OSDN Git Service

Improve shim Btm::GetAddressType
authorHansong Zhang <hsz@google.com>
Wed, 18 Nov 2020 00:42:10 +0000 (16:42 -0800)
committerHansong Zhang <hsz@google.com>
Thu, 19 Nov 2020 19:22:07 +0000 (11:22 -0800)
If legacy btm already knows its type, use it.

Tag: #gd-refactor
Bug: 141555841
Test: cert/run --host
Change-Id: Idfc28489f7d674dba7c724baccce0d4ee9170831

main/shim/btm.cc

index d5bdc1f..5fc2ac4 100644 (file)
@@ -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;