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

Commit 69ef8ad7 authored by Chris Manton's avatar Chris Manton
Browse files

Pull up ACL_AcceptLeConnectionFrom stack

A more appropriate stack level for this conditional

Bug: 180781174
Test: cert
Tag: #refactor

Change-Id: I3dd5ad22d96a5ac785b63ce28351631c0b1a9537
parent 8ee0d82f
Loading
Loading
Loading
Loading
+1 −10
Original line number Diff line number Diff line
@@ -194,7 +194,7 @@ static int background_connections_count() {
  return count;
}

static const tBLE_BD_ADDR convert_to_address_with_type(
const tBLE_BD_ADDR convert_to_address_with_type(
    const RawAddress& bd_addr, const tBTM_SEC_DEV_REC* p_dev_rec) {
  if (p_dev_rec == nullptr || !p_dev_rec->is_device_type_has_ble()) {
    return {
@@ -424,15 +424,6 @@ void btm_update_scanner_filter_policy(tBTM_BLE_SFP scan_policy) {
 *
 ******************************************************************************/
void btm_ble_bgconn_cancel_if_disconnected(const RawAddress& bd_addr) {
  if (bluetooth::shim::is_gd_acl_enabled()) {
    if (!bluetooth::shim::ACL_AcceptLeConnectionFrom(
            convert_to_address_with_type(bd_addr, btm_find_dev(bd_addr)))) {
      LOG_ERROR("Unable to add to acceptlist as it is full:%s",
                PRIVATE_ADDRESS(bd_addr));
    }
    return;
  }

  if (!btm_cb.ble_ctr_cb.is_connection_state_connecting()) return;

  auto map_it = background_connections.find(bd_addr);
+12 −1
Original line number Diff line number Diff line
@@ -63,6 +63,8 @@ extern bool btm_identity_addr_to_random_pseudo(RawAddress* bd_addr,
extern void btm_ble_batchscan_init(void);
extern void btm_ble_adv_filter_init(void);
extern void btm_clear_all_pending_le_entry(void);
extern const tBLE_BD_ADDR convert_to_address_with_type(
    const RawAddress& bd_addr, const tBTM_SEC_DEV_REC* p_dev_rec);

#define BTM_EXT_BLE_RMT_NAME_TIMEOUT_MS (30 * 1000)
#define MIN_ADV_LENGTH 2
@@ -2493,7 +2495,16 @@ void btm_ble_update_mode_operation(uint8_t link_role, const RawAddress* bd_addr,
  /* in case of disconnected, we must cancel bgconn and restart
     in order to add back device to acceptlist in order to reconnect */
  if (bd_addr != nullptr) {
    btm_ble_bgconn_cancel_if_disconnected(*bd_addr);
    const RawAddress bda(*bd_addr);
    if (bluetooth::shim::is_gd_acl_enabled()) {
      if (!bluetooth::shim::ACL_AcceptLeConnectionFrom(
              convert_to_address_with_type(bda, btm_find_dev(bda)))) {
        LOG_ERROR("Unable to add to acceptlist as it is full:%s",
                  PRIVATE_ADDRESS(bda));
      }
    } else {
      btm_ble_bgconn_cancel_if_disconnected(bda);
    }
  }

  /* when no connection is attempted, and controller is not rejecting last