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)
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();
#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;
/** 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
/** 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;
/** 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;
}
/** 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 */
/** 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
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
}
}
- gatt_deregister_bgdev_list(gatt_if);
+ gatt::connection_manager::on_app_deregistered(gatt_if);
memset(p_reg, 0, sizeof(tGATT_REG));
}
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";
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;
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) {
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);
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);
}