OSDN Git Service

Naming cleanup in stack/gatt/connection_manager.*
authorJakub Pawlowski <jpawlowski@google.com>
Fri, 9 Nov 2018 11:42:32 +0000 (12:42 +0100)
committerJakub Pawlowski <jpawlowski@google.com>
Fri, 9 Nov 2018 19:41:19 +0000 (20:41 +0100)
Test: compilation
Change-Id: Ic73632cb258515856b9ae5616ec47881b4b28c61

bta/dm/bta_dm_act.cc
stack/btm/btm_devctl.cc
stack/gatt/connection_manager.cc
stack/gatt/connection_manager.h
stack/gatt/gatt_api.cc
stack/gatt/gatt_main.cc
stack/gatt/gatt_utils.cc

index 9adf6c2..480e4a2 100644 (file)
@@ -478,7 +478,7 @@ void bta_dm_disable() {
   bta_dm_disable_search_and_disc();
   bta_dm_cb.disabling = true;
 
-  gatt_reset_bgdev_list(false);
+  gatt::connection_manager::reset(false);
 
   if (BTM_GetNumAclLinks() == 0) {
 #if (BTA_DISABLE_DELAY > 0)
index b7d6d26..4e0086e 100644 (file)
@@ -190,7 +190,7 @@ static void reset_complete(void* result) {
 
   btm_cb.ble_ctr_cb.conn_state = BLE_CONN_IDLE;
   btm_cb.ble_ctr_cb.bg_conn_type = BTM_BLE_CONN_NONE;
-  gatt_reset_bgdev_list(true);
+  gatt::connection_manager::reset(true);
 
   btm_pm_reset();
 
index 35d5b49..8197936 100644 (file)
 
 #include <base/logging.h>
 #include <list>
+#include <unordered_set>
 
 #include "stack/btm/btm_ble_bgconn.h"
 
+struct tGATT_BG_CONN_DEV {
+  std::unordered_set<tGATT_IF> gatt_if;
+  RawAddress remote_bda;
+};
+
+namespace gatt {
+namespace connection_manager {
+
 namespace {
 std::list<tGATT_BG_CONN_DEV> bgconn_dev;
 
@@ -58,7 +67,7 @@ tGATT_BG_CONN_DEV* gatt_find_bg_dev(const RawAddress& remote_bda) {
 
 /** Add a device from the background connection list.  Returns true if device
  * added to the list, or already in list, false otherwise */
-bool gatt_add_bg_dev_list(tGATT_IF gatt_if, const RawAddress& bd_addr) {
+bool background_connect_add(tGATT_IF gatt_if, const RawAddress& bd_addr) {
   tGATT_BG_CONN_DEV* p_dev = gatt_find_bg_dev(bd_addr);
   if (p_dev) {
     // device already in the whitelist, just add interested app to the list
@@ -81,7 +90,7 @@ bool gatt_add_bg_dev_list(tGATT_IF gatt_if, const RawAddress& bd_addr) {
 
 /** Removes all registrations for background connection for given device.
  * Returns true if anything was removed, false otherwise */
-uint8_t gatt_clear_bg_dev_for_addr(const RawAddress& bd_addr) {
+bool background_connect_remove_unconditional(const RawAddress& bd_addr) {
   auto dev_it = gatt_find_bg_dev_it(bd_addr);
   if (dev_it == bgconn_dev.end()) return false;
 
@@ -93,7 +102,7 @@ uint8_t gatt_clear_bg_dev_for_addr(const RawAddress& bd_addr) {
 /** Remove device from the background connection device list or listening to
  * advertising list.  Returns true if device was on the list and was succesfully
  * removed */
-bool gatt_remove_bg_dev_from_list(tGATT_IF gatt_if, const RawAddress& bd_addr) {
+bool background_connect_remove(tGATT_IF gatt_if, const RawAddress& bd_addr) {
   auto dev_it = gatt_find_bg_dev_it(bd_addr);
   if (dev_it == bgconn_dev.end()) return false;
 
@@ -108,7 +117,7 @@ bool gatt_remove_bg_dev_from_list(tGATT_IF gatt_if, const RawAddress& bd_addr) {
 }
 
 /** deregister all related back ground connetion device. */
-void gatt_deregister_bgdev_list(tGATT_IF gatt_if) {
+void on_app_deregistered(tGATT_IF gatt_if) {
   auto it = bgconn_dev.begin();
   auto end = bgconn_dev.end();
   /* update the BG conn device list */
@@ -126,7 +135,10 @@ void gatt_deregister_bgdev_list(tGATT_IF gatt_if) {
 
 /** 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 gatt_reset_bgdev_list(bool after_reset) {
+void reset(bool after_reset) {
   bgconn_dev.clear();
   if (!after_reset) BTM_WhiteListClear();
 }
+
+}  // namespace connection_manager
+}  // namespace gatt
\ No newline at end of file
index a91c560..a39a4de 100644 (file)
 
 typedef uint8_t tGATT_IF;
 
-struct tGATT_BG_CONN_DEV {
-  std::unordered_set<tGATT_IF> gatt_if;
-  RawAddress remote_bda;
-};
+struct tGATT_BG_CONN_DEV;
+
+namespace gatt {
+namespace connection_manager {
 
 /* for background connection */
-extern bool gatt_add_bg_dev_list(tGATT_IF gatt_if, const RawAddress& bd_addr);
-extern bool gatt_remove_bg_dev_from_list(tGATT_IF gatt_if,
-                                         const RawAddress& bd_addr);
+extern bool background_connect_add(tGATT_IF gatt_if, const RawAddress& bd_addr);
+extern bool background_connect_remove(tGATT_IF gatt_if,
+                                      const RawAddress& bd_addr);
+extern bool background_connect_remove_unconditional(const RawAddress& bd_addr);
+
+extern void reset(bool after_reset);
+
+extern void on_app_deregistered(tGATT_IF gatt_if);
+
 extern bool gatt_is_bg_dev_for_app(tGATT_BG_CONN_DEV* p_dev, tGATT_IF gatt_if);
-extern uint8_t gatt_clear_bg_dev_for_addr(const RawAddress& bd_addr);
 extern tGATT_BG_CONN_DEV* gatt_find_bg_dev(const RawAddress& remote_bda);
-extern void gatt_deregister_bgdev_list(tGATT_IF gatt_if);
+}  // namespace connection_manager
+}  // namespace gatt
index 0a8f280..852f801 100644 (file)
@@ -1031,7 +1031,7 @@ void GATT_Deregister(tGATT_IF gatt_if) {
     }
   }
 
-  gatt_deregister_bgdev_list(gatt_if);
+  gatt::connection_manager::on_app_deregistered(gatt_if);
 
   memset(p_reg, 0, sizeof(tGATT_REG));
 }
@@ -1176,7 +1176,8 @@ bool GATT_CancelConnect(tGATT_IF gatt_if, const RawAddress& bd_addr,
 
   if (gatt_if) return gatt_auto_connect_dev_remove(p_reg->gatt_if, bd_addr);
 
-  if (!gatt_clear_bg_dev_for_addr(bd_addr)) {
+  if (!gatt::connection_manager::background_connect_remove_unconditional(
+          bd_addr)) {
     LOG(ERROR)
         << __func__
         << ": no app associated with the bg device for unconditional removal";
index 68f610d..c7010ea 100644 (file)
@@ -102,7 +102,7 @@ void gatt_init(void) {
   VLOG(1) << __func__;
 
   gatt_cb = tGATT_CB();
-  gatt_reset_bgdev_list(true);
+  gatt::connection_manager::reset(true);
   memset(&fixed_reg, 0, sizeof(tL2CAP_FIXED_CHNL_REG));
 
   gatt_cb.def_mtu_size = GATT_DEF_BLE_MTU_SIZE;
@@ -801,13 +801,15 @@ static void gatt_send_conn_cback(tGATT_TCB* p_tcb) {
   tGATT_REG* p_reg;
   uint16_t conn_id;
 
-  tGATT_BG_CONN_DEV* p_bg_dev = gatt_find_bg_dev(p_tcb->peer_bda);
+  tGATT_BG_CONN_DEV* p_bg_dev =
+      gatt::connection_manager::gatt_find_bg_dev(p_tcb->peer_bda);
 
   /* notifying all applications for the connection up event */
   for (i = 0, p_reg = gatt_cb.cl_rcb; i < GATT_MAX_APPS; i++, p_reg++) {
     if (!p_reg->in_use) continue;
 
-    if (p_bg_dev && gatt_is_bg_dev_for_app(p_bg_dev, p_reg->gatt_if))
+    if (p_bg_dev && gatt::connection_manager::gatt_is_bg_dev_for_app(
+                        p_bg_dev, p_reg->gatt_if))
       gatt_update_app_use_link_flag(p_reg->gatt_if, p_tcb, true, true);
 
     if (p_reg->app_cb.p_conn_cb) {
index 3dbd842..246dea9 100644 (file)
@@ -1308,7 +1308,7 @@ bool gatt_auto_connect_dev_add(tGATT_IF gatt_if, const RawAddress& bd_addr) {
   VLOG(1) << __func__;
 
   tGATT_TCB* p_tcb = gatt_find_tcb_by_addr(bd_addr, BT_TRANSPORT_LE);
-  bool ret = gatt_add_bg_dev_list(gatt_if, bd_addr);
+  bool ret = gatt::connection_manager::background_connect_add(gatt_if, bd_addr);
   if (ret && p_tcb != NULL) {
     /* if a connected device, update the link holding number */
     gatt_update_app_use_link_flag(gatt_if, p_tcb, true, true);
@@ -1320,5 +1320,5 @@ bool gatt_auto_connect_dev_add(tGATT_IF gatt_if, const RawAddress& bd_addr) {
 bool gatt_auto_connect_dev_remove(tGATT_IF gatt_if, const RawAddress& bd_addr) {
   tGATT_TCB* p_tcb = gatt_find_tcb_by_addr(bd_addr, BT_TRANSPORT_LE);
   if (p_tcb) gatt_update_app_use_link_flag(gatt_if, p_tcb, false, false);
-  return gatt_remove_bg_dev_from_list(gatt_if, bd_addr);
+  return gatt::connection_manager::background_connect_remove(gatt_if, bd_addr);
 }