OSDN Git Service

gd_acl: Use address_with_type within API
authorChris Manton <cmanton@google.com>
Thu, 29 Oct 2020 04:27:20 +0000 (21:27 -0700)
committerChris Manton <cmanton@google.com>
Thu, 29 Oct 2020 17:21:44 +0000 (10:21 -0700)
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
main/shim/acl_api.cc
main/shim/acl_api.h
stack/acl/btm_acl.cc

index 196d8da..6e313c4 100644 (file)
@@ -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());
index ae9ca41..cf08587 100644 (file)
@@ -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) {
index cbd5457..dd2ad78 100644 (file)
@@ -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
index 41f0226..5711b5b 100644 (file)
@@ -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);
 }