Loading system/gd/hci/le_address_manager.cc +8 −0 Original line number Diff line number Diff line Loading @@ -309,6 +309,14 @@ uint8_t LeAddressManager::GetResolvingListSize() { } void LeAddressManager::handle_next_command() { for (auto client : registered_clients_) { if (client.second != ClientState::PAUSED) { // make sure all client paused, if not, this function will be trigger again by ack_pause LOG_DEBUG("waiting for ack_pause, return"); return; } } ASSERT(!cached_commands_.empty()); auto command = std::move(cached_commands_.front()); cached_commands_.pop(); Loading system/gd/hci/le_address_manager_test.cc +25 −1 Original line number Diff line number Diff line Loading @@ -69,7 +69,10 @@ class TestHciLayer : public HciLayer { } CommandPacketView GetCommandPacket(OpCode op_code) { if (command_future_ != nullptr) { if (!command_queue_.empty() && command_future_ != nullptr) { command_promise_.reset(); command_future_.reset(); } else if (command_future_ != nullptr) { auto result = command_future_->wait_for(std::chrono::milliseconds(1000)); EXPECT_NE(std::future_status::timeout, result); } Loading Loading @@ -428,5 +431,26 @@ TEST_F(LeAddressManagerWithSingleClientTest, clear_resolving_list) { clients[0].get()->WaitForResume(); } TEST_F(LeAddressManagerWithSingleClientTest, register_during_command_complete) { Address address; Address::FromString("01:02:03:04:05:06", address); test_hci_layer_->SetCommandFuture(); le_address_manager_->AddDeviceToConnectList(ConnectListAddressType::RANDOM, address); auto packet = test_hci_layer_->GetCommandPacket(OpCode::LE_ADD_DEVICE_TO_CONNECT_LIST); auto packet_view = LeAddDeviceToConnectListView::Create(LeConnectionManagementCommandView::Create(packet)); ASSERT_TRUE(packet_view.IsValid()); ASSERT_EQ(ConnectListAddressType::RANDOM, packet_view.GetAddressType()); ASSERT_EQ(address, packet_view.GetAddress()); test_hci_layer_->IncomingEvent(LeAddDeviceToConnectListCompleteBuilder::Create(0x01, ErrorCode::SUCCESS)); AllocateClients(1); test_hci_layer_->SetCommandFuture(); le_address_manager_->Register(clients[1].get()); test_hci_layer_->GetCommandPacket(OpCode::LE_SET_RANDOM_ADDRESS); test_hci_layer_->IncomingEvent(LeSetRandomAddressCompleteBuilder::Create(0x01, ErrorCode::SUCCESS)); clients[0].get()->WaitForResume(); clients[1].get()->WaitForResume(); } } // namespace hci } // namespace bluetooth Loading
system/gd/hci/le_address_manager.cc +8 −0 Original line number Diff line number Diff line Loading @@ -309,6 +309,14 @@ uint8_t LeAddressManager::GetResolvingListSize() { } void LeAddressManager::handle_next_command() { for (auto client : registered_clients_) { if (client.second != ClientState::PAUSED) { // make sure all client paused, if not, this function will be trigger again by ack_pause LOG_DEBUG("waiting for ack_pause, return"); return; } } ASSERT(!cached_commands_.empty()); auto command = std::move(cached_commands_.front()); cached_commands_.pop(); Loading
system/gd/hci/le_address_manager_test.cc +25 −1 Original line number Diff line number Diff line Loading @@ -69,7 +69,10 @@ class TestHciLayer : public HciLayer { } CommandPacketView GetCommandPacket(OpCode op_code) { if (command_future_ != nullptr) { if (!command_queue_.empty() && command_future_ != nullptr) { command_promise_.reset(); command_future_.reset(); } else if (command_future_ != nullptr) { auto result = command_future_->wait_for(std::chrono::milliseconds(1000)); EXPECT_NE(std::future_status::timeout, result); } Loading Loading @@ -428,5 +431,26 @@ TEST_F(LeAddressManagerWithSingleClientTest, clear_resolving_list) { clients[0].get()->WaitForResume(); } TEST_F(LeAddressManagerWithSingleClientTest, register_during_command_complete) { Address address; Address::FromString("01:02:03:04:05:06", address); test_hci_layer_->SetCommandFuture(); le_address_manager_->AddDeviceToConnectList(ConnectListAddressType::RANDOM, address); auto packet = test_hci_layer_->GetCommandPacket(OpCode::LE_ADD_DEVICE_TO_CONNECT_LIST); auto packet_view = LeAddDeviceToConnectListView::Create(LeConnectionManagementCommandView::Create(packet)); ASSERT_TRUE(packet_view.IsValid()); ASSERT_EQ(ConnectListAddressType::RANDOM, packet_view.GetAddressType()); ASSERT_EQ(address, packet_view.GetAddress()); test_hci_layer_->IncomingEvent(LeAddDeviceToConnectListCompleteBuilder::Create(0x01, ErrorCode::SUCCESS)); AllocateClients(1); test_hci_layer_->SetCommandFuture(); le_address_manager_->Register(clients[1].get()); test_hci_layer_->GetCommandPacket(OpCode::LE_SET_RANDOM_ADDRESS); test_hci_layer_->IncomingEvent(LeSetRandomAddressCompleteBuilder::Create(0x01, ErrorCode::SUCCESS)); clients[0].get()->WaitForResume(); clients[1].get()->WaitForResume(); } } // namespace hci } // namespace bluetooth