#include <base/logging.h>
#include <list>
-#include <unordered_set>
+#include <set>
#include "stack/btm/btm_ble_bgconn.h"
struct tGATT_BG_CONN_DEV {
- std::unordered_set<tGATT_IF> gatt_if;
+ std::set<tGATT_IF> gatt_if;
RawAddress remote_bda;
};
} // namespace
-/** Returns true if this is one of the background devices for the application,
- * false otherwise */
-bool gatt_is_bg_dev_for_app(tGATT_BG_CONN_DEV* p_dev, tGATT_IF gatt_if) {
- return p_dev->gatt_if.count(gatt_if);
+/** background connection device from the list. Returns pointer to the device
+ * record, or nullptr if not found */
+std::set<tGATT_IF> get_apps_connecting_to(const RawAddress& address) {
+ for (tGATT_BG_CONN_DEV& dev : bgconn_dev)
+ if (dev.remote_bda == address) return dev.gatt_if;
+
+ return std::set<tGATT_IF>();
}
/** background connection device from the list. Returns pointer to the device
#pragma once
-#include <unordered_set>
+#include <set>
#include "types/raw_address.h"
typedef uint8_t tGATT_IF;
-struct tGATT_BG_CONN_DEV;
-
namespace gatt {
namespace connection_manager {
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 tGATT_BG_CONN_DEV* gatt_find_bg_dev(const RawAddress& remote_bda);
+extern std::set<tGATT_IF> get_apps_connecting_to(const RawAddress& remote_bda);
} // namespace connection_manager
} // namespace gatt
tGATT_REG* p_reg;
uint16_t conn_id;
- tGATT_BG_CONN_DEV* p_bg_dev =
- gatt::connection_manager::gatt_find_bg_dev(p_tcb->peer_bda);
+ std::set<tGATT_IF> apps =
+ gatt::connection_manager::get_apps_connecting_to(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::connection_manager::gatt_is_bg_dev_for_app(
- p_bg_dev, p_reg->gatt_if))
+ if (apps.find(p_reg->gatt_if) != apps.end())
gatt_update_app_use_link_flag(p_reg->gatt_if, p_tcb, true, true);
if (p_reg->app_cb.p_conn_cb) {