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

Commit b802b07c authored by Chris Manton's avatar Chris Manton
Browse files

Ensure address removed from filter accept list

A direct connection not present in the internal
connection manager data structure prevents the address
from being removed from the filter accept list.

Should that occur, go ahead and try to remove it anyway.

Bug: 237353773
Test: gd/cert/run
Tag: #refactor
BYPASS_LONG_LINES_REASON: Bluetooth likes 120 lines

Change-Id: I0253b9d66b12bbee3c9994298ba054b47cd035dd
parent 04878bed
Loading
Loading
Loading
Loading
+20 −3
Original line number Diff line number Diff line
@@ -1398,7 +1398,12 @@ void gatt_sr_update_prep_cnt(tGATT_TCB& tcb, tGATT_IF gatt_if, bool is_inc,
/** Cancel LE Create Connection request */
bool gatt_cancel_open(tGATT_IF gatt_if, const RawAddress& bda) {
  tGATT_TCB* p_tcb = gatt_find_tcb_by_addr(bda, BT_TRANSPORT_LE);
  if (!p_tcb) return true;
  if (!p_tcb) {
    LOG_WARN(
        "Unable to cancel open for unknown connection gatt_if:%hhu peer:%s",
        gatt_if, PRIVATE_ADDRESS(bda));
    return true;
  }

  if (gatt_get_ch_state(p_tcb) == GATT_CH_OPEN) {
    LOG(ERROR) << __func__ << ": link connected Too late to cancel";
@@ -1407,9 +1412,21 @@ bool gatt_cancel_open(tGATT_IF gatt_if, const RawAddress& bda) {

  gatt_update_app_use_link_flag(gatt_if, p_tcb, false, false);

  if (p_tcb->app_hold_link.empty()) gatt_disconnect(p_tcb);
  if (p_tcb->app_hold_link.empty()) {
    LOG_DEBUG(
        "Client reference count is zero disconnecting device gatt_if:%hhu "
        "peer:%s",
        gatt_if, PRIVATE_ADDRESS(bda));
    gatt_disconnect(p_tcb);
  }

  connection_manager::direct_connect_remove(gatt_if, bda);
  if (!connection_manager::direct_connect_remove(gatt_if, bda)) {
    BTM_AcceptlistRemove(bda);
    LOG_INFO(
        "GATT connection manager has no record but removed filter acceptlist "
        "gatt_if:%hhu peer:%s",
        gatt_if, PRIVATE_ADDRESS(bda));
  }
  return true;
}