OSDN Git Service

Add return condition to stack/l2cap/l2c_ble::l2cble_conn_comp
authorChris Manton <cmanton@google.com>
Fri, 9 Oct 2020 20:44:07 +0000 (13:44 -0700)
committerChris Manton <cmanton@google.com>
Mon, 12 Oct 2020 17:12:29 +0000 (17:12 +0000)
Eventually not pass control here

Bug: 170396407
Tag: #refactor
Test: act.py -tc BleCocTest
Test: ble paired 2 phones
Test: classic paired Bose SoundLink
Change-Id: Idda6b2ad34499ce1a7ad0e7770cb973a9b5d44ec

stack/include/l2cap_hci_link_interface.h
stack/l2cap/l2c_ble.cc

index 63290fe..e0c994a 100644 (file)
@@ -29,12 +29,12 @@ extern bool l2c_link_hci_disc_comp(uint16_t handle, uint8_t reason);
 extern void l2c_link_role_changed(const RawAddress* bd_addr, uint8_t new_role,
                                   uint8_t hci_status);
 
-extern void l2cble_conn_comp(uint16_t handle, uint8_t role,
+extern bool l2cble_conn_comp(uint16_t handle, uint8_t role,
                              const RawAddress& bda, tBLE_ADDR_TYPE type,
                              uint16_t conn_interval, uint16_t conn_latency,
                              uint16_t conn_timeout);
 
-extern void l2cble_conn_comp_from_address_with_type(
+extern bool l2cble_conn_comp_from_address_with_type(
     uint16_t handle, uint8_t role, const tBLE_BD_ADDR& address_with_type,
     uint16_t conn_interval, uint16_t conn_latency, uint16_t conn_timeout);
 
index 341561f..4b971f7 100644 (file)
@@ -266,7 +266,7 @@ void l2cble_notify_le_connection(const RawAddress& bda) {
 
 /** This function is called when an HCI Connection Complete event is received.
  */
-void l2cble_conn_comp(uint16_t handle, uint8_t role, const RawAddress& bda,
+bool l2cble_conn_comp(uint16_t handle, uint8_t role, const RawAddress& bda,
                       tBLE_ADDR_TYPE type, uint16_t conn_interval,
                       uint16_t conn_latency, uint16_t conn_timeout) {
   // role == HCI_ROLE_MASTER => scanner completed connection
@@ -281,19 +281,19 @@ void l2cble_conn_comp(uint16_t handle, uint8_t role, const RawAddress& bda,
     if (!p_lcb) {
       btm_sec_disconnect(handle, HCI_ERR_NO_CONNECTION);
       LOG_ERROR("Unable to allocate link resource for le acl connection");
-      return;
+      return false;
     } else {
       if (!l2cu_initialize_fixed_ccb(p_lcb, L2CAP_ATT_CID)) {
         btm_sec_disconnect(handle, HCI_ERR_NO_CONNECTION);
         LOG_ERROR("Unable to allocate channel resource for le acl connection");
-        return;
+        return false;
       }
     }
   } else if (role == HCI_ROLE_MASTER && p_lcb->link_state != LST_CONNECTING) {
     LOG_ERROR(
         "Received le acl connection as role master but not in connecting "
         "state");
-    return;
+    return false;
   }
 
   if (role == HCI_ROLE_MASTER) alarm_cancel(p_lcb->l2c_lcb_timer);
@@ -333,13 +333,15 @@ void l2cble_conn_comp(uint16_t handle, uint8_t role, const RawAddress& bda,
       l2cu_process_fixed_chnl_resp(p_lcb);
     }
   }
+  return true;
 }
 
-void l2cble_conn_comp_from_address_with_type(
+bool l2cble_conn_comp_from_address_with_type(
     uint16_t handle, uint8_t role, const tBLE_BD_ADDR& address_with_type,
     uint16_t conn_interval, uint16_t conn_latency, uint16_t conn_timeout) {
-  l2cble_conn_comp(handle, role, address_with_type.bda, address_with_type.type,
-                   conn_interval, conn_latency, conn_timeout);
+  return l2cble_conn_comp(handle, role, address_with_type.bda,
+                          address_with_type.type, conn_interval, conn_latency,
+                          conn_timeout);
 }
 
 /*******************************************************************************