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

Commit d933cd2a authored by Hansong Zhang's avatar Hansong Zhang
Browse files

Simplify get role API

Just use BTM_GetRole()

Test: cert/run
Tag: #gd-refactor
Bug: 141555841
Change-Id: Ic90c23afe6512ee45acefdc9d04fca47ad5c550b
parent db43ac6d
Loading
Loading
Loading
Loading
+0 −27
Original line number Diff line number Diff line
@@ -124,7 +124,6 @@ inline bool IsEprAvailable(const tACL_CONN& p_acl) {
         controller_get_interface()->supports_encryption_pause();
}

static bool acl_is_role_central(const RawAddress& bda, tBT_TRANSPORT transport);
static void btm_acl_chk_peer_pkt_type_support(tACL_CONN* p,
                                              uint16_t* p_pkt_type);
static void btm_process_remote_ext_features(tACL_CONN* p_acl_cb,
@@ -2324,23 +2323,6 @@ void btm_acl_chk_peer_pkt_type_support(tACL_CONN* p, uint16_t* p_pkt_type) {
  }
}

bool acl_is_role_central(const RawAddress& bda, tBT_TRANSPORT transport) {
  tACL_CONN* p = internal_.btm_bda_to_acl(bda, BT_TRANSPORT_BR_EDR);
  if (p == nullptr) {
    LOG_WARN("Unable to find active acl");
    return false;
  }
  return (p->link_role == HCI_ROLE_CENTRAL);
}

bool acl_br_edr_is_role_central(const RawAddress& bda) {
  return acl_is_role_central(bda, BT_TRANSPORT_BR_EDR);
}

bool acl_ble_is_role_central(const RawAddress& bda) {
  return acl_is_role_central(bda, BT_TRANSPORT_LE);
}

bool BTM_BLE_IS_RESOLVE_BDA(const RawAddress& x) {
  return ((x.address)[0] & BLE_RESOLVE_ADDR_MASK) == BLE_RESOLVE_ADDR_MSB;
}
@@ -2592,15 +2574,6 @@ bool BTM_ReadRemoteConnectionAddr(const RawAddress& pseudo_addr,
  return st;
}

uint8_t acl_link_role(const RawAddress& bd_addr, tBT_TRANSPORT transport) {
  tACL_CONN* p_acl = internal_.btm_bda_to_acl(bd_addr, transport);
  if (p_acl == nullptr) {
    LOG_WARN("Unable to find active acl");
    return HCI_ROLE_UNKNOWN;
  }
  return p_acl->link_role;
}

uint8_t acl_link_role_from_handle(uint16_t handle) {
  tACL_CONN* p_acl = internal_.acl_get_connection_from_handle(handle);
  if (p_acl == nullptr) {
+6 −3
Original line number Diff line number Diff line
@@ -3107,7 +3107,9 @@ void btm_sec_auth_complete(uint16_t handle, tHCI_STATUS status) {
        BTM_TRACE_DEBUG(
            "link encrypted afer dedic bonding can use SMP_BR_CHNL");

        if (acl_br_edr_is_role_central(p_dev_rec->bd_addr)) {
        uint8_t role = HCI_ROLE_UNKNOWN;
        BTM_GetRole(p_dev_rec->bd_addr, &role);
        if (role == HCI_ROLE_CENTRAL) {
          // Encryption is required to start SM over BR/EDR
          // indicate that this is encryption after authentication
          BTM_SetEncryption(p_dev_rec->bd_addr, BT_TRANSPORT_BR_EDR, NULL, NULL,
@@ -3233,9 +3235,10 @@ void btm_sec_encrypt_change(uint16_t handle, tHCI_STATUS status,
      BTM_TRACE_DEBUG("%s: BR key is temporary, skip derivation of LE LTK",
                      __func__);
    }
    uint8_t role = HCI_ROLE_UNKNOWN;
    BTM_GetRole(p_dev_rec->bd_addr, &role);
    if (p_dev_rec->new_encryption_key_is_p256) {
      if (btm_sec_use_smp_br_chnl(p_dev_rec) &&
          acl_br_edr_is_role_central(p_dev_rec->bd_addr) &&
      if (btm_sec_use_smp_br_chnl(p_dev_rec) && role == HCI_ROLE_CENTRAL &&
          /* if LE key is not known, do deriving */
          (!(p_dev_rec->sec_flags & BTM_SEC_LE_LINK_KEY_KNOWN) ||
           /* or BR key is higher security than existing LE keys */
+1 −1
Original line number Diff line number Diff line
@@ -595,7 +595,7 @@ struct eatt_impl {
  void connect(const RawAddress& bd_addr) {
    eatt_device* eatt_dev = find_device_by_address(bd_addr);

    uint8_t role = acl_link_role(bd_addr, BT_TRANSPORT_LE);
    uint8_t role = L2CA_GetBleConnRole(bd_addr);
    if (role == HCI_ROLE_UNKNOWN) {
      LOG(ERROR) << __func__ << "Could not get device role" << bd_addr;
      return;
+0 −4
Original line number Diff line number Diff line
@@ -214,9 +214,6 @@ void btm_set_packet_types_from_address(const RawAddress& bda,
                                       tBT_TRANSPORT transport,
                                       uint16_t pkt_types);

bool acl_br_edr_is_role_central(const RawAddress& bda);
bool acl_ble_is_role_central(const RawAddress& bda);

#define BLE_RESOLVE_ADDR_MASK 0xc0
#define BLE_RESOLVE_ADDR_MSB 0x40

@@ -279,7 +276,6 @@ void btm_ble_refresh_local_resolvable_private_addr(

void btm_cont_rswitch_from_handle(uint16_t hci_handle);

uint8_t acl_link_role(const RawAddress& remote_bda, tBT_TRANSPORT transport);
uint8_t acl_link_role_from_handle(uint16_t handle);

tBT_TRANSPORT acl_get_transport_from_handle(uint16_t handle);
+5 −1
Original line number Diff line number Diff line
@@ -70,6 +70,10 @@ void L2CA_DeregisterLECoc(uint16_t psm) {
  return l2cap_interface->DeregisterLECoc(psm);
}

uint8_t L2CA_GetBleConnRole(const RawAddress& bd_addr) {
  return l2cap_interface->GetBleConnRole(bd_addr);
}

std::vector<uint16_t> L2CA_ConnectCreditBasedReq(uint16_t psm,
                                const RawAddress& bd_addr,
                                tL2CAP_LE_CFG_INFO* p_cfg) {
Loading