aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2021-12-11 13:06:59 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2021-12-11 13:06:59 +0000
commit2e8ec41b917ec27f51f78d2b54eb3dc69fa7c110 (patch)
treebb3c616f05405ca323082c8b50b4a363488c3cd0
parente9c2830951e8e213b6a2e74e587f375f2dca4c91 (diff)
parentfb39af61b7ef25981ab139b9340c2f42528bca19 (diff)
downloadbt-2e8ec41b917ec27f51f78d2b54eb3dc69fa7c110.tar.gz
Snap for 7992043 from fb39af61b7ef25981ab139b9340c2f42528bca19 to mainline-media-swcodec-release
Change-Id: Id591b969c892f89cda739bb90471d1ff65e254d1
-rw-r--r--bta/dm/bta_dm_act.cc11
-rw-r--r--stack/btm/btm_sec.cc2
-rw-r--r--test/mock/mock_stack_btm_ble.cc3
3 files changed, 15 insertions, 1 deletions
diff --git a/bta/dm/bta_dm_act.cc b/bta/dm/bta_dm_act.cc
index 8f9e26e52..cde0fa7fd 100644
--- a/bta/dm/bta_dm_act.cc
+++ b/bta/dm/bta_dm_act.cc
@@ -25,11 +25,14 @@
#define LOG_TAG "bt_bta_dm"
+#include <base/logging.h>
+
#include <cstdint>
#include "bta/dm/bta_dm_int.h"
#include "bta/gatt/bta_gattc_int.h"
#include "bta/include/bta_dm_ci.h"
+#include "btif/include/btif_config.h"
#include "btif/include/btif_dm.h"
#include "btif/include/btif_storage.h"
#include "btif/include/stack_manager.h"
@@ -42,6 +45,7 @@
#include "osi/include/fixed_queue.h"
#include "osi/include/log.h"
#include "osi/include/osi.h"
+#include "stack/btm/btm_ble_int.h"
#include "stack/btm/btm_sec.h"
#include "stack/btm/neighbor_inquiry.h"
#include "stack/gatt/connection_manager.h"
@@ -645,6 +649,13 @@ void bta_dm_remove_device(const RawAddress& bd_addr) {
if (!other_address_connected && !other_address.IsEmpty()) {
bta_dm_process_remove_device(other_address);
}
+
+ /* Check the length of the paired devices, and if 0 then reset IRK */
+ auto paired_devices = btif_config_get_paired_devices();
+ if (paired_devices.empty()) {
+ LOG_INFO("Last paired device removed, resetting IRK");
+ btm_ble_reset_id();
+ }
}
/*******************************************************************************
diff --git a/stack/btm/btm_sec.cc b/stack/btm/btm_sec.cc
index 50bd604b0..4b5d70d69 100644
--- a/stack/btm/btm_sec.cc
+++ b/stack/btm/btm_sec.cc
@@ -3385,7 +3385,6 @@ static void btm_sec_connect_after_reject_timeout(UNUSED_ATTR void* data) {
void btm_sec_connected(const RawAddress& bda, uint16_t handle,
tHCI_STATUS status, uint8_t enc_mode,
tHCI_ROLE assigned_role) {
- tBTM_SEC_DEV_REC* p_dev_rec = btm_find_dev(bda);
tBTM_STATUS res;
bool is_pairing_device = false;
bool addr_matched;
@@ -3393,6 +3392,7 @@ void btm_sec_connected(const RawAddress& bda, uint16_t handle,
btm_acl_resubmit_page();
+ tBTM_SEC_DEV_REC* p_dev_rec = btm_find_dev(bda);
if (!p_dev_rec) {
LOG_DEBUG(
"Connected to new device state:%s handle:0x%04x status:%s "
diff --git a/test/mock/mock_stack_btm_ble.cc b/test/mock/mock_stack_btm_ble.cc
index 835b1d230..b6e24ee12 100644
--- a/test/mock/mock_stack_btm_ble.cc
+++ b/test/mock/mock_stack_btm_ble.cc
@@ -254,3 +254,6 @@ void read_phy_cb(
uint8_t* data, uint16_t len) {
mock_function_count_map[__func__]++;
}
+void btm_ble_reset_id(void) {
+ mock_function_count_map[__func__]++;
+}