OSDN Git Service

gd_acl: Resolve address after connection
authorChris Manton <cmanton@google.com>
Wed, 28 Oct 2020 15:53:29 +0000 (08:53 -0700)
committerChris Manton <cmanton@google.com>
Wed, 4 Nov 2020 18:30:05 +0000 (10:30 -0800)
Bug: 171568335
Tag: #refactor
Test: acts/bin/act.py -tp ~/Goog/tools/test/connectivity -tc BleCocTest
Test: atest --host bluetooth_test_gd

Change-Id: I0cabfa9cbe894d754269591c64292d6ed412d7a3

stack/acl/ble_acl.cc
stack/acl/btm_ble_connection_establishment.cc

index be2763b..0630e17 100644 (file)
@@ -29,6 +29,8 @@ void btm_ble_advertiser_notify_terminated_legacy(uint8_t status,
                                                  uint16_t connection_handle);
 void btm_ble_increment_link_topology_mask(uint8_t link_role);
 
+bool maybe_resolve_address(RawAddress* bda, tBLE_ADDR_TYPE* bda_type);
+
 static bool acl_ble_common_connection(const tBLE_BD_ADDR& address_with_type,
                                       uint16_t handle, uint8_t role,
                                       bool is_in_security_db,
@@ -106,15 +108,29 @@ void acl_ble_enhanced_connection_complete(
     btm_ble_advertiser_notify_terminated_legacy(HCI_SUCCESS, handle);
 }
 
+static bool maybe_resolve_received_address(
+    const tBLE_BD_ADDR& address_with_type,
+    tBLE_BD_ADDR* resolved_address_with_type) {
+  ASSERT(resolved_address_with_type != nullptr);
+
+  *resolved_address_with_type = address_with_type;
+  return maybe_resolve_address(&resolved_address_with_type->bda,
+                               &resolved_address_with_type->type);
+}
+
 void acl_ble_enhanced_connection_complete_from_shim(
     const tBLE_BD_ADDR& address_with_type, uint16_t handle, uint8_t role,
     uint16_t conn_interval, uint16_t conn_latency, uint16_t conn_timeout,
     const RawAddress& local_rpa, const RawAddress& peer_rpa,
     uint8_t peer_addr_type) {
-  bool match = false;  // TODO look up in database
-  acl_ble_enhanced_connection_complete(
-      address_with_type, handle, role, match, conn_interval, conn_latency,
-      conn_timeout, local_rpa, peer_rpa, peer_addr_type);
+  tBLE_BD_ADDR resolved_address_with_type;
+  const bool is_in_security_db = maybe_resolve_received_address(
+      address_with_type, &resolved_address_with_type);
+
+  acl_ble_enhanced_connection_complete(resolved_address_with_type, handle, role,
+                                       is_in_security_db, conn_interval,
+                                       conn_latency, conn_timeout, local_rpa,
+                                       peer_rpa, peer_addr_type);
 
   // The legacy stack continues the LE connection after the read remote version
   // complete has been received.
index 152ba1d..d65601e 100644 (file)
@@ -94,7 +94,7 @@ void btm_ble_create_ll_conn_complete(uint8_t status) {
   }
 }
 
-static bool maybe_resolve_address(RawAddress* bda, tBLE_ADDR_TYPE* bda_type) {
+bool maybe_resolve_address(RawAddress* bda, tBLE_ADDR_TYPE* bda_type) {
   bool is_in_security_db = false;
   tBLE_ADDR_TYPE peer_addr_type = *bda_type;
   bool addr_is_rpa =