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

Commit 11cd0041 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge changes I1596a245,I2e62c052,I44fcc4d7

* changes:
  Provide more suitable API to rotate le address
  Remove incorrect and useless cached data type
  combine multiple BTM_BLE_IS_RESOLVE_BDA() functions
parents a0ba1162 37229509
Loading
Loading
Loading
Loading
+0 −7
Original line number Diff line number Diff line
@@ -86,13 +86,6 @@ extern const btgatt_callbacks_t* bt_gatt_callbacks;
    }                                                   \
  } while (0)

#define BLE_RESOLVE_ADDR_MSB                                                   \
  0x40                             /* bit7, bit6 is 01 to be resolvable random \
                                      */
#define BLE_RESOLVE_ADDR_MASK 0xc0 /* bit 6, and bit7 */
inline bool BTM_BLE_IS_RESOLVE_BDA(const RawAddress& x) {
  return ((x.address)[0] & BLE_RESOLVE_ADDR_MASK) == BLE_RESOLVE_ADDR_MSB;
}
namespace {

uint8_t rssi_request_client_if;
+31 −0
Original line number Diff line number Diff line
@@ -2406,3 +2406,34 @@ bool acl_is_role_master(const RawAddress& bda, tBT_TRANSPORT transport) {
  }
  return (p->link_role == HCI_ROLE_MASTER);
}

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,
                                const RawAddress& bda, tBT_TRANSPORT transport,
                                uint8_t rra_type, const RawAddress& rpa) {
  tACL_CONN* p_acl = btm_bda_to_acl(bda, transport);
  if (p_acl == nullptr) {
    return false;
  }

  if (rra_type == 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_addr_type;
      p_acl->active_remote_addr = p_sec_rec->ble.identity_addr;
    } else {
      p_acl->active_remote_addr_type = BLE_ADDR_RANDOM;
      p_acl->active_remote_addr = rpa;
    }
  } else {
    p_acl->active_remote_addr_type = rra_type;
    p_acl->active_remote_addr = rpa;
  }

  BTM_TRACE_DEBUG("%s active_remote_addr_type: %d ", __func__,
                  p_acl->active_remote_addr_type);
  return true;
}
+8 −25
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@

#include "btm_ble_int.h"
#include "stack/crypto_toolbox/crypto_toolbox.h"
#include "stack/include/acl_api.h"

/* This function generates Resolvable Private Address (RPA) from Identity
 * Resolving Key |irk| and |random|*/
@@ -314,9 +315,6 @@ void btm_ble_refresh_peer_resolvable_private_addr(const RawAddress& pseudo_bda,
                                                  const RawAddress& rpa,
                                                  uint8_t rra_type) {
#if (BLE_PRIVACY_SPT == TRUE)
  uint8_t rra_dummy = false;
  if (rpa.IsEmpty()) rra_dummy = true;

  /* update security record here, in adv event or connection complete process */
  tBTM_SEC_DEV_REC* p_sec_rec = btm_find_dev(pseudo_bda);
  if (p_sec_rec != NULL) {
@@ -325,7 +323,7 @@ void btm_ble_refresh_peer_resolvable_private_addr(const RawAddress& pseudo_bda,
    /* unknown, if dummy address, set to static */
    if (rra_type == BTM_BLE_ADDR_PSEUDO)
      p_sec_rec->ble.active_addr_type =
          rra_dummy ? BTM_BLE_ADDR_STATIC : BTM_BLE_ADDR_RRA;
          rpa.IsEmpty() ? BTM_BLE_ADDR_STATIC : BTM_BLE_ADDR_RRA;
    else
      p_sec_rec->ble.active_addr_type = rra_type;
  } else {
@@ -337,28 +335,13 @@ void btm_ble_refresh_peer_resolvable_private_addr(const RawAddress& pseudo_bda,
                  p_sec_rec->ble.active_addr_type);

  /* connection refresh remote address */
  tACL_CONN* p_acl = btm_bda_to_acl(p_sec_rec->bd_addr, BT_TRANSPORT_LE);
  if (p_acl == NULL)
    p_acl = btm_bda_to_acl(p_sec_rec->ble.pseudo_addr, BT_TRANSPORT_LE);

  if (p_acl != NULL) {
    if (rra_type == BTM_BLE_ADDR_PSEUDO) {
      /* use identity address, resolvable_private_addr is empty */
      if (rra_dummy) {
        p_acl->active_remote_addr_type = p_sec_rec->ble.identity_addr_type;
        p_acl->active_remote_addr = p_sec_rec->ble.identity_addr;
      } else {
        p_acl->active_remote_addr_type = BLE_ADDR_RANDOM;
        p_acl->active_remote_addr = rpa;
  if (!acl_refresh_remote_address(p_sec_rec, p_sec_rec->bd_addr,
                                  BT_TRANSPORT_LE, rra_type, rpa)) {
    // Try looking up the pseudo random address
    if (!acl_refresh_remote_address(p_sec_rec, p_sec_rec->ble.pseudo_addr,
                                    BT_TRANSPORT_LE, rra_type, rpa)) {
      BTM_TRACE_ERROR("%s Unknown device to refresh remote device", __func__);
    }
    } else {
      p_acl->active_remote_addr_type = rra_type;
      p_acl->active_remote_addr = rpa;
    }

    BTM_TRACE_DEBUG("p_acl->active_remote_addr_type: %d ",
                    p_acl->active_remote_addr_type);
    VLOG(1) << __func__ << " conn_addr: " << p_acl->active_remote_addr;
  }
#endif
}
+1 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@
#include "common/metrics.h"
#include "device/include/controller.h"
#include "stack/gatt/connection_manager.h"
#include "stack/include/acl_api.h"
#include "stack/include/hcimsgs.h"
#include "stack/include/l2cap_hci_link_interface.h"

+1 −0
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@

#include "main/shim/btm_api.h"
#include "main/shim/shim.h"
#include "stack/include/acl_api.h"

#define BTM_EXT_BLE_RMT_NAME_TIMEOUT_MS (30 * 1000)
#define MIN_ADV_LENGTH 2
Loading