OSDN Git Service

Refactor acl_refresh_remote_address
authorHansong Zhang <hsz@google.com>
Fri, 30 Oct 2020 04:06:32 +0000 (21:06 -0700)
committerHansong Zhang <hsz@google.com>
Thu, 5 Nov 2020 02:03:01 +0000 (18:03 -0800)
Bug: 159815595
Tag: #refactor
Test: compile & verify basic functions working
Change-Id: Ie44e348424d1e13ba7b01e02ac5f918e3cdefd68

stack/acl/btm_acl.cc
stack/btm/btm_ble_addr.cc
stack/include/acl_api.h

index cbeb55b..fcd69bf 100644 (file)
@@ -2316,7 +2316,8 @@ bool BTM_BLE_IS_RESOLVE_BDA(const RawAddress& x) {
   return ((x.address)[0] & BLE_RESOLVE_ADDR_MASK) == BLE_RESOLVE_ADDR_MSB;
 }
 
-bool acl_refresh_remote_address(const tBTM_SEC_DEV_REC* p_sec_rec,
+bool acl_refresh_remote_address(const RawAddress& identity_address,
+                                tBLE_ADDR_TYPE identity_address_type,
                                 const RawAddress& bda, tBLE_ADDR_TYPE rra_type,
                                 const RawAddress& rpa) {
   tACL_CONN* p_acl = internal_.btm_bda_to_acl(bda, BT_TRANSPORT_LE);
@@ -2328,9 +2329,8 @@ bool acl_refresh_remote_address(const tBTM_SEC_DEV_REC* p_sec_rec,
   if (rra_type == tBTM_SEC_BLE::BTM_BLE_ADDR_PSEUDO) {
     /* use identity address, resolvable_private_addr is empty */
     if (rpa.IsEmpty()) {
-      p_acl->active_remote_addr_type =
-          p_sec_rec->ble.identity_address_with_type.type;
-      p_acl->active_remote_addr = p_sec_rec->ble.identity_address_with_type.bda;
+      p_acl->active_remote_addr_type = identity_address_type;
+      p_acl->active_remote_addr = identity_address;
     } else {
       p_acl->active_remote_addr_type = BLE_ADDR_RANDOM;
       p_acl->active_remote_addr = rpa;
index 0330fe7..7575005 100644 (file)
@@ -325,11 +325,15 @@ void btm_ble_refresh_peer_resolvable_private_addr(
   }
 
   /* connection refresh remote address */
-  if (!acl_refresh_remote_address(p_sec_rec, p_sec_rec->bd_addr, rra_type,
-                                  rpa)) {
+  const auto& identity_address = p_sec_rec->ble.identity_address_with_type.bda;
+  auto identity_address_type = p_sec_rec->ble.identity_address_with_type.type;
+
+  if (!acl_refresh_remote_address(identity_address, identity_address_type,
+                                  p_sec_rec->bd_addr, rra_type, rpa)) {
     // Try looking up the pseudo random address
-    if (!acl_refresh_remote_address(p_sec_rec, p_sec_rec->ble.pseudo_addr,
-                                    rra_type, rpa)) {
+    if (!acl_refresh_remote_address(identity_address, identity_address_type,
+                                    p_sec_rec->ble.pseudo_addr, rra_type,
+                                    rpa)) {
       LOG_ERROR("%s Unknown device to refresh remote device", __func__);
     }
   }
index b3bd405..06d8388 100644 (file)
@@ -222,7 +222,8 @@ bool acl_ble_is_role_central(const RawAddress& bda);
 
 bool BTM_BLE_IS_RESOLVE_BDA(const RawAddress& x);
 
-bool acl_refresh_remote_address(const tBTM_SEC_DEV_REC* p_dev_rec,
+bool acl_refresh_remote_address(const RawAddress& identity_address,
+                                tBLE_ADDR_TYPE identity_address_type,
                                 const RawAddress& remote_bda, uint8_t rra_type,
                                 const RawAddress& rpa);