Loading system/blueberry/facade/hci/le_acl_manager_facade.proto +10 −0 Original line number Diff line number Diff line Loading @@ -14,6 +14,9 @@ service LeAclManagerFacade { rpc FetchAclData(LeHandleMsg) returns (stream LeAclData) {} rpc FetchIncomingConnection(google.protobuf.Empty) returns (stream LeConnectionEvent) {} rpc AddDeviceToResolvingList(IrkMsg) returns (google.protobuf.Empty) {} rpc IsOnBackgroundList(BackgroundRequestMsg) returns (BackgroundResultMsg) {} rpc RemoveFromBackgroundList(BackgroundRequestMsg) returns (google.protobuf.Empty) {} } message LeHandleMsg { Loading Loading @@ -44,3 +47,10 @@ message IrkMsg { bytes local_irk = 3; } message BackgroundRequestMsg { blueberry.facade.BluetoothAddressWithType peer_address = 1; } message BackgroundResultMsg { bool is_on_background_list = 1; } system/blueberry/tests/gd/cert/py_le_acl_manager.py +8 −0 Original line number Diff line number Diff line Loading @@ -124,6 +124,14 @@ class PyLeAclManager(Closable): self.next_token += 1 return token def is_on_background_list(self, remote_addr): return self.le_acl_manager.IsOnBackgroundList( le_acl_manager_facade.BackgroundRequestMsg(peer_address=remote_addr)) def remove_from_background_list(self, remote_addr): self.le_acl_manager.RemoveFromBackgroundList( le_acl_manager_facade.BackgroundRequestMsg(peer_address=remote_addr)) def complete_connection(self, event_stream): connection_complete = HciCaptures.LeConnectionCompleteCapture() assertThat(event_stream).emits(connection_complete) Loading system/blueberry/tests/gd/hci/le_acl_manager_test.py +40 −0 Original line number Diff line number Diff line Loading @@ -403,6 +403,46 @@ class LeAclManagerTest(gd_base_test.GdBaseTestClass): is_direct=True) self.dut_le_acl_manager.complete_outgoing_connection(token) def test_background_connection_list(self): self.set_privacy_policy_static() # Start background connection token_background = self.dut_le_acl_manager.initiate_connection( remote_addr=common.BluetoothAddressWithType( address=common.BluetoothAddress(address=bytes(self.cert_random_address, 'utf8')), type=int(hci_packets.AddressType.RANDOM_DEVICE_ADDRESS)), is_direct=False) # Cert Advertises advertising_handle = 0 py_hci_adv = self.cert_hci.create_advertisement(advertising_handle, self.cert_random_address, hci_packets.LegacyAdvertisingProperties.ADV_IND, 155, 165) py_hci_adv.set_data(b'Im_A_Cert') py_hci_adv.set_scan_response(b'Im_A_C') py_hci_adv.start() # Check background connection complete self.dut_le_acl_manager.complete_outgoing_connection(token_background) msg = self.dut_le_acl_manager.is_on_background_list( remote_addr=common.BluetoothAddressWithType( address=common.BluetoothAddress(address=bytes(self.cert_random_address, 'utf8')), type=int(hci_packets.AddressType.RANDOM_DEVICE_ADDRESS))) assertThat(msg.is_on_background_list).isEqualTo(True) self.dut_le_acl_manager.remove_from_background_list( remote_addr=common.BluetoothAddressWithType( address=common.BluetoothAddress(address=bytes(self.cert_random_address, 'utf8')), type=int(hci_packets.AddressType.RANDOM_DEVICE_ADDRESS))) msg = self.dut_le_acl_manager.is_on_background_list( remote_addr=common.BluetoothAddressWithType( address=common.BluetoothAddress(address=bytes(self.cert_random_address, 'utf8')), type=int(hci_packets.AddressType.RANDOM_DEVICE_ADDRESS))) assertThat(msg.is_on_background_list).isEqualTo(False) if __name__ == '__main__': test_runner.main() system/gd/hci/acl_manager.cc +15 −0 Original line number Diff line number Diff line Loading @@ -160,6 +160,10 @@ void AclManager::CreateLeConnection(AddressWithType address_with_type, bool is_d CallOn(pimpl_->le_impl_, &le_impl::create_le_connection, address_with_type, true, is_direct); } void AclManager::IsOnBackgroundList(AddressWithType address_with_type, std::promise<bool> promise) { CallOn(pimpl_->le_impl_, &le_impl::is_on_background_connection_list, address_with_type, std::move(promise)); } void AclManager::SetLeSuggestedDefaultDataParameters(uint16_t octets, uint16_t time) { CallOn(pimpl_->le_impl_, &le_impl::set_le_suggested_default_data_parameters, octets, time); } Loading Loading @@ -210,6 +214,17 @@ void AclManager::CancelLeConnect(AddressWithType address_with_type) { CallOn(pimpl_->le_impl_, &le_impl::cancel_connect, address_with_type); } void AclManager::RemoveFromBackgroundList(AddressWithType address_with_type) { CallOn(pimpl_->le_impl_, &le_impl::remove_device_from_background_connection_list, address_with_type); } void AclManager::CancelLeConnectAndRemoveFromBackgroundList(AddressWithType address_with_type) { CallOn( pimpl_->le_impl_, &le_impl::cancel_connection_and_remove_device_from_background_connection_list, address_with_type); } void AclManager::AddDeviceToFilterAcceptList(AddressWithType address_with_type) { CallOn(pimpl_->le_impl_, &le_impl::add_device_to_connect_list, address_with_type); } Loading system/gd/hci/acl_manager.h +4 −0 Original line number Diff line number Diff line Loading @@ -103,8 +103,12 @@ public: // Generates OnConnectFail with error code "terminated by local host 0x16" if cancelled, or OnConnectSuccess if not // successfully cancelled and already connected virtual void CancelConnect(Address address); virtual void RemoveFromBackgroundList(AddressWithType address_with_type); virtual void IsOnBackgroundList(AddressWithType address_with_type, std::promise<bool> promise); virtual void CancelLeConnect(AddressWithType address_with_type); virtual void CancelLeConnectAndRemoveFromBackgroundList(AddressWithType address_with_type); virtual void AddDeviceToFilterAcceptList(AddressWithType address_with_type); virtual void RemoveDeviceFromFilterAcceptList(AddressWithType address_with_type); virtual void ClearFilterAcceptList(); Loading Loading
system/blueberry/facade/hci/le_acl_manager_facade.proto +10 −0 Original line number Diff line number Diff line Loading @@ -14,6 +14,9 @@ service LeAclManagerFacade { rpc FetchAclData(LeHandleMsg) returns (stream LeAclData) {} rpc FetchIncomingConnection(google.protobuf.Empty) returns (stream LeConnectionEvent) {} rpc AddDeviceToResolvingList(IrkMsg) returns (google.protobuf.Empty) {} rpc IsOnBackgroundList(BackgroundRequestMsg) returns (BackgroundResultMsg) {} rpc RemoveFromBackgroundList(BackgroundRequestMsg) returns (google.protobuf.Empty) {} } message LeHandleMsg { Loading Loading @@ -44,3 +47,10 @@ message IrkMsg { bytes local_irk = 3; } message BackgroundRequestMsg { blueberry.facade.BluetoothAddressWithType peer_address = 1; } message BackgroundResultMsg { bool is_on_background_list = 1; }
system/blueberry/tests/gd/cert/py_le_acl_manager.py +8 −0 Original line number Diff line number Diff line Loading @@ -124,6 +124,14 @@ class PyLeAclManager(Closable): self.next_token += 1 return token def is_on_background_list(self, remote_addr): return self.le_acl_manager.IsOnBackgroundList( le_acl_manager_facade.BackgroundRequestMsg(peer_address=remote_addr)) def remove_from_background_list(self, remote_addr): self.le_acl_manager.RemoveFromBackgroundList( le_acl_manager_facade.BackgroundRequestMsg(peer_address=remote_addr)) def complete_connection(self, event_stream): connection_complete = HciCaptures.LeConnectionCompleteCapture() assertThat(event_stream).emits(connection_complete) Loading
system/blueberry/tests/gd/hci/le_acl_manager_test.py +40 −0 Original line number Diff line number Diff line Loading @@ -403,6 +403,46 @@ class LeAclManagerTest(gd_base_test.GdBaseTestClass): is_direct=True) self.dut_le_acl_manager.complete_outgoing_connection(token) def test_background_connection_list(self): self.set_privacy_policy_static() # Start background connection token_background = self.dut_le_acl_manager.initiate_connection( remote_addr=common.BluetoothAddressWithType( address=common.BluetoothAddress(address=bytes(self.cert_random_address, 'utf8')), type=int(hci_packets.AddressType.RANDOM_DEVICE_ADDRESS)), is_direct=False) # Cert Advertises advertising_handle = 0 py_hci_adv = self.cert_hci.create_advertisement(advertising_handle, self.cert_random_address, hci_packets.LegacyAdvertisingProperties.ADV_IND, 155, 165) py_hci_adv.set_data(b'Im_A_Cert') py_hci_adv.set_scan_response(b'Im_A_C') py_hci_adv.start() # Check background connection complete self.dut_le_acl_manager.complete_outgoing_connection(token_background) msg = self.dut_le_acl_manager.is_on_background_list( remote_addr=common.BluetoothAddressWithType( address=common.BluetoothAddress(address=bytes(self.cert_random_address, 'utf8')), type=int(hci_packets.AddressType.RANDOM_DEVICE_ADDRESS))) assertThat(msg.is_on_background_list).isEqualTo(True) self.dut_le_acl_manager.remove_from_background_list( remote_addr=common.BluetoothAddressWithType( address=common.BluetoothAddress(address=bytes(self.cert_random_address, 'utf8')), type=int(hci_packets.AddressType.RANDOM_DEVICE_ADDRESS))) msg = self.dut_le_acl_manager.is_on_background_list( remote_addr=common.BluetoothAddressWithType( address=common.BluetoothAddress(address=bytes(self.cert_random_address, 'utf8')), type=int(hci_packets.AddressType.RANDOM_DEVICE_ADDRESS))) assertThat(msg.is_on_background_list).isEqualTo(False) if __name__ == '__main__': test_runner.main()
system/gd/hci/acl_manager.cc +15 −0 Original line number Diff line number Diff line Loading @@ -160,6 +160,10 @@ void AclManager::CreateLeConnection(AddressWithType address_with_type, bool is_d CallOn(pimpl_->le_impl_, &le_impl::create_le_connection, address_with_type, true, is_direct); } void AclManager::IsOnBackgroundList(AddressWithType address_with_type, std::promise<bool> promise) { CallOn(pimpl_->le_impl_, &le_impl::is_on_background_connection_list, address_with_type, std::move(promise)); } void AclManager::SetLeSuggestedDefaultDataParameters(uint16_t octets, uint16_t time) { CallOn(pimpl_->le_impl_, &le_impl::set_le_suggested_default_data_parameters, octets, time); } Loading Loading @@ -210,6 +214,17 @@ void AclManager::CancelLeConnect(AddressWithType address_with_type) { CallOn(pimpl_->le_impl_, &le_impl::cancel_connect, address_with_type); } void AclManager::RemoveFromBackgroundList(AddressWithType address_with_type) { CallOn(pimpl_->le_impl_, &le_impl::remove_device_from_background_connection_list, address_with_type); } void AclManager::CancelLeConnectAndRemoveFromBackgroundList(AddressWithType address_with_type) { CallOn( pimpl_->le_impl_, &le_impl::cancel_connection_and_remove_device_from_background_connection_list, address_with_type); } void AclManager::AddDeviceToFilterAcceptList(AddressWithType address_with_type) { CallOn(pimpl_->le_impl_, &le_impl::add_device_to_connect_list, address_with_type); } Loading
system/gd/hci/acl_manager.h +4 −0 Original line number Diff line number Diff line Loading @@ -103,8 +103,12 @@ public: // Generates OnConnectFail with error code "terminated by local host 0x16" if cancelled, or OnConnectSuccess if not // successfully cancelled and already connected virtual void CancelConnect(Address address); virtual void RemoveFromBackgroundList(AddressWithType address_with_type); virtual void IsOnBackgroundList(AddressWithType address_with_type, std::promise<bool> promise); virtual void CancelLeConnect(AddressWithType address_with_type); virtual void CancelLeConnectAndRemoveFromBackgroundList(AddressWithType address_with_type); virtual void AddDeviceToFilterAcceptList(AddressWithType address_with_type); virtual void RemoveDeviceFromFilterAcceptList(AddressWithType address_with_type); virtual void ClearFilterAcceptList(); Loading