Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e39603d9 authored by Jakub Pawlowski's avatar Jakub Pawlowski
Browse files

introduce gatt::connection_manager::get_apps_connecting_to

This is to clean up the interface, and don't expose internal control
structures.

Test: compilation
Change-Id: Id2afc5efb4c14be0b787cfabbe21fc1961381cb7
parent 1fee0e4d
Loading
Loading
Loading
Loading
+9 −6
Original line number Diff line number Diff line
@@ -20,12 +20,12 @@

#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;
};

@@ -48,10 +48,13 @@ std::list<tGATT_BG_CONN_DEV>::iterator gatt_find_bg_dev_it(

}  // 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
+2 −5
Original line number Diff line number Diff line
@@ -18,14 +18,12 @@

#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 {

@@ -39,7 +37,6 @@ 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 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
+3 −4
Original line number Diff line number Diff line
@@ -801,15 +801,14 @@ 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::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) {