OSDN Git Service

Break out stack/gatt::on_connection_complete
authorChris Manton <cmanton@google.com>
Thu, 17 Sep 2020 17:02:54 +0000 (10:02 -0700)
committerChris Manton <cmanton@google.com>
Fri, 18 Sep 2020 17:50:35 +0000 (10:50 -0700)
Towards readable code

Bug: 163134718
Tag: #refactor
Test: compile & verify basic functions working
Test: act.py -tc BleCocTest

Change-Id: I30da4870897ade37a671021edb7722b062150d65

stack/gatt/connection_manager.cc

index c8bc78b..fc42fcb 100644 (file)
@@ -29,6 +29,7 @@
 #include "internal_include/bt_trace.h"
 #include "main/shim/shim.h"
 #include "osi/include/alarm.h"
+#include "osi/include/log.h"
 #include "stack/btm/btm_ble_bgconn.h"
 #include "stack/include/l2c_api.h"
 
@@ -170,10 +171,9 @@ void on_app_deregistered(uint8_t app_id) {
   }
 }
 
-void on_connection_complete(const RawAddress& address) {
-  VLOG(2) << __func__;
+static void remove_all_clients_with_pending_connections(
+    const RawAddress& address) {
   auto it = bgconn_dev.find(address);
-
   while (it != bgconn_dev.end() && !it->second.doing_direct_conn.empty()) {
     uint8_t app_id = it->second.doing_direct_conn.begin()->first;
     direct_connect_remove(app_id, address);
@@ -181,6 +181,12 @@ void on_connection_complete(const RawAddress& address) {
   }
 }
 
+void on_connection_complete(const RawAddress& address) {
+  LOG_DEBUG("Le connection completed to device:%s", address.ToString().c_str());
+
+  remove_all_clients_with_pending_connections(address);
+}
+
 /** Reset bg device list. If called after controller reset, set |after_reset| to
  * true, as there is no need to wipe controller white list in this case. */
 void reset(bool after_reset) {