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

Commit ad76e928 authored by Jakub Pawlowski's avatar Jakub Pawlowski Committed by Jack He
Browse files

Fix gatt autoconnect

When BLE connection is complete, stack would inform connection_manager by invoking on_connection_complete. When shim was added, it started using remove_unconditional_from_shim.

The difference between those two methods is that on_connection_complete would keep information about background connections, and remove_unconditional_from_shim would just erase everything.

Information about background connection is used after connection is complete in gatt_send_conn_cback, to mark apps as using link, by invoking gatt_update_app_use_link_flag. When remove_unconditional_from_shim is used, this is not done, and app would not be able to reconnect.

Test: manual
Bug: 232258524
Ignore-AOSP-First: cherry-pick
Merged-In: Ie2fb572ac2e0d4124f603c4d5c440de69da82d0c
Change-Id: Ie2fb572ac2e0d4124f603c4d5c440de69da82d0c
parent 4891931f
Loading
Loading
Loading
Loading
+1 −6
Original line number Diff line number Diff line
@@ -125,12 +125,7 @@ void acl_ble_enhanced_connection_complete_from_shim(
    uint16_t conn_interval, uint16_t conn_latency, uint16_t conn_timeout,
    const RawAddress& local_rpa, const RawAddress& peer_rpa,
    tBLE_ADDR_TYPE peer_addr_type) {
  if (!connection_manager::remove_unconditional_from_shim(
          address_with_type.bda)) {
    LOG_WARN(
        "Unable to remove from legacy connection manager accept list addr:%s",
        PRIVATE_ADDRESS(address_with_type.bda));
  }
  connection_manager::on_connection_complete(address_with_type.bda);

  tBLE_BD_ADDR resolved_address_with_type;
  const bool is_in_security_db = maybe_resolve_received_address(
+0 −15
Original line number Diff line number Diff line
@@ -149,21 +149,6 @@ bool remove_unconditional(const RawAddress& address) {
  return true;
}

/** Removes the registrations for connection for given device.
 * but does not change the controller acceptlist.  Used for
 * shim purposes.
 * Returns true if anything was removed, false otherwise */
bool remove_unconditional_from_shim(const RawAddress& address) {
  LOG_DEBUG("address=%s", address.ToString().c_str());
  auto it = bgconn_dev.find(address);
  if (it == bgconn_dev.end()) {
    LOG_WARN("address %s is not found", address.ToString().c_str());
    return false;
  }
  bgconn_dev.erase(it);
  return true;
}

/** Remove device from the background connection device list or listening to
 * advertising list.  Returns true if device was on the list and was
 * successfully removed */
+0 −1
Original line number Diff line number Diff line
@@ -41,7 +41,6 @@ extern bool background_connect_add(tAPP_ID app_id, const RawAddress& address);
extern bool background_connect_remove(tAPP_ID app_id,
                                      const RawAddress& address);
extern bool remove_unconditional(const RawAddress& address);
extern bool remove_unconditional_from_shim(const RawAddress& address);

extern void reset(bool after_reset);

+0 −5
Original line number Diff line number Diff line
@@ -71,11 +71,6 @@ bool connection_manager::remove_unconditional(const RawAddress& address) {
  mock_function_count_map[__func__]++;
  return false;
}
bool connection_manager::remove_unconditional_from_shim(
    const RawAddress& address) {
  mock_function_count_map[__func__]++;
  return false;
}
std::set<tAPP_ID> connection_manager::get_apps_connecting_to(
    const RawAddress& address) {
  mock_function_count_map[__func__]++;