From 60f3de2f8ce4477fec6cf3d5527bc3f8fa2950ec Mon Sep 17 00:00:00 2001 From: Chris Manton Date: Wed, 28 Oct 2020 21:27:20 -0700 Subject: [PATCH] gd_acl: Use address_with_type within API Also: Remove extraneous add device to connect list Bug: 171568335 Tag: #refactor Test: compile & verify basic functions working Change-Id: Ifbb3d64c1091d9a6611807b3ec177fcacc6a23df --- main/shim/acl.cc | 1 - main/shim/acl_api.cc | 14 ++++++++------ main/shim/acl_api.h | 4 ++-- stack/acl/btm_acl.cc | 12 ++++++++++-- 4 files changed, 20 insertions(+), 11 deletions(-) diff --git a/main/shim/acl.cc b/main/shim/acl.cc index 196d8dab4..6e313c43c 100644 --- a/main/shim/acl.cc +++ b/main/shim/acl.cc @@ -477,7 +477,6 @@ void bluetooth::shim::legacy::Acl::CreateClassicConnection( void bluetooth::shim::legacy::Acl::CreateLeConnection( const bluetooth::hci::AddressWithType& address_with_type) { - GetAclManager()->AddDeviceToConnectList(address_with_type); GetAclManager()->CreateLeConnection(address_with_type); LOG_DEBUG("Started Le device to connection %s", address_with_type.ToString().c_str()); diff --git a/main/shim/acl_api.cc b/main/shim/acl_api.cc index ae9ca416d..cf085872e 100644 --- a/main/shim/acl_api.cc +++ b/main/shim/acl_api.cc @@ -28,14 +28,16 @@ void bluetooth::shim::ACL_CreateClassicConnection( Stack::GetInstance()->GetAcl()->CreateClassicConnection(address); } -void bluetooth::shim::ACL_CreateLeConnection(const RawAddress& raw_address) { - auto address_with_type = ToAddressWithType(raw_address, BLE_ADDR_RANDOM); - Stack::GetInstance()->GetAcl()->CreateLeConnection(address_with_type); +void bluetooth::shim::ACL_CreateLeConnection( + const tBLE_BD_ADDR& legacy_address_with_type) { + Stack::GetInstance()->GetAcl()->CreateLeConnection( + ToAddressWithTypeFromLegacy(legacy_address_with_type)); } -void bluetooth::shim::ACL_CancelLeConnection(const RawAddress& raw_address) { - auto address_with_type = ToAddressWithType(raw_address, BLE_ADDR_RANDOM); - Stack::GetInstance()->GetAcl()->CancelLeConnection(address_with_type); +void bluetooth::shim::ACL_CancelLeConnection( + const tBLE_BD_ADDR& legacy_address_with_type) { + Stack::GetInstance()->GetAcl()->CancelLeConnection( + ToAddressWithTypeFromLegacy(legacy_address_with_type)); } void bluetooth::shim::ACL_WriteData(uint16_t handle, const BT_HDR* p_buf) { diff --git a/main/shim/acl_api.h b/main/shim/acl_api.h index cbd54570f..dd2ad7853 100644 --- a/main/shim/acl_api.h +++ b/main/shim/acl_api.h @@ -23,9 +23,9 @@ namespace bluetooth { namespace shim { void ACL_CancelClassicConnection(const RawAddress& raw_address); -void ACL_CancelLeConnection(const RawAddress& raw_address); +void ACL_CancelLeConnection(const tBLE_BD_ADDR& legacy_address_with_type); void ACL_CreateClassicConnection(const RawAddress& raw_address); -void ACL_CreateLeConnection(const RawAddress& raw_address); +void ACL_CreateLeConnection(const tBLE_BD_ADDR& legacy_address_with_type); void ACL_WriteData(uint16_t handle, const BT_HDR* p_buf); } // namespace shim diff --git a/stack/acl/btm_acl.cc b/stack/acl/btm_acl.cc index 41f022614..5711b5b20 100644 --- a/stack/acl/btm_acl.cc +++ b/stack/acl/btm_acl.cc @@ -2951,7 +2951,11 @@ void acl_write_automatic_flush_timeout(const RawAddress& bd_addr, bool acl_create_le_connection_with_id(uint8_t id, const RawAddress& bd_addr) { if (bluetooth::shim::is_gd_acl_enabled()) { - bluetooth::shim::ACL_CreateLeConnection(bd_addr); + tBLE_BD_ADDR address_with_type{ + .bda = bd_addr, + .type = BLE_ADDR_RANDOM, + }; + bluetooth::shim::ACL_CreateLeConnection(address_with_type); return true; } return connection_manager::direct_connect_add(id, bd_addr); @@ -2963,7 +2967,11 @@ bool acl_create_le_connection(const RawAddress& bd_addr) { void acl_cancel_le_connection(const RawAddress& bd_addr) { if (bluetooth::shim::is_gd_acl_enabled()) { - return bluetooth::shim::ACL_CancelLeConnection(bd_addr); + tBLE_BD_ADDR address_with_type{ + .bda = bd_addr, + .type = BLE_ADDR_RANDOM, + }; + return bluetooth::shim::ACL_CancelLeConnection(address_with_type); } connection_manager::direct_connect_remove(CONN_MGR_ID_L2CAP, bd_addr); } -- 2.11.0