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

Commit ed2401a9 authored by Hui Peng's avatar Hui Peng
Browse files

[Invisalign2] Encapsulate tBTM_SEC_CB::IsDeviceBonded

Bug: 301661850
Test: m com.android.btservices
Flag: EXEMPT, mechanical refactor
Change-Id: Iebcf4634c6a0cb4461ea7cff0bd599e36b0c749b
parent f9b68125
Loading
Loading
Loading
Loading
+2 −12
Original line number Diff line number Diff line
@@ -4895,23 +4895,13 @@ void btm_sec_clear_ble_keys(tBTM_SEC_DEV_REC* p_dev_rec) {
 * Function         btm_sec_is_a_bonded_dev
 *
 * Description       Is the specified device is a bonded device
 *                   (either on BR/EDR or LE)
 *
 * Returns          true - dev is bonded
 *
 ******************************************************************************/
bool btm_sec_is_a_bonded_dev(const RawAddress& bda) {
  tBTM_SEC_DEV_REC* p_dev_rec = btm_find_dev(bda);
  bool is_bonded = false;

  if (p_dev_rec &&
      ((p_dev_rec->sec_rec.ble_keys.key_type &&
        (p_dev_rec->sec_rec.sec_flags & BTM_SEC_LE_LINK_KEY_KNOWN)) ||
       (p_dev_rec->sec_rec.sec_flags & BTM_SEC_LINK_KEY_KNOWN))) {
    is_bonded = true;
  }
  LOG_DEBUG("Device record bonded check peer:%s is_bonded:%s",
            ADDRESS_TO_LOGGABLE_CSTR(bda), logbool(is_bonded).c_str());
  return is_bonded;
  return btm_sec_cb.IsDeviceBonded(bda);
}

/*******************************************************************************
+14 −0
Original line number Diff line number Diff line
@@ -189,6 +189,20 @@ bool tBTM_SEC_CB::IsLinkKeyKnown(const RawAddress bd_addr,
  return false;
}

bool tBTM_SEC_CB::IsDeviceBonded(const RawAddress bd_addr) {
  tBTM_SEC_DEV_REC* p_dev_rec = btm_find_dev(bd_addr);
  bool is_bonded = false;

  if (p_dev_rec && ((p_dev_rec->sec_rec.ble_keys.key_type &&
                     p_dev_rec->sec_rec.is_le_link_key_known()) ||
                    p_dev_rec->sec_rec.is_link_key_known())) {
    is_bonded = true;
  }
  LOG_DEBUG("Device record bonded check peer:%s is_bonded:%s",
            ADDRESS_TO_LOGGABLE_CSTR(bd_addr), logbool(is_bonded).c_str());
  return is_bonded;
}

#define BTM_NO_AVAIL_SEC_SERVICES ((uint16_t)0xffff)
bool tBTM_SEC_CB::AddService(bool is_originator, const char* p_name,
                             uint8_t service_id, uint16_t sec_level,
+2 −0
Original line number Diff line number Diff line
@@ -84,10 +84,12 @@ class tBTM_SEC_CB {

  tBTM_SEC_SERV_REC* find_first_serv_rec(bool is_originator, uint16_t psm);

  bool IsDeviceBonded(const RawAddress bd_addr);
  bool IsDeviceEncrypted(const RawAddress bd_addr, tBT_TRANSPORT transport);
  bool IsDeviceAuthenticated(const RawAddress bd_addr, tBT_TRANSPORT transport);
  bool IsLinkKeyAuthenticated(const RawAddress bd_addr,
                              tBT_TRANSPORT transport);

  bool IsLinkKeyKnown(const RawAddress bd_addr, tBT_TRANSPORT transport);

  tBTM_SEC_REC* getSecRec(const RawAddress bd_addr);