Loading system/stack/btm/btm_dev.cc +7 −5 Original line number Original line Diff line number Diff line Loading @@ -186,17 +186,19 @@ bool BTM_SecDeleteDevice(const RawAddress& bd_addr) { BTM_AcceptlistRemove(p_dev_rec->bd_addr); BTM_AcceptlistRemove(p_dev_rec->bd_addr); } } const auto device_type = p_dev_rec->device_type; const auto bond_type = p_dev_rec->bond_type; /* Clear out any saved BLE keys */ /* Clear out any saved BLE keys */ btm_sec_clear_ble_keys(p_dev_rec); btm_sec_clear_ble_keys(p_dev_rec); wipe_secrets_and_remove(p_dev_rec); wipe_secrets_and_remove(p_dev_rec); /* Tell controller to get rid of the link key, if it has one stored */ /* Tell controller to get rid of the link key, if it has one stored */ BTM_DeleteStoredLinkKey(&bda, NULL); BTM_DeleteStoredLinkKey(&bda, NULL); LOG_INFO("%s %s complete", __func__, ADDRESS_TO_LOGGABLE_CSTR(bd_addr)); LOG_INFO("%s %s complete", __func__, ADDRESS_TO_LOGGABLE_CSTR(bd_addr)); BTM_LogHistory( BTM_LogHistory(kBtmLogTag, bd_addr, "Device removed", kBtmLogTag, bd_addr, "Device removed", base::StringPrintf("device_type:%s bond_type:%s", base::StringPrintf("device_type:%s bond_type:%s", DeviceTypeText(p_dev_rec->device_type).c_str(), DeviceTypeText(device_type).c_str(), bond_type_text(p_dev_rec->bond_type).c_str())); bond_type_text(bond_type).c_str())); } else { } else { LOG_WARN("%s Unable to delete link key for unknown device %s", __func__, LOG_WARN("%s Unable to delete link key for unknown device %s", __func__, ADDRESS_TO_LOGGABLE_CSTR(bd_addr)); ADDRESS_TO_LOGGABLE_CSTR(bd_addr)); Loading system/stack/test/btm/stack_btm_test.cc +19 −1 Original line number Original line Diff line number Diff line Loading @@ -44,8 +44,8 @@ #include "stack/include/sec_hci_link_interface.h" #include "stack/include/sec_hci_link_interface.h" #include "stack/l2cap/l2c_int.h" #include "stack/l2cap/l2c_int.h" #include "test/common/mock_functions.h" #include "test/common/mock_functions.h" #include "test/mock/mock_osi_list.h" #include "test/mock/mock_device_iot_config.h" #include "test/mock/mock_device_iot_config.h" #include "test/mock/mock_osi_list.h" #include "test/mock/mock_stack_hcic_hcicmds.h" #include "test/mock/mock_stack_hcic_hcicmds.h" #include "types/raw_address.h" #include "types/raw_address.h" Loading Loading @@ -438,3 +438,21 @@ TEST_F(StackBtmTest, bond_type_text) { std::numeric_limits<std::uint8_t>::max())) std::numeric_limits<std::uint8_t>::max())) .c_str()); .c_str()); } } TEST_F(StackBtmWithInitFreeTest, wipe_secrets_and_remove) { bluetooth::common::InitFlags::SetAllForTesting(); RawAddress bd_addr = RawAddress({0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6}); const uint16_t classic_handle = 0x1234; const uint16_t ble_handle = 0x9876; // Setup device tBTM_SEC_DEV_REC* device_record = btm_sec_allocate_dev_rec(); ASSERT_NE(nullptr, device_record); ASSERT_EQ(BTM_SEC_IN_USE, device_record->sec_flags); device_record->bd_addr = bd_addr; device_record->hci_handle = classic_handle; device_record->ble_hci_handle = ble_handle; wipe_secrets_and_remove(device_record); } Loading
system/stack/btm/btm_dev.cc +7 −5 Original line number Original line Diff line number Diff line Loading @@ -186,17 +186,19 @@ bool BTM_SecDeleteDevice(const RawAddress& bd_addr) { BTM_AcceptlistRemove(p_dev_rec->bd_addr); BTM_AcceptlistRemove(p_dev_rec->bd_addr); } } const auto device_type = p_dev_rec->device_type; const auto bond_type = p_dev_rec->bond_type; /* Clear out any saved BLE keys */ /* Clear out any saved BLE keys */ btm_sec_clear_ble_keys(p_dev_rec); btm_sec_clear_ble_keys(p_dev_rec); wipe_secrets_and_remove(p_dev_rec); wipe_secrets_and_remove(p_dev_rec); /* Tell controller to get rid of the link key, if it has one stored */ /* Tell controller to get rid of the link key, if it has one stored */ BTM_DeleteStoredLinkKey(&bda, NULL); BTM_DeleteStoredLinkKey(&bda, NULL); LOG_INFO("%s %s complete", __func__, ADDRESS_TO_LOGGABLE_CSTR(bd_addr)); LOG_INFO("%s %s complete", __func__, ADDRESS_TO_LOGGABLE_CSTR(bd_addr)); BTM_LogHistory( BTM_LogHistory(kBtmLogTag, bd_addr, "Device removed", kBtmLogTag, bd_addr, "Device removed", base::StringPrintf("device_type:%s bond_type:%s", base::StringPrintf("device_type:%s bond_type:%s", DeviceTypeText(p_dev_rec->device_type).c_str(), DeviceTypeText(device_type).c_str(), bond_type_text(p_dev_rec->bond_type).c_str())); bond_type_text(bond_type).c_str())); } else { } else { LOG_WARN("%s Unable to delete link key for unknown device %s", __func__, LOG_WARN("%s Unable to delete link key for unknown device %s", __func__, ADDRESS_TO_LOGGABLE_CSTR(bd_addr)); ADDRESS_TO_LOGGABLE_CSTR(bd_addr)); Loading
system/stack/test/btm/stack_btm_test.cc +19 −1 Original line number Original line Diff line number Diff line Loading @@ -44,8 +44,8 @@ #include "stack/include/sec_hci_link_interface.h" #include "stack/include/sec_hci_link_interface.h" #include "stack/l2cap/l2c_int.h" #include "stack/l2cap/l2c_int.h" #include "test/common/mock_functions.h" #include "test/common/mock_functions.h" #include "test/mock/mock_osi_list.h" #include "test/mock/mock_device_iot_config.h" #include "test/mock/mock_device_iot_config.h" #include "test/mock/mock_osi_list.h" #include "test/mock/mock_stack_hcic_hcicmds.h" #include "test/mock/mock_stack_hcic_hcicmds.h" #include "types/raw_address.h" #include "types/raw_address.h" Loading Loading @@ -438,3 +438,21 @@ TEST_F(StackBtmTest, bond_type_text) { std::numeric_limits<std::uint8_t>::max())) std::numeric_limits<std::uint8_t>::max())) .c_str()); .c_str()); } } TEST_F(StackBtmWithInitFreeTest, wipe_secrets_and_remove) { bluetooth::common::InitFlags::SetAllForTesting(); RawAddress bd_addr = RawAddress({0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6}); const uint16_t classic_handle = 0x1234; const uint16_t ble_handle = 0x9876; // Setup device tBTM_SEC_DEV_REC* device_record = btm_sec_allocate_dev_rec(); ASSERT_NE(nullptr, device_record); ASSERT_EQ(BTM_SEC_IN_USE, device_record->sec_flags); device_record->bd_addr = bd_addr; device_record->hci_handle = classic_handle; device_record->ble_hci_handle = ble_handle; wipe_secrets_and_remove(device_record); }