Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 31b3f653 authored by Doug Ferraz's avatar Doug Ferraz
Browse files

Bluetooth HCI: Add VTS requirement for HCI 4.2

Bug: 285456310
Test: atest VtsHalBluetoothTargetTest
(cherry picked from https://android-review.googlesource.com/q/commit:83b2267b785037bcb54a904e4eecea1ddb3b0f22)
Merged-In: I056b924543ac349beb9b0eddaf039b0aa9187821
Change-Id: I056b924543ac349beb9b0eddaf039b0aa9187821
24D1-dev is based on 24Q2-release. Therefore, we merged this CL to 24D1-dev.
parent c2b68f2b
Loading
Loading
Loading
Loading
+45 −0
Original line number Diff line number Diff line
@@ -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)
@@ -1039,6 +1043,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<uint8_t> version_event;
  send_and_wait_for_cmd_complete(ReadLocalVersionInformationBuilder::Create(),
                                 version_event);
  auto version_view = ReadLocalVersionInformationCompleteView::Create(
      CommandCompleteView::Create(EventView::Create(PacketView<true>(
          std::make_shared<std::vector<uint8_t>>(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<int>(version.hci_version_),
    static_cast<int>(::bluetooth::hci::HciVersion::V_4_2));
  ASSERT_GE(static_cast<int>(version.lmp_version_),
    static_cast<int>(::bluetooth::hci::LmpVersion::V_4_2));

  std::vector<uint8_t> 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<true>(
          std::make_shared<std::vector<uint8_t>>(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<uint64_t>(LLFeaturesBits::LE_EXTENDED_ADVERTISING));

}

GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(BluetoothAidlTest);
INSTANTIATE_TEST_SUITE_P(PerInstance, BluetoothAidlTest,
                         testing::ValuesIn(android::getAidlHalInstanceNames(