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

Commit 82f3cb08 authored by Chris Manton's avatar Chris Manton
Browse files

Use API ignore_auto_connect_after_disconnect

Bug: 180781174
Test: cert
Tag: #refactor

Change-Id: Ia032262c0e136ea7bc7b7bd7a2737b7d67439804
parent 882a65b4
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -482,10 +482,12 @@ cc_test {
        "packages/modules/Bluetooth/system/utils/include",
    ],
    srcs: [
        "test/gatt/gatt_sr_test.cc",
        "gatt/gatt_utils.cc",
        "test/common/mock_acl.cc",
        "test/common/mock_eatt.cc",
        "test/common/mock_gatt_layer.cc",
        "test/common/mock_main_shim.cc",
        "test/gatt/gatt_sr_test.cc",
    ],
    shared_libs: [
        "libcutils",
@@ -560,9 +562,11 @@ cc_test {
        "gatt/gatt_db.cc",
        "gatt/gatt_sr_hash.cc",
        "gatt/gatt_utils.cc",
        "test/gatt/mock_gatt_utils_ref.cc",
        "test/common/mock_acl.cc",
        "test/common/mock_eatt.cc",
        "test/common/mock_gatt_layer.cc",
        "test/common/mock_main_shim.cc",
        "test/gatt/mock_gatt_utils_ref.cc",
        "test/stack_gatt_sr_hash_test.cc",
    ],
    shared_libs: [
+7 −0
Original line number Diff line number Diff line
@@ -534,6 +534,12 @@ bool BTM_AcceptlistAdd(const RawAddress& address) {
  }

  if (bluetooth::shim::is_gd_acl_enabled()) {
    if (acl_check_and_clear_ignore_auto_connect_after_disconnect(address)) {
      LOG_WARN(
          "Unexpectedly found device address already in ignore auto connect "
          "device:%s",
          PRIVATE_ADDRESS(address));
    }
    return bluetooth::shim::ACL_AcceptLeConnectionFrom(
        convert_to_address_with_type(address, btm_find_dev(address)));
  }
@@ -582,6 +588,7 @@ void BTM_AcceptlistClear() {
  }

  if (bluetooth::shim::is_gd_acl_enabled()) {
    acl_clear_all_ignore_auto_connect_after_disconnect();
    bluetooth::shim::ACL_IgnoreAllLeConnections();
    return;
  }
+11 −4
Original line number Diff line number Diff line
@@ -2497,11 +2497,18 @@ void btm_ble_update_mode_operation(uint8_t link_role, const RawAddress* bd_addr,
  if (bd_addr != nullptr) {
    const RawAddress bda(*bd_addr);
    if (bluetooth::shim::is_gd_acl_enabled()) {
      if (acl_check_and_clear_ignore_auto_connect_after_disconnect(bda)) {
        LOG_DEBUG(
            "Local disconnect initiated so skipping re-add to acceptlist "
            "device:%s",
            PRIVATE_ADDRESS(bda));
      } else {
        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);
    }
+5 −0
Original line number Diff line number Diff line
@@ -26,10 +26,12 @@

#include "bt_target.h"  // Must be first to define build configuration

#include "main/shim/shim.h"
#include "stack/btm/btm_sec.h"
#include "stack/eatt/eatt.h"
#include "stack/gatt/connection_manager.h"
#include "stack/gatt/gatt_int.h"
#include "stack/include/acl_api.h"
#include "stack/include/l2cdefs.h"
#include "stack/include/sdp_api.h"
#include "types/bluetooth/uuid.h"
@@ -1611,5 +1613,8 @@ uint8_t* gatt_dbg_op_name(uint8_t op_code) {
bool gatt_auto_connect_dev_remove(tGATT_IF gatt_if, const RawAddress& bd_addr) {
  tGATT_TCB* p_tcb = gatt_find_tcb_by_addr(bd_addr, BT_TRANSPORT_LE);
  if (p_tcb) gatt_update_app_use_link_flag(gatt_if, p_tcb, false, false);
  if (bluetooth::shim::is_gd_acl_enabled()) {
    acl_add_to_ignore_auto_connect_after_disconnect(bd_addr);
  }
  return connection_manager::background_connect_remove(gatt_if, bd_addr);
}
+3 −0
Original line number Diff line number Diff line
@@ -28,6 +28,9 @@

#define MAX_UINT16 ((uint16_t)0xffff)

bool MOCK_bluetooth_shim_is_gd_acl_enabled_ = true;
std::map<std::string, int> mock_function_count_map;

tGATT_CB gatt_cb;

namespace {
Loading