Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6616bcbf authored by Hansong Zhang's avatar Hansong Zhang
Browse files

Refactor acl_refresh_remote_address

Bug: 159815595
Tag: #refactor
Test: compile & verify basic functions working
Change-Id: Ie44e348424d1e13ba7b01e02ac5f918e3cdefd68
parent 2394322a
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -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;
+8 −4
Original line number Diff line number Diff line
@@ -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__);
    }
  }
+2 −1
Original line number Diff line number Diff line
@@ -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);