Loading system/gd/hci/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -39,6 +39,7 @@ filegroup { "address_unittest.cc", "address_with_type_test.cc", "class_of_device_unittest.cc", "controller_unittest.cc", "hci_packets_test.cc", "uuid_unittest.cc", "le_periodic_sync_manager_test.cc" Loading system/gd/hci/controller.cc +3 −1 Original line number Diff line number Diff line Loading @@ -38,7 +38,6 @@ struct Controller::impl { hci_->RegisterEventHandler( EventCode::NUMBER_OF_COMPLETED_PACKETS, handler->BindOn(this, &Controller::impl::NumberOfCompletedPackets)); le_set_event_mask(kDefaultLeEventMask); set_event_mask(kDefaultEventMask); write_le_host_support(Enable::ENABLED, Enable::DISABLED); hci_->EnqueueCommand(ReadLocalNameBuilder::Create(), Loading @@ -59,11 +58,14 @@ struct Controller::impl { // Wait for all extended features read std::promise<void> features_promise; auto features_future = features_promise.get_future(); hci_->EnqueueCommand(ReadLocalExtendedFeaturesBuilder::Create(0x00), handler->BindOnceOn(this, &Controller::impl::read_local_extended_features_complete_handler, std::move(features_promise))); features_future.wait(); le_set_event_mask(MaskLeEventMask(local_version_information_.hci_version_, kDefaultLeEventMask)); hci_->EnqueueCommand(ReadBufferSizeBuilder::Create(), handler->BindOnceOn(this, &Controller::impl::read_buffer_size_complete_handler)); Loading system/gd/hci/controller.h +17 −0 Original line number Diff line number Diff line Loading @@ -202,6 +202,23 @@ class Controller : public Module { static constexpr uint64_t kDefaultEventMask = 0x3dbfffffffffffff; static constexpr uint64_t kDefaultLeEventMask = 0x000000004d02fe7f; static constexpr uint64_t kLeEventMask52 = 0x00000003ffffffff; static constexpr uint64_t kLeEventMask51 = 0x0000000000ffffff; static constexpr uint64_t kLeEventMask42 = 0x00000000000003ff; static constexpr uint64_t kLeEventMask41 = 0x000000000000003f; static uint64_t MaskLeEventMask(HciVersion version, uint64_t mask) { if (version >= HciVersion::V_5_2) { return mask; } else if (version >= HciVersion::V_5_1) { return mask & kLeEventMask51; } else if (version >= HciVersion::V_4_2) { return mask & kLeEventMask42; } else { return mask & kLeEventMask41; } } protected: void ListDependencies(ModuleList* list) const override; Loading system/gd/hci/controller_unittest.cc 0 → 100644 +55 −0 Original line number Diff line number Diff line /* * Copyright 2022 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "hci/controller.h" #include <gtest/gtest.h> namespace bluetooth { namespace hci { class ControllerUnitTest : public ::testing::Test { protected: void SetUp() override {} void TearDown() override {} }; TEST_F(ControllerUnitTest, testLeEventMask) { LocalVersionInformation version; version.hci_version_ = HciVersion::V_5_2; // Update the function and this test when adding new bits. ASSERT_TRUE(Controller::kLeEventMask52 > Controller::kDefaultLeEventMask); ASSERT_EQ( Controller::MaskLeEventMask(version.hci_version_, Controller::kDefaultLeEventMask), Controller::kDefaultLeEventMask); ASSERT_LE( Controller::MaskLeEventMask(version.hci_version_, Controller::kDefaultLeEventMask), Controller::kLeEventMask52); version.hci_version_ = HciVersion::V_5_1; ASSERT_LE( Controller::MaskLeEventMask(version.hci_version_, Controller::kDefaultLeEventMask), Controller::kLeEventMask51); version.hci_version_ = HciVersion::V_4_2; ASSERT_LE( Controller::MaskLeEventMask(version.hci_version_, Controller::kDefaultLeEventMask), Controller::kLeEventMask42); version.hci_version_ = HciVersion::V_4_1; ASSERT_LE( Controller::MaskLeEventMask(version.hci_version_, Controller::kDefaultLeEventMask), Controller::kLeEventMask41); } } // namespace hci } // namespace bluetooth Loading
system/gd/hci/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -39,6 +39,7 @@ filegroup { "address_unittest.cc", "address_with_type_test.cc", "class_of_device_unittest.cc", "controller_unittest.cc", "hci_packets_test.cc", "uuid_unittest.cc", "le_periodic_sync_manager_test.cc" Loading
system/gd/hci/controller.cc +3 −1 Original line number Diff line number Diff line Loading @@ -38,7 +38,6 @@ struct Controller::impl { hci_->RegisterEventHandler( EventCode::NUMBER_OF_COMPLETED_PACKETS, handler->BindOn(this, &Controller::impl::NumberOfCompletedPackets)); le_set_event_mask(kDefaultLeEventMask); set_event_mask(kDefaultEventMask); write_le_host_support(Enable::ENABLED, Enable::DISABLED); hci_->EnqueueCommand(ReadLocalNameBuilder::Create(), Loading @@ -59,11 +58,14 @@ struct Controller::impl { // Wait for all extended features read std::promise<void> features_promise; auto features_future = features_promise.get_future(); hci_->EnqueueCommand(ReadLocalExtendedFeaturesBuilder::Create(0x00), handler->BindOnceOn(this, &Controller::impl::read_local_extended_features_complete_handler, std::move(features_promise))); features_future.wait(); le_set_event_mask(MaskLeEventMask(local_version_information_.hci_version_, kDefaultLeEventMask)); hci_->EnqueueCommand(ReadBufferSizeBuilder::Create(), handler->BindOnceOn(this, &Controller::impl::read_buffer_size_complete_handler)); Loading
system/gd/hci/controller.h +17 −0 Original line number Diff line number Diff line Loading @@ -202,6 +202,23 @@ class Controller : public Module { static constexpr uint64_t kDefaultEventMask = 0x3dbfffffffffffff; static constexpr uint64_t kDefaultLeEventMask = 0x000000004d02fe7f; static constexpr uint64_t kLeEventMask52 = 0x00000003ffffffff; static constexpr uint64_t kLeEventMask51 = 0x0000000000ffffff; static constexpr uint64_t kLeEventMask42 = 0x00000000000003ff; static constexpr uint64_t kLeEventMask41 = 0x000000000000003f; static uint64_t MaskLeEventMask(HciVersion version, uint64_t mask) { if (version >= HciVersion::V_5_2) { return mask; } else if (version >= HciVersion::V_5_1) { return mask & kLeEventMask51; } else if (version >= HciVersion::V_4_2) { return mask & kLeEventMask42; } else { return mask & kLeEventMask41; } } protected: void ListDependencies(ModuleList* list) const override; Loading
system/gd/hci/controller_unittest.cc 0 → 100644 +55 −0 Original line number Diff line number Diff line /* * Copyright 2022 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "hci/controller.h" #include <gtest/gtest.h> namespace bluetooth { namespace hci { class ControllerUnitTest : public ::testing::Test { protected: void SetUp() override {} void TearDown() override {} }; TEST_F(ControllerUnitTest, testLeEventMask) { LocalVersionInformation version; version.hci_version_ = HciVersion::V_5_2; // Update the function and this test when adding new bits. ASSERT_TRUE(Controller::kLeEventMask52 > Controller::kDefaultLeEventMask); ASSERT_EQ( Controller::MaskLeEventMask(version.hci_version_, Controller::kDefaultLeEventMask), Controller::kDefaultLeEventMask); ASSERT_LE( Controller::MaskLeEventMask(version.hci_version_, Controller::kDefaultLeEventMask), Controller::kLeEventMask52); version.hci_version_ = HciVersion::V_5_1; ASSERT_LE( Controller::MaskLeEventMask(version.hci_version_, Controller::kDefaultLeEventMask), Controller::kLeEventMask51); version.hci_version_ = HciVersion::V_4_2; ASSERT_LE( Controller::MaskLeEventMask(version.hci_version_, Controller::kDefaultLeEventMask), Controller::kLeEventMask42); version.hci_version_ = HciVersion::V_4_1; ASSERT_LE( Controller::MaskLeEventMask(version.hci_version_, Controller::kDefaultLeEventMask), Controller::kLeEventMask41); } } // namespace hci } // namespace bluetooth