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

Commit fb234fe2 authored by Hui Peng's avatar Hui Peng Committed by Gerrit Code Review
Browse files

Merge "[Invisalign2] Move maybe_resolve_address to btm_ble_addr" into main

parents 61533fdc 1526b74e
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@
#include "stack/btm/btm_sec.h"
#include "stack/gatt/connection_manager.h"
#include "stack/include/acl_api.h"
#include "stack/include/btm_ble_addr.h"
#include "stack/include/l2cap_hci_link_interface.h"
#include "types/raw_address.h"

@@ -34,8 +35,6 @@ void btm_ble_advertiser_notify_terminated_legacy(uint8_t status,
                                                 uint16_t connection_handle);
void btm_ble_increment_link_topology_mask(uint8_t link_role);

bool maybe_resolve_address(RawAddress* bda, tBLE_ADDR_TYPE* bda_type);

static bool acl_ble_common_connection(
    const tBLE_BD_ADDR& address_with_type, uint16_t handle, tHCI_ROLE role,
    bool is_in_security_db, uint16_t conn_interval, uint16_t conn_latency,
+0 −43
Original line number Diff line number Diff line
@@ -22,18 +22,13 @@

#include "stack/btm/btm_ble_int.h"
#include "stack/btm/btm_int_types.h"
#include "stack/include/acl_api.h"
#include "stack/include/ble_hci_link_interface.h"
#include "stack/include/btm_ble_addr.h"
#include "types/raw_address.h"

extern tBTM_CB btm_cb;

void btm_ble_advertiser_notify_terminated_legacy(uint8_t status,
                                                 uint16_t connection_handle);

bool btm_ble_init_pseudo_addr(tBTM_SEC_DEV_REC* p_dev_rec,
                              const RawAddress& new_pseudo_addr);
/** LE connection complete. */
void btm_ble_create_ll_conn_complete(tHCI_STATUS status) {
  if (status == HCI_SUCCESS) return;
@@ -51,41 +46,3 @@ void btm_ble_create_ll_conn_complete(tHCI_STATUS status) {
    btm_ble_update_mode_operation(HCI_ROLE_UNKNOWN, NULL, status);
  }
}

bool maybe_resolve_address(RawAddress* bda, tBLE_ADDR_TYPE* bda_type) {
  bool is_in_security_db = false;
  tBLE_ADDR_TYPE peer_addr_type = *bda_type;
  bool addr_is_rpa =
      (peer_addr_type == BLE_ADDR_RANDOM && BTM_BLE_IS_RESOLVE_BDA(*bda));

  /* We must translate whatever address we received into the "pseudo" address.
   * i.e. if we bonded with device that was using RPA for first connection,
   * "pseudo" address is equal to this RPA. If it later decides to use Public
   * address, or Random Static Address, we convert it into the "pseudo"
   * address here. */
  if (!addr_is_rpa || peer_addr_type & BLE_ADDR_TYPE_ID_BIT) {
    is_in_security_db = btm_identity_addr_to_random_pseudo(bda, bda_type, true);
  }

  /* possiblly receive connection complete with resolvable random while
     the device has been paired */
  if (!is_in_security_db && addr_is_rpa) {
    tBTM_SEC_DEV_REC* match_rec = btm_ble_resolve_random_addr(*bda);
    if (match_rec) {
      LOG(INFO) << __func__ << ": matched and resolved random address";
      is_in_security_db = true;
      match_rec->ble.active_addr_type = BTM_BLE_ADDR_RRA;
      match_rec->ble.cur_rand_addr = *bda;
      if (!btm_ble_init_pseudo_addr(match_rec, *bda)) {
        /* assign the original address to be the current report address */
        *bda = match_rec->ble.pseudo_addr;
        *bda_type = match_rec->ble.AddressType();
      } else {
        *bda = match_rec->bd_addr;
      }
    } else {
      LOG(INFO) << __func__ << ": unable to match and resolve random address";
    }
  }
  return is_in_security_db;
}
+38 −0
Original line number Diff line number Diff line
@@ -325,3 +325,41 @@ void btm_ble_refresh_peer_resolvable_private_addr(
    }
  }
}

bool maybe_resolve_address(RawAddress* bda, tBLE_ADDR_TYPE* bda_type) {
  bool is_in_security_db = false;
  tBLE_ADDR_TYPE peer_addr_type = *bda_type;
  bool addr_is_rpa =
      (peer_addr_type == BLE_ADDR_RANDOM && BTM_BLE_IS_RESOLVE_BDA(*bda));

  /* We must translate whatever address we received into the "pseudo" address.
   * i.e. if we bonded with device that was using RPA for first connection,
   * "pseudo" address is equal to this RPA. If it later decides to use Public
   * address, or Random Static Address, we convert it into the "pseudo"
   * address here. */
  if (!addr_is_rpa || peer_addr_type & BLE_ADDR_TYPE_ID_BIT) {
    is_in_security_db = btm_identity_addr_to_random_pseudo(bda, bda_type, true);
  }

  /* possiblly receive connection complete with resolvable random while
     the device has been paired */
  if (!is_in_security_db && addr_is_rpa) {
    tBTM_SEC_DEV_REC* match_rec = btm_ble_resolve_random_addr(*bda);
    if (match_rec) {
      LOG(INFO) << __func__ << ": matched and resolved random address";
      is_in_security_db = true;
      match_rec->ble.active_addr_type = BTM_BLE_ADDR_RRA;
      match_rec->ble.cur_rand_addr = *bda;
      if (!btm_ble_init_pseudo_addr(match_rec, *bda)) {
        /* assign the original address to be the current report address */
        *bda = match_rec->ble.pseudo_addr;
        *bda_type = match_rec->ble.AddressType();
      } else {
        *bda = match_rec->bd_addr;
      }
    } else {
      LOG(INFO) << __func__ << ": unable to match and resolve random address";
    }
  }
  return is_in_security_db;
}
+2 −0
Original line number Diff line number Diff line
@@ -48,3 +48,5 @@ bool btm_identity_addr_to_random_pseudo(RawAddress* bd_addr,

bool btm_identity_addr_to_random_pseudo_from_address_with_type(
    tBLE_BD_ADDR* address_with_type, bool refresh);

bool maybe_resolve_address(RawAddress* bda, tBLE_ADDR_TYPE* bda_type);
+0 −6
Original line number Diff line number Diff line
@@ -39,7 +39,6 @@ namespace stack_acl_btm_ble_connection_establishment {

// Function state capture and return values, if needed
struct btm_ble_create_ll_conn_complete btm_ble_create_ll_conn_complete;
struct maybe_resolve_address maybe_resolve_address;

}  // namespace stack_acl_btm_ble_connection_establishment
}  // namespace mock
@@ -50,10 +49,5 @@ void btm_ble_create_ll_conn_complete(tHCI_STATUS status) {
  test::mock::stack_acl_btm_ble_connection_establishment::
      btm_ble_create_ll_conn_complete(status);
}
bool maybe_resolve_address(RawAddress* bda, tBLE_ADDR_TYPE* bda_type) {
  inc_func_call_count(__func__);
  return test::mock::stack_acl_btm_ble_connection_establishment::
      maybe_resolve_address(bda, bda_type);
}

// END mockcify generation
Loading