Loading system/gd/hci/acl_manager/le_acl_connection.h +22 −2 Original line number Diff line number Diff line Loading @@ -83,8 +83,7 @@ class LeAclConnection : public AclConnection { // The peer address and type returned from the Connection Complete Event AddressWithType peer_address_with_type_; Address remote_initiator_address_; Address local_initiator_address_; // 5.2::7.7.65.10 Connection interval used on this connection. // Range: 0x0006 to 0x0C80 // Time = N * 1.25 ms Loading @@ -108,6 +107,27 @@ class LeAclConnection : public AclConnection { Address local_resolvable_private_address_ = Address::kEmpty; Address peer_resolvable_private_address_ = Address::kEmpty; virtual AddressWithType GetPeerAddress() const { return peer_address_with_type_; } // This function return actual peer address which was used for the connection over the air. virtual AddressWithType GetPeerOtaAddress() const { if (peer_resolvable_private_address_ == Address::kEmpty) { return GetPeerAddress(); } return AddressWithType(peer_resolvable_private_address_, AddressType::RANDOM_DEVICE_ADDRESS); } // This function return actual local address which was used for the connection over the air. virtual AddressWithType GetLocalOtaAddress() const { if (local_resolvable_private_address_ == Address::kEmpty) { return GetLocalAddress(); } return AddressWithType(local_resolvable_private_address_, AddressType::RANDOM_DEVICE_ADDRESS); } virtual void RegisterCallbacks(LeConnectionManagementCallbacks* callbacks, os::Handler* handler); virtual void Disconnect(DisconnectReason reason); Loading system/main/shim/acl.cc +39 −5 Original line number Diff line number Diff line Loading @@ -763,6 +763,18 @@ class LeShimAclConnection return connection_->GetLocalAddress(); } bluetooth::hci::AddressWithType GetLocalOtaAddressWithType() { return connection_->GetLocalOtaAddress(); } bluetooth::hci::AddressWithType GetPeerAddressWithType() { return connection_->GetPeerAddress(); } bluetooth::hci::AddressWithType GetPeerOtaAddressWithType() { return connection_->GetPeerOtaAddress(); } std::optional<uint8_t> GetAdvertisingSetConnectedTo() { return std::visit( [](auto&& data) { Loading Loading @@ -1529,13 +1541,35 @@ void shim::legacy::Acl::OnClassicLinkDisconnected(HciHandle handle, } bluetooth::hci::AddressWithType shim::legacy::Acl::GetConnectionLocalAddress( const RawAddress& remote_bda) { uint16_t handle, bool ota_address) { bluetooth::hci::AddressWithType address_with_type; auto remote_address = ToGdAddress(remote_bda); for (auto& [handle, connection] : pimpl_->handle_to_le_connection_map_) { if (connection->GetRemoteAddressWithType().GetAddress() == remote_address) { for (auto& [acl_handle, connection] : pimpl_->handle_to_le_connection_map_) { if (acl_handle != handle) { continue; } if (ota_address) { return connection->GetLocalOtaAddressWithType(); } return connection->GetLocalAddressWithType(); } LOG_WARN("address not found!"); return address_with_type; } bluetooth::hci::AddressWithType shim::legacy::Acl::GetConnectionPeerAddress( uint16_t handle, bool ota_address) { bluetooth::hci::AddressWithType address_with_type; for (auto& [acl_handle, connection] : pimpl_->handle_to_le_connection_map_) { if (acl_handle != handle) { continue; } if (ota_address) { return connection->GetPeerOtaAddressWithType(); } return connection->GetPeerAddressWithType(); } LOG_WARN("address not found!"); return address_with_type; Loading system/main/shim/acl.h +4 −2 Original line number Diff line number Diff line Loading @@ -69,8 +69,10 @@ class Acl : public hci::acl_manager::ConnectionCallbacks, std::unique_ptr<hci::acl_manager::LeAclConnection>) override; void OnLeConnectFail(hci::AddressWithType, hci::ErrorCode reason) override; void OnLeLinkDisconnected(uint16_t handle, hci::ErrorCode reason); bluetooth::hci::AddressWithType GetConnectionLocalAddress( const RawAddress& remote_bda); bluetooth::hci::AddressWithType GetConnectionLocalAddress(uint16_t handle, bool ota_address); bluetooth::hci::AddressWithType GetConnectionPeerAddress(uint16_t handle, bool ota_address); std::optional<uint8_t> GetAdvertisingSetConnectedTo( const RawAddress& remote_bda); Loading system/main/shim/acl_api.cc +19 −3 Original line number Diff line number Diff line Loading @@ -107,15 +107,31 @@ void bluetooth::shim::ACL_IgnoreAllLeConnections() { return Stack::GetInstance()->GetAcl()->ClearFilterAcceptList(); } void bluetooth::shim::ACL_ReadConnectionAddress(const RawAddress& pseudo_addr, void bluetooth::shim::ACL_ReadConnectionAddress(uint16_t handle, RawAddress& conn_addr, tBLE_ADDR_TYPE* p_addr_type) { tBLE_ADDR_TYPE* p_addr_type, bool ota_address) { auto local_address = Stack::GetInstance()->GetAcl()->GetConnectionLocalAddress(pseudo_addr); Stack::GetInstance()->GetAcl()->GetConnectionLocalAddress(handle, ota_address); conn_addr = ToRawAddress(local_address.GetAddress()); *p_addr_type = static_cast<tBLE_ADDR_TYPE>(local_address.GetAddressType()); } void bluetooth::shim::ACL_ReadPeerConnectionAddress(uint16_t handle, RawAddress& conn_addr, tBLE_ADDR_TYPE* p_addr_type, bool ota_address) { auto remote_ota_address = Stack::GetInstance()->GetAcl()->GetConnectionPeerAddress(handle, ota_address); conn_addr = ToRawAddress(remote_ota_address.GetAddress()); *p_addr_type = static_cast<tBLE_ADDR_TYPE>(remote_ota_address.GetAddressType()); } std::optional<uint8_t> bluetooth::shim::ACL_GetAdvertisingSetConnectedTo( const RawAddress& addr) { return Stack::GetInstance()->GetAcl()->GetAdvertisingSetConnectedTo(addr); Loading system/main/shim/acl_api.h +6 −3 Original line number Diff line number Diff line Loading @@ -40,9 +40,12 @@ void ACL_ConfigureLePrivacy(bool is_le_privacy_enabled); void ACL_Shutdown(); void ACL_IgnoreAllLeConnections(); void ACL_ReadConnectionAddress(const RawAddress& pseudo_addr, RawAddress& conn_addr, tBLE_ADDR_TYPE* p_addr_type); void ACL_ReadConnectionAddress(uint16_t handle, RawAddress& conn_addr, tBLE_ADDR_TYPE* p_addr_type, bool ota_address); void ACL_ReadPeerConnectionAddress(uint16_t handle, RawAddress& conn_addr, tBLE_ADDR_TYPE* p_addr_type, bool ota_address); std::optional<uint8_t> ACL_GetAdvertisingSetConnectedTo(const RawAddress& addr); Loading Loading
system/gd/hci/acl_manager/le_acl_connection.h +22 −2 Original line number Diff line number Diff line Loading @@ -83,8 +83,7 @@ class LeAclConnection : public AclConnection { // The peer address and type returned from the Connection Complete Event AddressWithType peer_address_with_type_; Address remote_initiator_address_; Address local_initiator_address_; // 5.2::7.7.65.10 Connection interval used on this connection. // Range: 0x0006 to 0x0C80 // Time = N * 1.25 ms Loading @@ -108,6 +107,27 @@ class LeAclConnection : public AclConnection { Address local_resolvable_private_address_ = Address::kEmpty; Address peer_resolvable_private_address_ = Address::kEmpty; virtual AddressWithType GetPeerAddress() const { return peer_address_with_type_; } // This function return actual peer address which was used for the connection over the air. virtual AddressWithType GetPeerOtaAddress() const { if (peer_resolvable_private_address_ == Address::kEmpty) { return GetPeerAddress(); } return AddressWithType(peer_resolvable_private_address_, AddressType::RANDOM_DEVICE_ADDRESS); } // This function return actual local address which was used for the connection over the air. virtual AddressWithType GetLocalOtaAddress() const { if (local_resolvable_private_address_ == Address::kEmpty) { return GetLocalAddress(); } return AddressWithType(local_resolvable_private_address_, AddressType::RANDOM_DEVICE_ADDRESS); } virtual void RegisterCallbacks(LeConnectionManagementCallbacks* callbacks, os::Handler* handler); virtual void Disconnect(DisconnectReason reason); Loading
system/main/shim/acl.cc +39 −5 Original line number Diff line number Diff line Loading @@ -763,6 +763,18 @@ class LeShimAclConnection return connection_->GetLocalAddress(); } bluetooth::hci::AddressWithType GetLocalOtaAddressWithType() { return connection_->GetLocalOtaAddress(); } bluetooth::hci::AddressWithType GetPeerAddressWithType() { return connection_->GetPeerAddress(); } bluetooth::hci::AddressWithType GetPeerOtaAddressWithType() { return connection_->GetPeerOtaAddress(); } std::optional<uint8_t> GetAdvertisingSetConnectedTo() { return std::visit( [](auto&& data) { Loading Loading @@ -1529,13 +1541,35 @@ void shim::legacy::Acl::OnClassicLinkDisconnected(HciHandle handle, } bluetooth::hci::AddressWithType shim::legacy::Acl::GetConnectionLocalAddress( const RawAddress& remote_bda) { uint16_t handle, bool ota_address) { bluetooth::hci::AddressWithType address_with_type; auto remote_address = ToGdAddress(remote_bda); for (auto& [handle, connection] : pimpl_->handle_to_le_connection_map_) { if (connection->GetRemoteAddressWithType().GetAddress() == remote_address) { for (auto& [acl_handle, connection] : pimpl_->handle_to_le_connection_map_) { if (acl_handle != handle) { continue; } if (ota_address) { return connection->GetLocalOtaAddressWithType(); } return connection->GetLocalAddressWithType(); } LOG_WARN("address not found!"); return address_with_type; } bluetooth::hci::AddressWithType shim::legacy::Acl::GetConnectionPeerAddress( uint16_t handle, bool ota_address) { bluetooth::hci::AddressWithType address_with_type; for (auto& [acl_handle, connection] : pimpl_->handle_to_le_connection_map_) { if (acl_handle != handle) { continue; } if (ota_address) { return connection->GetPeerOtaAddressWithType(); } return connection->GetPeerAddressWithType(); } LOG_WARN("address not found!"); return address_with_type; Loading
system/main/shim/acl.h +4 −2 Original line number Diff line number Diff line Loading @@ -69,8 +69,10 @@ class Acl : public hci::acl_manager::ConnectionCallbacks, std::unique_ptr<hci::acl_manager::LeAclConnection>) override; void OnLeConnectFail(hci::AddressWithType, hci::ErrorCode reason) override; void OnLeLinkDisconnected(uint16_t handle, hci::ErrorCode reason); bluetooth::hci::AddressWithType GetConnectionLocalAddress( const RawAddress& remote_bda); bluetooth::hci::AddressWithType GetConnectionLocalAddress(uint16_t handle, bool ota_address); bluetooth::hci::AddressWithType GetConnectionPeerAddress(uint16_t handle, bool ota_address); std::optional<uint8_t> GetAdvertisingSetConnectedTo( const RawAddress& remote_bda); Loading
system/main/shim/acl_api.cc +19 −3 Original line number Diff line number Diff line Loading @@ -107,15 +107,31 @@ void bluetooth::shim::ACL_IgnoreAllLeConnections() { return Stack::GetInstance()->GetAcl()->ClearFilterAcceptList(); } void bluetooth::shim::ACL_ReadConnectionAddress(const RawAddress& pseudo_addr, void bluetooth::shim::ACL_ReadConnectionAddress(uint16_t handle, RawAddress& conn_addr, tBLE_ADDR_TYPE* p_addr_type) { tBLE_ADDR_TYPE* p_addr_type, bool ota_address) { auto local_address = Stack::GetInstance()->GetAcl()->GetConnectionLocalAddress(pseudo_addr); Stack::GetInstance()->GetAcl()->GetConnectionLocalAddress(handle, ota_address); conn_addr = ToRawAddress(local_address.GetAddress()); *p_addr_type = static_cast<tBLE_ADDR_TYPE>(local_address.GetAddressType()); } void bluetooth::shim::ACL_ReadPeerConnectionAddress(uint16_t handle, RawAddress& conn_addr, tBLE_ADDR_TYPE* p_addr_type, bool ota_address) { auto remote_ota_address = Stack::GetInstance()->GetAcl()->GetConnectionPeerAddress(handle, ota_address); conn_addr = ToRawAddress(remote_ota_address.GetAddress()); *p_addr_type = static_cast<tBLE_ADDR_TYPE>(remote_ota_address.GetAddressType()); } std::optional<uint8_t> bluetooth::shim::ACL_GetAdvertisingSetConnectedTo( const RawAddress& addr) { return Stack::GetInstance()->GetAcl()->GetAdvertisingSetConnectedTo(addr); Loading
system/main/shim/acl_api.h +6 −3 Original line number Diff line number Diff line Loading @@ -40,9 +40,12 @@ void ACL_ConfigureLePrivacy(bool is_le_privacy_enabled); void ACL_Shutdown(); void ACL_IgnoreAllLeConnections(); void ACL_ReadConnectionAddress(const RawAddress& pseudo_addr, RawAddress& conn_addr, tBLE_ADDR_TYPE* p_addr_type); void ACL_ReadConnectionAddress(uint16_t handle, RawAddress& conn_addr, tBLE_ADDR_TYPE* p_addr_type, bool ota_address); void ACL_ReadPeerConnectionAddress(uint16_t handle, RawAddress& conn_addr, tBLE_ADDR_TYPE* p_addr_type, bool ota_address); std::optional<uint8_t> ACL_GetAdvertisingSetConnectedTo(const RawAddress& addr); Loading