diff options
author | 2024-06-04 15:34:55 +0000 | |
---|---|---|
committer | 2024-06-04 15:34:55 +0000 | |
commit | f423f0f63acde53ceb60ba661d4fa9149dfba6a6 (patch) | |
tree | b64c2999affb3447b81975827b49a847fb66f998 | |
parent | 64fd9c43cfbd6636a94d6257c929bfe05a791d64 (diff) | |
parent | 547e652e32d5437cb7562503b536a7fa9b646588 (diff) |
Merge "Retain device properties while connected" into main
-rw-r--r-- | android/app/src/com/android/bluetooth/btservice/BondStateMachine.java | 2 | ||||
-rw-r--r-- | android/app/src/com/android/bluetooth/btservice/RemoteDevices.java | 34 |
2 files changed, 22 insertions, 14 deletions
diff --git a/android/app/src/com/android/bluetooth/btservice/BondStateMachine.java b/android/app/src/com/android/bluetooth/btservice/BondStateMachine.java index 10f3b19535..2d323923f7 100644 --- a/android/app/src/com/android/bluetooth/btservice/BondStateMachine.java +++ b/android/app/src/com/android/bluetooth/btservice/BondStateMachine.java @@ -523,7 +523,7 @@ final class BondStateMachine extends StateMachine { return; } - mRemoteDevices.onBondStateChange(device, oldState, newState); + mRemoteDevices.onBondStateChange(device, newState); if (devProp != null) { oldState = devProp.getBondState(); diff --git a/android/app/src/com/android/bluetooth/btservice/RemoteDevices.java b/android/app/src/com/android/bluetooth/btservice/RemoteDevices.java index 8f7e769538..d12a0789ac 100644 --- a/android/app/src/com/android/bluetooth/btservice/RemoteDevices.java +++ b/android/app/src/com/android/bluetooth/btservice/RemoteDevices.java @@ -1279,21 +1279,16 @@ public class RemoteDevices { } private void removeAddressMapping(String address) { - synchronized (mDevices) { - mDevices.remove(address); - mDeviceQueue.remove(address); // Remove from LRU cache - - // Remove from dual mode device mappings - mDualDevicesMap.values().remove(address); - mDualDevicesMap.remove(address); - } - } - - void onBondStateChange(BluetoothDevice device, int oldState, int newState) { - String address = device.getAddress(); - if (Flags.temporaryPairingDeviceProperties() && oldState != BluetoothDevice.BOND_BONDED) { + if (Flags.temporaryPairingDeviceProperties()) { DeviceProperties deviceProperties = mDevices.get(address); if (deviceProperties != null) { + String pseudoAddress = mDualDevicesMap.get(address); + if (pseudoAddress != null) { + deviceProperties = mDevices.get(pseudoAddress); + } + } + + if (deviceProperties != null) { int leConnectionHandle = deviceProperties.getConnectionHandle(BluetoothDevice.TRANSPORT_LE); int bredrConnectionHandle = @@ -1306,6 +1301,19 @@ public class RemoteDevices { } } + synchronized (mDevices) { + mDevices.remove(address); + mDeviceQueue.remove(address); // Remove from LRU cache + + // Remove from dual mode device mappings + mDualDevicesMap.values().remove(address); + mDualDevicesMap.remove(address); + } + } + + void onBondStateChange(BluetoothDevice device, int newState) { + String address = device.getAddress(); + if (Flags.removeAddressMapOnUnbond() && newState == BluetoothDevice.BOND_NONE) { removeAddressMapping(address); } |