From 83b2267b785037bcb54a904e4eecea1ddb3b0f22 Mon Sep 17 00:00:00 2001 From: Doug Ferraz Date: Fri, 22 Mar 2024 19:54:26 -0400 Subject: [PATCH] Bluetooth HCI: Add VTS requirement for HCI 4.2 Bug: 285456310 Test: atest VtsHalBluetoothTargetTest Change-Id: I056b924543ac349beb9b0eddaf039b0aa9187821 --- .../aidl/vts/VtsHalBluetoothTargetTest.cpp | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/bluetooth/aidl/vts/VtsHalBluetoothTargetTest.cpp b/bluetooth/aidl/vts/VtsHalBluetoothTargetTest.cpp index 395e4cc8cf..30aa642340 100644 --- a/bluetooth/aidl/vts/VtsHalBluetoothTargetTest.cpp +++ b/bluetooth/aidl/vts/VtsHalBluetoothTargetTest.cpp @@ -118,6 +118,10 @@ static bool isTv() { testing::deviceSupportsFeature("android.hardware.type.television"); } +static bool isHandheld() { + return testing::deviceSupportsFeature("android.hardware.type.handheld"); +} + class ThroughputLogger { public: explicit ThroughputLogger(std::string task) @@ -1050,6 +1054,47 @@ TEST_P(BluetoothAidlTest, Vsr_Bluetooth5Requirements) { ASSERT_GE(num_resolving_list, kMinLeResolvingListForBt5); } +/** + * Requirements + * + * VSR-5.3.14-007 MUST support Bluetooth 4.2 and Bluetooth LE Data Length Extension. + * VSR-5.3.14-008 MUST support Bluetooth Low Energy (BLE). + */ +TEST_P(BluetoothAidlTest, Vsr_Bluetooth4_2Requirements) { + // test only applies to handheld devices + if (!isHandheld()) { + return; + } + + std::vector version_event; + send_and_wait_for_cmd_complete(ReadLocalVersionInformationBuilder::Create(), + version_event); + auto version_view = ReadLocalVersionInformationCompleteView::Create( + CommandCompleteView::Create(EventView::Create(PacketView( + std::make_shared>(version_event))))); + ASSERT_TRUE(version_view.IsValid()); + ASSERT_EQ(::bluetooth::hci::ErrorCode::SUCCESS, version_view.GetStatus()); + auto version = version_view.GetLocalVersionInformation(); + // Starting with Android 15, Fails when HCI version is lower than 4.2. + ASSERT_GE(static_cast(version.hci_version_), + static_cast(::bluetooth::hci::HciVersion::V_4_2)); + ASSERT_GE(static_cast(version.lmp_version_), + static_cast(::bluetooth::hci::LmpVersion::V_4_2)); + + std::vector le_features_event; + send_and_wait_for_cmd_complete(LeReadLocalSupportedFeaturesBuilder::Create(), + le_features_event); + auto le_features_view = LeReadLocalSupportedFeaturesCompleteView::Create( + CommandCompleteView::Create(EventView::Create(PacketView( + std::make_shared>(le_features_event))))); + ASSERT_TRUE(le_features_view.IsValid()); + ASSERT_EQ(::bluetooth::hci::ErrorCode::SUCCESS, le_features_view.GetStatus()); + auto le_features = le_features_view.GetLeFeatures(); + ASSERT_TRUE(le_features & + static_cast(LLFeaturesBits::LE_EXTENDED_ADVERTISING)); + +} + GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(BluetoothAidlTest); INSTANTIATE_TEST_SUITE_P(PerInstance, BluetoothAidlTest, testing::ValuesIn(android::getAidlHalInstanceNames(