Loading system/gd/hci/acl_manager/le_acceptlist_callbacks.h +0 −6 Original line number Diff line number Diff line Loading @@ -35,12 +35,6 @@ class LeAcceptlistCallbacks { // Invoked when controller sends Connection Complete event with Success error code // AddressWithType is the address returned by the controller. virtual void OnLeConnectSuccess(AddressWithType) = 0; // Invoked when controller sends Connection Complete event with failing error code // AddressWithType is the address returned by the controller. virtual void OnLeConnectFail(AddressWithType, ErrorCode reason) = 0; // Invoked when an LE connection is disconnected. AddressWithType is the remote address // associated with this connection at the time of connection. virtual void OnLeDisconnection(AddressWithType) = 0; // Invoked when the resolving list has changed, so we need to re-resolve our addresses. virtual void OnResolvingListChange() = 0; }; Loading system/gd/hci/acl_manager/le_impl.h +20 −18 Original line number Diff line number Diff line Loading @@ -313,17 +313,6 @@ struct le_impl : public bluetooth::hci::LeAddressManagerCallback { return connections.send_packet_upward(handle, cb); } void report_le_connection_failure(AddressWithType address, ErrorCode status) { le_client_handler_->Post(common::BindOnce( &LeConnectionCallbacks::OnLeConnectFail, common::Unretained(le_client_callbacks_), address, status)); if (le_acceptlist_callbacks_ != nullptr) { le_acceptlist_callbacks_->OnLeConnectFail(address, status); } } // connection canceled by LeAddressManager.OnPause(), will auto reconnect by LeAddressManager.OnResume() void on_le_connection_canceled_on_pause() { ASSERT_LOG(pause_connection, "Connection must be paused to ack the le address manager"); Loading Loading @@ -398,7 +387,11 @@ struct le_impl : public bluetooth::hci::LeAddressManagerCallback { } if (status != ErrorCode::SUCCESS) { report_le_connection_failure(remote_address, status); le_client_handler_->Post(common::BindOnce( &LeConnectionCallbacks::OnLeConnectFail, common::Unretained(le_client_callbacks_), remote_address, status)); return; } } else { Loading @@ -411,7 +404,11 @@ struct le_impl : public bluetooth::hci::LeAddressManagerCallback { if (status != ErrorCode::SUCCESS) { std::string error_code = ErrorCodeText(status); LOG_WARN("Received on_le_connection_complete with error code %s", error_code.c_str()); report_le_connection_failure(remote_address, status); le_client_handler_->Post(common::BindOnce( &LeConnectionCallbacks::OnLeConnectFail, common::Unretained(le_client_callbacks_), remote_address, status)); return; } Loading Loading @@ -546,7 +543,11 @@ struct le_impl : public bluetooth::hci::LeAddressManagerCallback { } if (status != ErrorCode::SUCCESS) { report_le_connection_failure(remote_address, status); le_client_handler_->Post(common::BindOnce( &LeConnectionCallbacks::OnLeConnectFail, common::Unretained(le_client_callbacks_), remote_address, status)); return; } Loading @@ -560,7 +561,11 @@ struct le_impl : public bluetooth::hci::LeAddressManagerCallback { if (status != ErrorCode::SUCCESS) { std::string error_code = ErrorCodeText(status); LOG_WARN("Received on_le_enhanced_connection_complete with error code %s", error_code.c_str()); report_le_connection_failure(remote_address, status); le_client_handler_->Post(common::BindOnce( &LeConnectionCallbacks::OnLeConnectFail, common::Unretained(le_client_callbacks_), remote_address, status)); return; } Loading Loading @@ -663,9 +668,6 @@ struct le_impl : public bluetooth::hci::LeAddressManagerCallback { callbacks->OnDisconnection(reason); }, kRemoveConnectionAfterwards); if (le_acceptlist_callbacks_ != nullptr) { le_acceptlist_callbacks_->OnLeDisconnection(remote_address); } connections.crash_on_unknown_handle_ = event_also_routes_to_other_receivers; if (background_connections_.count(remote_address) == 1) { Loading system/gd/hci/acl_manager/le_impl_test.cc +1 −87 Original line number Diff line number Diff line Loading @@ -407,9 +407,7 @@ class MockLeConnectionCallbacks : public LeConnectionCallbacks { class MockLeAcceptlistCallbacks : public LeAcceptlistCallbacks { public: MOCK_METHOD(void, OnLeConnectSuccess, (AddressWithType address), (override)); MOCK_METHOD(void, OnLeConnectFail, (AddressWithType address, ErrorCode reason), (override)); MOCK_METHOD(void, OnLeDisconnection, (AddressWithType address), (override)); MOCK_METHOD(void, OnLeConnectSuccess, (AddressWithType address_with_type), (override)); MOCK_METHOD(void, OnResolvingListChange, (), (override)); }; Loading Loading @@ -1728,90 +1726,6 @@ TEST_F(LeImplTest, ResolvingListCallback) { Mock::VerifyAndClearExpectations(&callbacks); } TEST_F(LeImplTest, ConnectionFailedAcceptlistCallback) { // arrange MockLeAcceptlistCallbacks callbacks; le_impl_->handle_register_le_acceptlist_callbacks(&callbacks); set_random_device_address_policy(); // expect AddressWithType remote_address; ErrorCode reason; EXPECT_CALL(callbacks, OnLeConnectFail(_, _)) .WillOnce([&](AddressWithType addr, ErrorCode error) { remote_address = addr; reason = error; }); // act auto command = LeEnhancedConnectionCompleteBuilder::Create( ErrorCode::CONTROLLER_BUSY, kHciHandle, Role::PERIPHERAL, AddressType::PUBLIC_DEVICE_ADDRESS, remote_address_, local_rpa_, remote_rpa_, 0x0024, 0x0000, 0x0011, ClockAccuracy::PPM_30); auto bytes = Serialize<LeEnhancedConnectionCompleteBuilder>(std::move(command)); auto view = CreateLeEventView<hci::LeEnhancedConnectionCompleteView>(bytes); ASSERT_TRUE(view.IsValid()); le_impl_->on_le_event(view); sync_handler(); // assert EXPECT_EQ(remote_address, remote_public_address_with_type_); EXPECT_EQ(reason, ErrorCode::CONTROLLER_BUSY); } TEST_F(LeImplTest, DisconnectionAcceptlistCallback) { // expect MockLeAcceptlistCallbacks callbacks; AddressWithType remote_address; EXPECT_CALL(callbacks, OnLeDisconnection(_)).WillOnce([&](AddressWithType addr) { remote_address = addr; }); // we need to capture the LeAclConnection so it is not immediately dropped => disconnected std::unique_ptr<LeAclConnection> connection; EXPECT_CALL(mock_le_connection_callbacks_, OnLeConnectSuccess(_, _)) .WillOnce([&](AddressWithType, std::unique_ptr<LeAclConnection> conn) { connection = std::move(conn); connection->RegisterCallbacks(&connection_management_callbacks_, handler_); }); // arrange: an active connection to a peer le_impl_->handle_register_le_acceptlist_callbacks(&callbacks); set_random_device_address_policy(); auto command = LeEnhancedConnectionCompleteBuilder::Create( ErrorCode::SUCCESS, kHciHandle, Role::PERIPHERAL, AddressType::PUBLIC_DEVICE_ADDRESS, remote_address_, local_rpa_, remote_rpa_, 0x0024, 0x0000, 0x0011, ClockAccuracy::PPM_30); auto bytes = Serialize<LeEnhancedConnectionCompleteBuilder>(std::move(command)); auto view = CreateLeEventView<hci::LeEnhancedConnectionCompleteView>(bytes); ASSERT_TRUE(view.IsValid()); le_impl_->on_le_event(view); sync_handler(); // act le_impl_->on_le_disconnect(kHciHandle, ErrorCode::REMOTE_USER_TERMINATED_CONNECTION); sync_handler(); // assert EXPECT_EQ(remote_public_address_with_type_, remote_address); Mock::VerifyAndClearExpectations(&callbacks); } } // namespace acl_manager } // namespace hci } // namespace bluetooth system/rust/src/connection/ffi.rs +1 −1 Original line number Diff line number Diff line Loading @@ -69,7 +69,7 @@ mod inner { fn on_le_connect_success(&self, address: AddressWithType); #[cxx_name = "OnLeConnectFail"] fn on_le_connect_fail(&self, address: AddressWithType, status: u8); #[cxx_name = "OnLeDisconnection"] #[cxx_name = "OnDisconnect"] fn on_disconnect(&self, address: AddressWithType); } Loading system/rust/src/connection/ffi/connection_shim.cc +1 −13 Original line number Diff line number Diff line Loading @@ -43,7 +43,7 @@ struct LeAclManagerCallbackShim { void OnLeConnectFail(core::AddressWithType addr, uint8_t status) const { LOG_ALWAYS_FATAL("system/rust not available in Floss"); }; void OnLeDisconnection(core::AddressWithType addr) const { void OnDisconnect(core::AddressWithType addr) const { LOG_ALWAYS_FATAL("system/rust not available in Floss"); }; }; Loading Loading @@ -94,18 +94,6 @@ struct LeAclManagerShim::impl : hci::acl_manager::LeAcceptlistCallbacks { callbacks_.value()->OnLeConnectSuccess(ToRustAddress(address)); } // hci::acl_manager::LeAcceptlistCallbacks virtual void OnLeConnectFail(hci::AddressWithType address, hci::ErrorCode reason) { callbacks_.value()->OnLeConnectFail(ToRustAddress(address), static_cast<uint8_t>(reason)); } // hci::acl_manager::LeAcceptlistCallbacks virtual void OnLeDisconnection(hci::AddressWithType address) { callbacks_.value()->OnLeDisconnection(ToRustAddress(address)); } // hci::acl_manager::LeAcceptlistCallbacks virtual void OnResolvingListChange() {} Loading Loading
system/gd/hci/acl_manager/le_acceptlist_callbacks.h +0 −6 Original line number Diff line number Diff line Loading @@ -35,12 +35,6 @@ class LeAcceptlistCallbacks { // Invoked when controller sends Connection Complete event with Success error code // AddressWithType is the address returned by the controller. virtual void OnLeConnectSuccess(AddressWithType) = 0; // Invoked when controller sends Connection Complete event with failing error code // AddressWithType is the address returned by the controller. virtual void OnLeConnectFail(AddressWithType, ErrorCode reason) = 0; // Invoked when an LE connection is disconnected. AddressWithType is the remote address // associated with this connection at the time of connection. virtual void OnLeDisconnection(AddressWithType) = 0; // Invoked when the resolving list has changed, so we need to re-resolve our addresses. virtual void OnResolvingListChange() = 0; }; Loading
system/gd/hci/acl_manager/le_impl.h +20 −18 Original line number Diff line number Diff line Loading @@ -313,17 +313,6 @@ struct le_impl : public bluetooth::hci::LeAddressManagerCallback { return connections.send_packet_upward(handle, cb); } void report_le_connection_failure(AddressWithType address, ErrorCode status) { le_client_handler_->Post(common::BindOnce( &LeConnectionCallbacks::OnLeConnectFail, common::Unretained(le_client_callbacks_), address, status)); if (le_acceptlist_callbacks_ != nullptr) { le_acceptlist_callbacks_->OnLeConnectFail(address, status); } } // connection canceled by LeAddressManager.OnPause(), will auto reconnect by LeAddressManager.OnResume() void on_le_connection_canceled_on_pause() { ASSERT_LOG(pause_connection, "Connection must be paused to ack the le address manager"); Loading Loading @@ -398,7 +387,11 @@ struct le_impl : public bluetooth::hci::LeAddressManagerCallback { } if (status != ErrorCode::SUCCESS) { report_le_connection_failure(remote_address, status); le_client_handler_->Post(common::BindOnce( &LeConnectionCallbacks::OnLeConnectFail, common::Unretained(le_client_callbacks_), remote_address, status)); return; } } else { Loading @@ -411,7 +404,11 @@ struct le_impl : public bluetooth::hci::LeAddressManagerCallback { if (status != ErrorCode::SUCCESS) { std::string error_code = ErrorCodeText(status); LOG_WARN("Received on_le_connection_complete with error code %s", error_code.c_str()); report_le_connection_failure(remote_address, status); le_client_handler_->Post(common::BindOnce( &LeConnectionCallbacks::OnLeConnectFail, common::Unretained(le_client_callbacks_), remote_address, status)); return; } Loading Loading @@ -546,7 +543,11 @@ struct le_impl : public bluetooth::hci::LeAddressManagerCallback { } if (status != ErrorCode::SUCCESS) { report_le_connection_failure(remote_address, status); le_client_handler_->Post(common::BindOnce( &LeConnectionCallbacks::OnLeConnectFail, common::Unretained(le_client_callbacks_), remote_address, status)); return; } Loading @@ -560,7 +561,11 @@ struct le_impl : public bluetooth::hci::LeAddressManagerCallback { if (status != ErrorCode::SUCCESS) { std::string error_code = ErrorCodeText(status); LOG_WARN("Received on_le_enhanced_connection_complete with error code %s", error_code.c_str()); report_le_connection_failure(remote_address, status); le_client_handler_->Post(common::BindOnce( &LeConnectionCallbacks::OnLeConnectFail, common::Unretained(le_client_callbacks_), remote_address, status)); return; } Loading Loading @@ -663,9 +668,6 @@ struct le_impl : public bluetooth::hci::LeAddressManagerCallback { callbacks->OnDisconnection(reason); }, kRemoveConnectionAfterwards); if (le_acceptlist_callbacks_ != nullptr) { le_acceptlist_callbacks_->OnLeDisconnection(remote_address); } connections.crash_on_unknown_handle_ = event_also_routes_to_other_receivers; if (background_connections_.count(remote_address) == 1) { Loading
system/gd/hci/acl_manager/le_impl_test.cc +1 −87 Original line number Diff line number Diff line Loading @@ -407,9 +407,7 @@ class MockLeConnectionCallbacks : public LeConnectionCallbacks { class MockLeAcceptlistCallbacks : public LeAcceptlistCallbacks { public: MOCK_METHOD(void, OnLeConnectSuccess, (AddressWithType address), (override)); MOCK_METHOD(void, OnLeConnectFail, (AddressWithType address, ErrorCode reason), (override)); MOCK_METHOD(void, OnLeDisconnection, (AddressWithType address), (override)); MOCK_METHOD(void, OnLeConnectSuccess, (AddressWithType address_with_type), (override)); MOCK_METHOD(void, OnResolvingListChange, (), (override)); }; Loading Loading @@ -1728,90 +1726,6 @@ TEST_F(LeImplTest, ResolvingListCallback) { Mock::VerifyAndClearExpectations(&callbacks); } TEST_F(LeImplTest, ConnectionFailedAcceptlistCallback) { // arrange MockLeAcceptlistCallbacks callbacks; le_impl_->handle_register_le_acceptlist_callbacks(&callbacks); set_random_device_address_policy(); // expect AddressWithType remote_address; ErrorCode reason; EXPECT_CALL(callbacks, OnLeConnectFail(_, _)) .WillOnce([&](AddressWithType addr, ErrorCode error) { remote_address = addr; reason = error; }); // act auto command = LeEnhancedConnectionCompleteBuilder::Create( ErrorCode::CONTROLLER_BUSY, kHciHandle, Role::PERIPHERAL, AddressType::PUBLIC_DEVICE_ADDRESS, remote_address_, local_rpa_, remote_rpa_, 0x0024, 0x0000, 0x0011, ClockAccuracy::PPM_30); auto bytes = Serialize<LeEnhancedConnectionCompleteBuilder>(std::move(command)); auto view = CreateLeEventView<hci::LeEnhancedConnectionCompleteView>(bytes); ASSERT_TRUE(view.IsValid()); le_impl_->on_le_event(view); sync_handler(); // assert EXPECT_EQ(remote_address, remote_public_address_with_type_); EXPECT_EQ(reason, ErrorCode::CONTROLLER_BUSY); } TEST_F(LeImplTest, DisconnectionAcceptlistCallback) { // expect MockLeAcceptlistCallbacks callbacks; AddressWithType remote_address; EXPECT_CALL(callbacks, OnLeDisconnection(_)).WillOnce([&](AddressWithType addr) { remote_address = addr; }); // we need to capture the LeAclConnection so it is not immediately dropped => disconnected std::unique_ptr<LeAclConnection> connection; EXPECT_CALL(mock_le_connection_callbacks_, OnLeConnectSuccess(_, _)) .WillOnce([&](AddressWithType, std::unique_ptr<LeAclConnection> conn) { connection = std::move(conn); connection->RegisterCallbacks(&connection_management_callbacks_, handler_); }); // arrange: an active connection to a peer le_impl_->handle_register_le_acceptlist_callbacks(&callbacks); set_random_device_address_policy(); auto command = LeEnhancedConnectionCompleteBuilder::Create( ErrorCode::SUCCESS, kHciHandle, Role::PERIPHERAL, AddressType::PUBLIC_DEVICE_ADDRESS, remote_address_, local_rpa_, remote_rpa_, 0x0024, 0x0000, 0x0011, ClockAccuracy::PPM_30); auto bytes = Serialize<LeEnhancedConnectionCompleteBuilder>(std::move(command)); auto view = CreateLeEventView<hci::LeEnhancedConnectionCompleteView>(bytes); ASSERT_TRUE(view.IsValid()); le_impl_->on_le_event(view); sync_handler(); // act le_impl_->on_le_disconnect(kHciHandle, ErrorCode::REMOTE_USER_TERMINATED_CONNECTION); sync_handler(); // assert EXPECT_EQ(remote_public_address_with_type_, remote_address); Mock::VerifyAndClearExpectations(&callbacks); } } // namespace acl_manager } // namespace hci } // namespace bluetooth
system/rust/src/connection/ffi.rs +1 −1 Original line number Diff line number Diff line Loading @@ -69,7 +69,7 @@ mod inner { fn on_le_connect_success(&self, address: AddressWithType); #[cxx_name = "OnLeConnectFail"] fn on_le_connect_fail(&self, address: AddressWithType, status: u8); #[cxx_name = "OnLeDisconnection"] #[cxx_name = "OnDisconnect"] fn on_disconnect(&self, address: AddressWithType); } Loading
system/rust/src/connection/ffi/connection_shim.cc +1 −13 Original line number Diff line number Diff line Loading @@ -43,7 +43,7 @@ struct LeAclManagerCallbackShim { void OnLeConnectFail(core::AddressWithType addr, uint8_t status) const { LOG_ALWAYS_FATAL("system/rust not available in Floss"); }; void OnLeDisconnection(core::AddressWithType addr) const { void OnDisconnect(core::AddressWithType addr) const { LOG_ALWAYS_FATAL("system/rust not available in Floss"); }; }; Loading Loading @@ -94,18 +94,6 @@ struct LeAclManagerShim::impl : hci::acl_manager::LeAcceptlistCallbacks { callbacks_.value()->OnLeConnectSuccess(ToRustAddress(address)); } // hci::acl_manager::LeAcceptlistCallbacks virtual void OnLeConnectFail(hci::AddressWithType address, hci::ErrorCode reason) { callbacks_.value()->OnLeConnectFail(ToRustAddress(address), static_cast<uint8_t>(reason)); } // hci::acl_manager::LeAcceptlistCallbacks virtual void OnLeDisconnection(hci::AddressWithType address) { callbacks_.value()->OnLeDisconnection(ToRustAddress(address)); } // hci::acl_manager::LeAcceptlistCallbacks virtual void OnResolvingListChange() {} Loading