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

Commit 01376b4c authored by Hansong Zhang's avatar Hansong Zhang
Browse files

Minor refactor on remote version comparison

Bug: 159815595
Tag: #refactor
Test: compile & verify basic functions working
Change-Id: I5641b7b7210b203892b13e196fc6f7f32cbbc5ca
parent 17504842
Loading
Loading
Loading
Loading
+0 −15
Original line number Diff line number Diff line
@@ -2295,21 +2295,6 @@ void btm_acl_chk_peer_pkt_type_support(tACL_CONN* p, uint16_t* p_pkt_type) {
  }
}

bool lmp_version_below(const RawAddress& bda, uint8_t version) {
  const tACL_CONN* acl = internal_.btm_bda_to_acl(bda, BT_TRANSPORT_LE);
  if (acl == nullptr) {
    LOG_INFO("Unable to get LMP version as no le acl exists to device");
    return false;
  }
  if (acl->lmp_version == 0) {
    LOG_INFO("Unable to get LMP version as value has not been set");
    return false;
  }
  LOG_DEBUG("Requested LMP version:%hhu acl_version:%hhu", version,
            acl->lmp_version);
  return acl->lmp_version < version;
}

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) {
+0 −2
Original line number Diff line number Diff line
@@ -214,8 +214,6 @@ void btm_set_packet_types_from_address(const RawAddress& bda,
                                       tBT_TRANSPORT transport,
                                       uint16_t pkt_types);

bool lmp_version_below(const RawAddress& bda, uint8_t version);

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

+6 −2
Original line number Diff line number Diff line
@@ -97,6 +97,7 @@ static void smp_update_key_mask(tSMP_CB* p_cb, uint8_t key_type, bool recv) {
void smp_send_app_cback(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) {
  tSMP_EVT_DATA cb_data;
  tSMP_STATUS callback_rc;
  uint8_t remote_lmp_version = 0;
  if (p_cb->p_callback && p_cb->cb_evt != 0) {
    switch (p_cb->cb_evt) {
      case SMP_IO_CAP_REQ_EVT:
@@ -165,9 +166,12 @@ void smp_send_app_cback(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) {
            p_cb->loc_auth_req |= SMP_SC_SUPPORT_BIT;
          }

          BTM_ReadRemoteVersion(p_cb->pairing_bda, &remote_lmp_version, nullptr,
                                nullptr);

          if (!p_cb->secure_connections_only_mode_required &&
              (!(p_cb->loc_auth_req & SMP_SC_SUPPORT_BIT) ||
               lmp_version_below(p_cb->pairing_bda, HCI_PROTO_VERSION_4_2) ||
               remote_lmp_version < HCI_PROTO_VERSION_4_2 ||
               interop_match_addr(INTEROP_DISABLE_LE_SECURE_CONNECTIONS,
                                  (const RawAddress*)&p_cb->pairing_bda))) {
            p_cb->loc_auth_req &= ~SMP_SC_SUPPORT_BIT;
@@ -176,7 +180,7 @@ void smp_send_app_cback(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) {
            p_cb->local_r_key &= ~SMP_SEC_KEY_TYPE_LK;
          }

          if (lmp_version_below(p_cb->pairing_bda, HCI_PROTO_VERSION_5_0)) {
          if (remote_lmp_version < HCI_PROTO_VERSION_5_0) {
            p_cb->loc_auth_req &= ~SMP_H7_SUPPORT_BIT;
          }