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

Commit 41639dd1 authored by Hansong Zhang's avatar Hansong Zhang
Browse files

Improve shim Btm::GetAddressType

If legacy btm already knows its type, use it.

Tag: #gd-refactor
Bug: 141555841
Test: cert/run --host
Change-Id: Idfc28489f7d674dba7c724baccce0d4ee9170831
parent cd320f1b
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@
#include "main/shim/entry.h"
#include "main/shim/helpers.h"
#include "main/shim/shim.h"
#include "stack/btm/btm_dev.h"
#include "stack/btm/btm_int_types.h"
#include "types/bt_transport.h"
#include "types/raw_address.h"
@@ -776,6 +777,14 @@ uint16_t Btm::GetAclHandle(const RawAddress& remote_bda,
}

tBLE_ADDR_TYPE Btm::GetAddressType(const RawAddress& bd_addr) {
  tBTM_SEC_DEV_REC* p_dev_rec = btm_find_dev(bd_addr);
  if (p_dev_rec != NULL && p_dev_rec->device_type & BT_DEVICE_TYPE_BLE) {
    if (!p_dev_rec->ble.identity_address_with_type.bda.IsEmpty()) {
      return p_dev_rec->ble.identity_address_with_type.type;
    } else {
      return p_dev_rec->ble.ble_addr_type;
    }
  }
  if (le_address_type_cache_.count(bd_addr) == 0) {
    LOG(ERROR) << "Unknown bd_addr. Use public address";
    return BLE_ADDR_PUBLIC;