OSDN Git Service

Pull up ACL_AcceptLeConnectionFrom stack
authorChris Manton <cmanton@google.com>
Fri, 26 Feb 2021 20:43:12 +0000 (12:43 -0800)
committerChris Manton <cmanton@google.com>
Tue, 2 Mar 2021 05:23:24 +0000 (05:23 +0000)
A more appropriate stack level for this conditional

Bug: 180781174
Test: cert
Tag: #refactor

Change-Id: I3dd5ad22d96a5ac785b63ce28351631c0b1a9537

stack/btm/btm_ble_bgconn.cc
stack/btm/btm_ble_gap.cc

index dede216..a323005 100644 (file)
@@ -194,7 +194,7 @@ static int background_connections_count() {
   return count;
 }
 
-static const tBLE_BD_ADDR convert_to_address_with_type(
+const tBLE_BD_ADDR convert_to_address_with_type(
     const RawAddress& bd_addr, const tBTM_SEC_DEV_REC* p_dev_rec) {
   if (p_dev_rec == nullptr || !p_dev_rec->is_device_type_has_ble()) {
     return {
@@ -424,15 +424,6 @@ void btm_update_scanner_filter_policy(tBTM_BLE_SFP scan_policy) {
  *
  ******************************************************************************/
 void btm_ble_bgconn_cancel_if_disconnected(const RawAddress& bd_addr) {
-  if (bluetooth::shim::is_gd_acl_enabled()) {
-    if (!bluetooth::shim::ACL_AcceptLeConnectionFrom(
-            convert_to_address_with_type(bd_addr, btm_find_dev(bd_addr)))) {
-      LOG_ERROR("Unable to add to acceptlist as it is full:%s",
-                PRIVATE_ADDRESS(bd_addr));
-    }
-    return;
-  }
-
   if (!btm_cb.ble_ctr_cb.is_connection_state_connecting()) return;
 
   auto map_it = background_connections.find(bd_addr);
index a838a6d..5d77adc 100644 (file)
@@ -63,6 +63,8 @@ extern bool btm_identity_addr_to_random_pseudo(RawAddress* bd_addr,
 extern void btm_ble_batchscan_init(void);
 extern void btm_ble_adv_filter_init(void);
 extern void btm_clear_all_pending_le_entry(void);
+extern const tBLE_BD_ADDR convert_to_address_with_type(
+    const RawAddress& bd_addr, const tBTM_SEC_DEV_REC* p_dev_rec);
 
 #define BTM_EXT_BLE_RMT_NAME_TIMEOUT_MS (30 * 1000)
 #define MIN_ADV_LENGTH 2
@@ -2493,7 +2495,16 @@ void btm_ble_update_mode_operation(uint8_t link_role, const RawAddress* bd_addr,
   /* in case of disconnected, we must cancel bgconn and restart
      in order to add back device to acceptlist in order to reconnect */
   if (bd_addr != nullptr) {
-    btm_ble_bgconn_cancel_if_disconnected(*bd_addr);
+    const RawAddress bda(*bd_addr);
+    if (bluetooth::shim::is_gd_acl_enabled()) {
+      if (!bluetooth::shim::ACL_AcceptLeConnectionFrom(
+              convert_to_address_with_type(bda, btm_find_dev(bda)))) {
+        LOG_ERROR("Unable to add to acceptlist as it is full:%s",
+                  PRIVATE_ADDRESS(bda));
+      }
+    } else {
+      btm_ble_bgconn_cancel_if_disconnected(bda);
+    }
   }
 
   /* when no connection is attempted, and controller is not rejecting last