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

Commit 1fee0e4d authored by Jakub Pawlowski's avatar Jakub Pawlowski
Browse files

Naming cleanup in stack/gatt/connection_manager.*

Test: compilation
Change-Id: Ic73632cb258515856b9ae5616ec47881b4b28c61
parent 22d721e7
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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)
+1 −1
Original line number Diff line number Diff line
@@ -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();

+17 −5
Original line number Diff line number Diff line
@@ -20,9 +20,18 @@

#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
+15 −9
Original line number Diff line number Diff line
@@ -24,16 +24,22 @@

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,
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
+3 −2
Original line number Diff line number Diff line
@@ -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";
Loading