diff options
author | 2024-10-28 22:01:19 +0100 | |
---|---|---|
committer | 2025-02-14 18:40:20 +0100 | |
commit | e8a3d5b3fbf6b60ae7a396bdcba33e58112fc66e (patch) | |
tree | 7ef201261ed4d2408c82634500057fa8f9817e26 | |
parent | 47773b0fd4a95aa8defced6e7c8c754b953cb068 (diff) |
Pass device deletion from acccept list through connection manager
Currently, when device bond is removed, BTM_SecDeleteDevice requests
device removal from accept list directly from shim.
GATT would also remove directly from accept list i.e. when operation
timeout happens.
If an app was to request connection after it, connection_manager would
be unaware of accept list modification, think we still have device in
it, and prevent further connections.
Test: atest net_test_conn_multiplexing
Bug: 372202918
Flag: EXEMPT, covered under unittests
Change-Id: I1a12681281cf82fad1889ee2b292ff4e587cea40
-rw-r--r-- | system/stack/btm/btm_dev.cc | 4 | ||||
-rw-r--r-- | system/stack/connection_manager/connection_manager.cc | 10 | ||||
-rw-r--r-- | system/stack/gatt/gatt_main.cc | 9 |
3 files changed, 7 insertions, 16 deletions
diff --git a/system/stack/btm/btm_dev.cc b/system/stack/btm/btm_dev.cc index 6d81308238..2745041d82 100644 --- a/system/stack/btm/btm_dev.cc +++ b/system/stack/btm/btm_dev.cc @@ -35,8 +35,8 @@ #include "btm_int_types.h" #include "btm_sec_api.h" #include "btm_sec_cb.h" +#include "connection_manager/connection_manager.h" #include "internal_include/bt_target.h" -#include "main/shim/acl_api.h" #include "main/shim/dumpsys.h" #include "osi/include/allocator.h" #include "stack/btm/btm_sec.h" @@ -184,7 +184,7 @@ bool BTM_SecDeleteDevice(const RawAddress& bd_addr) { RawAddress bda = p_dev_rec->bd_addr; log::info("Remove device {} from filter accept list before delete record", bd_addr); - bluetooth::shim::ACL_IgnoreLeConnectionFrom(BTM_Sec_GetAddressWithType(bda)); + connection_manager::remove_unconditional(bd_addr); const auto device_type = p_dev_rec->device_type; const auto bond_type = p_dev_rec->sec_rec.bond_type; diff --git a/system/stack/connection_manager/connection_manager.cc b/system/stack/connection_manager/connection_manager.cc index ed223b92a8..42a25e1610 100644 --- a/system/stack/connection_manager/connection_manager.cc +++ b/system/stack/connection_manager/connection_manager.cc @@ -330,15 +330,13 @@ bool background_connect_add(uint8_t app_id, const RawAddress& address) { * Returns true if anything was removed, false otherwise */ bool remove_unconditional(const RawAddress& address) { log::debug("address={}", address); - auto it = bgconn_dev.find(address); - if (it == bgconn_dev.end()) { - log::warn("address {} is not found", address); - return false; + int count = bgconn_dev.erase(address); + if (count == 0) { + log::info("address {} is not found", address); } bluetooth::shim::ACL_IgnoreLeConnectionFrom(BTM_Sec_GetAddressWithType(address)); - bgconn_dev.erase(it); - return true; + return count > 0; } /** Remove device from the background connection device list or listening to diff --git a/system/stack/gatt/gatt_main.cc b/system/stack/gatt/gatt_main.cc index 7458cedc64..b89327f93d 100644 --- a/system/stack/gatt/gatt_main.cc +++ b/system/stack/gatt/gatt_main.cc @@ -277,14 +277,7 @@ bool gatt_disconnect(tGATT_TCB* p_tcb) { /* att_lcid == L2CAP_ATT_CID */ if (ch_state != GATT_CH_OPEN) { - if (!connection_manager::direct_connect_remove(CONN_MGR_ID_L2CAP, p_tcb->peer_bda)) { - bluetooth::shim::ACL_IgnoreLeConnectionFrom(BTM_Sec_GetAddressWithType(p_tcb->peer_bda)); - log::info( - "GATT connection manager has no record but removed filter " - "acceptlist gatt_if:{} peer:{}", - static_cast<uint8_t>(CONN_MGR_ID_L2CAP), p_tcb->peer_bda); - } - + connection_manager::remove_unconditional(p_tcb->peer_bda); gatt_cleanup_upon_disc(p_tcb->peer_bda, GATT_CONN_TERMINATE_LOCAL_HOST, p_tcb->transport); return true; } |