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

Commit 198ade1d authored by Hansong Zhang's avatar Hansong Zhang Committed by Automerger Merge Worker
Browse files

Move btm_ble_get_acl_remote_addr am: d5ca844c am: b5413a99

Original change: https://android-review.googlesource.com/c/platform/system/bt/+/1480895

Change-Id: Iff539d79254312065152a2e3ae254f6b4b81bbbf
parents b6e4e56d b5413a99
Loading
Loading
Loading
Loading
+0 −51
Original line number Diff line number Diff line
@@ -127,9 +127,6 @@ static void btm_process_remote_ext_features(tACL_CONN* p_acl_cb,
                                            uint8_t num_read_pages);
static bool acl_is_role_central(const RawAddress& bda, tBT_TRANSPORT transport);
static void btm_set_link_policy(tACL_CONN* conn, uint16_t policy);
static bool btm_ble_get_acl_remote_addr(uint16_t hci_handle,
                                        RawAddress& conn_addr,
                                        tBLE_ADDR_TYPE* p_addr_type);

/* 3 seconds timeout waiting for responses */
#define BTM_DEV_REPLY_TIMEOUT_MS (3 * 1000)
@@ -254,54 +251,6 @@ tACL_CONN* StackAclBtmAcl::acl_get_connection_from_handle(uint16_t hci_handle) {
  return &btm_cb.acl_cb_.acl_db[index];
}

/*******************************************************************************
 *
 * Function         btm_ble_get_acl_remote_addr
 *
 * Description      This function reads the active remote address used for the
 *                  connection.
 *
 * Returns          success return true, otherwise false.
 *
 ******************************************************************************/
static bool btm_ble_get_acl_remote_addr(uint16_t hci_handle,
                                        RawAddress& conn_addr,
                                        tBLE_ADDR_TYPE* p_addr_type) {
  tBTM_SEC_DEV_REC* p_dev_rec = btm_find_dev_by_handle(hci_handle);
  if (p_dev_rec == nullptr) {
    LOG_WARN("Unable to find security device record hci_handle:%hu",
             hci_handle);
    // TODO Release acl resource
    return false;
  }

  bool st = true;

  switch (p_dev_rec->ble.active_addr_type) {
    case tBTM_SEC_BLE::BTM_BLE_ADDR_PSEUDO:
      conn_addr = p_dev_rec->bd_addr;
      *p_addr_type = p_dev_rec->ble.ble_addr_type;
      break;

    case tBTM_SEC_BLE::BTM_BLE_ADDR_RRA:
      conn_addr = p_dev_rec->ble.cur_rand_addr;
      *p_addr_type = BLE_ADDR_RANDOM;
      break;

    case tBTM_SEC_BLE::BTM_BLE_ADDR_STATIC:
      conn_addr = p_dev_rec->ble.identity_address_with_type.bda;
      *p_addr_type = p_dev_rec->ble.identity_address_with_type.type;
      break;

    default:
      LOG_WARN("Unable to find record with active address type: %d",
               p_dev_rec->ble.active_addr_type);
      st = false;
      break;
  }
  return st;
}

void btm_acl_process_sca_cmpl_pkt(uint8_t len, uint8_t* data) {
  uint16_t handle;
  uint8_t acl_idx;
+47 −0
Original line number Diff line number Diff line
@@ -2073,6 +2073,53 @@ void btm_ble_set_random_address(const RawAddress& random_bda) {
  btm_ble_resume_bg_conn();
}

/*******************************************************************************
 *
 * Function         btm_ble_get_acl_remote_addr
 *
 * Description      This function reads the active remote address used for the
 *                  connection.
 *
 * Returns          success return true, otherwise false.
 *
 ******************************************************************************/
bool btm_ble_get_acl_remote_addr(uint16_t hci_handle, RawAddress& conn_addr,
                                 tBLE_ADDR_TYPE* p_addr_type) {
  tBTM_SEC_DEV_REC* p_dev_rec = btm_find_dev_by_handle(hci_handle);
  if (p_dev_rec == nullptr) {
    LOG_WARN("Unable to find security device record hci_handle:%hu",
             hci_handle);
    // TODO Release acl resource
    return false;
  }

  bool st = true;

  switch (p_dev_rec->ble.active_addr_type) {
    case tBTM_SEC_BLE::BTM_BLE_ADDR_PSEUDO:
      conn_addr = p_dev_rec->bd_addr;
      *p_addr_type = p_dev_rec->ble.ble_addr_type;
      break;

    case tBTM_SEC_BLE::BTM_BLE_ADDR_RRA:
      conn_addr = p_dev_rec->ble.cur_rand_addr;
      *p_addr_type = BLE_ADDR_RANDOM;
      break;

    case tBTM_SEC_BLE::BTM_BLE_ADDR_STATIC:
      conn_addr = p_dev_rec->ble.identity_address_with_type.bda;
      *p_addr_type = p_dev_rec->ble.identity_address_with_type.type;
      break;

    default:
      LOG_WARN("Unable to find record with active address type: %d",
               p_dev_rec->ble.active_addr_type);
      st = false;
      break;
  }
  return st;
}

#if BTM_BLE_CONFORMANCE_TESTING == TRUE
/*******************************************************************************
 *
+13 −0
Original line number Diff line number Diff line
@@ -597,4 +597,17 @@ extern void BTM_BleSetPhy(const RawAddress& bd_addr, uint8_t tx_phys,

extern void btm_ble_multi_adv_cleanup(void);

/*******************************************************************************
 *
 * Function         btm_ble_get_acl_remote_addr
 *
 * Description      This function reads the active remote address used for the
 *                  connection.
 *
 * Returns          success return true, otherwise false.
 *
 ******************************************************************************/
bool btm_ble_get_acl_remote_addr(uint16_t hci_handle, RawAddress& conn_addr,
                                 tBLE_ADDR_TYPE* p_addr_type);

#endif