aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2022-01-04 14:24:53 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2022-01-04 14:24:53 +0000
commitb3c3673abb138f3ba63a42b8bdc56090a4df507a (patch)
tree8269c28bd85f30cc17767771215683359257d340
parentcab59198bedd0a71ed619ce9a6973803f28e0294 (diff)
parentd30055c8d941e1bf053e1d6658aae19734809c8c (diff)
downloadbt-b3c3673abb138f3ba63a42b8bdc56090a4df507a.tar.gz
Snap for 8041703 from d30055c8d941e1bf053e1d6658aae19734809c8c to mainline-sdkext-releaseandroid-mainline-12.0.0_r81
Change-Id: Id25843b36fe2704c7ccb6e4e8d465a05aac0197b
-rw-r--r--bta/dm/bta_dm_act.cc11
-rw-r--r--stack/btm/btm_sec.cc2
-rw-r--r--stack/gatt/gatt_cl.cc2
-rw-r--r--test/mock/mock_stack_btm_ble.cc3
4 files changed, 16 insertions, 2 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/stack/gatt/gatt_cl.cc b/stack/gatt/gatt_cl.cc
index 8c3567d7a..cb5c13877 100644
--- a/stack/gatt/gatt_cl.cc
+++ b/stack/gatt/gatt_cl.cc
@@ -745,7 +745,7 @@ void gatt_process_notification(tGATT_TCB& tcb, uint16_t cid, uint8_t op_code,
rem_len -= 4;
// Make sure we don't read past the remaining data even if the length says
// we can Also need to watch comparing the int16_t with the uint16_t
- value.len = std::min(rem_len, (int16_t)value.len);
+ value.len = std::min((uint16_t)rem_len, value.len);
STREAM_TO_ARRAY(value.value, p, value.len);
// Accounting
rem_len -= value.len;
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__]++;
+}