From c833b66427e15f8a4ba1fc4631010a93b1ea5f1d Mon Sep 17 00:00:00 2001 From: Jakub Pawlowski Date: Mon, 23 Sep 2019 22:27:12 +0200 Subject: [PATCH] Fix BLE device reconnections Some BLE devices would advertise using both their RPA and Public address. If such device was discovered using it's RPA, but later it's overriden by Public address, we might have trouble reconnecting to it due to the logic in whitelist handling code. This logic should prefer Identity Address over any other type of address. Test: Bond with BLE device, modify the AddrType in bt_config.conf file, try to reconnect. We should use Address Type stored in LE_KEY_PID Bug: 141186673 Bug: 139825901 Bug: 140847046 Change-Id: If27032f53dd655983ee5d5bc6d07b55d7458078f --- stack/btm/btm_ble_bgconn.cc | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/stack/btm/btm_ble_bgconn.cc b/stack/btm/btm_ble_bgconn.cc index 3af63f496..209f49fe5 100644 --- a/stack/btm/btm_ble_bgconn.cc +++ b/stack/btm/btm_ble_bgconn.cc @@ -178,8 +178,7 @@ bool BTM_BackgroundConnectAddressKnown(const RawAddress& address) { return true; // bonded device with identity address known - if (p_dev_rec->ble.identity_addr != address && - !p_dev_rec->ble.identity_addr.IsEmpty()) { + if (!p_dev_rec->ble.identity_addr.IsEmpty()) { return true; } @@ -205,8 +204,7 @@ bool btm_add_dev_to_controller(bool to_add, const RawAddress& bd_addr) { if (p_dev_rec != NULL && p_dev_rec->device_type & BT_DEVICE_TYPE_BLE) { if (to_add) { - if (p_dev_rec->ble.identity_addr != bd_addr && - !p_dev_rec->ble.identity_addr.IsEmpty()) { + if (!p_dev_rec->ble.identity_addr.IsEmpty()) { background_connection_add(p_dev_rec->ble.identity_addr_type, p_dev_rec->ble.identity_addr); } else { @@ -220,8 +218,7 @@ bool btm_add_dev_to_controller(bool to_add, const RawAddress& bd_addr) { p_dev_rec->ble.in_controller_list |= BTM_WHITE_LIST_BIT; } else { - if (!p_dev_rec->ble.identity_addr.IsEmpty() && - p_dev_rec->ble.identity_addr != bd_addr) { + if (!p_dev_rec->ble.identity_addr.IsEmpty()) { background_connection_remove(p_dev_rec->ble.identity_addr); } else { background_connection_remove(bd_addr); -- 2.11.0