Loading packages/SettingsLib/aconfig/settingslib.aconfig +10 −0 Original line number Diff line number Diff line Loading @@ -7,3 +7,13 @@ flag { bug: "314812750" } flag { name: "enable_cached_bluetooth_device_dedup" namespace: "bluetooth" description: "Enable dedup in CachedBluetoothDevice" bug: "319197962" metadata { purpose: PURPOSE_BUGFIX } } packages/SettingsLib/src/com/android/settingslib/bluetooth/BluetoothEventManager.java +6 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.settingslib.bluetooth; import static com.android.settingslib.flags.Flags.enableCachedBluetoothDeviceDedup; import android.bluetooth.BluetoothA2dp; import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothCsipSetCoordinator; Loading Loading @@ -377,6 +379,10 @@ public class BluetoothEventManager { cachedDevice = mDeviceManager.addDevice(device); } if (enableCachedBluetoothDeviceDedup() && bondState == BluetoothDevice.BOND_BONDED) { mDeviceManager.removeDuplicateInstanceForIdentityAddress(device); } for (BluetoothCallback callback : mCallbacks) { callback.onDeviceBondStateChanged(cachedDevice, bondState); } Loading packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDeviceManager.java +14 −0 Original line number Diff line number Diff line Loading @@ -340,6 +340,20 @@ public class CachedBluetoothDeviceManager { } } synchronized void removeDuplicateInstanceForIdentityAddress(BluetoothDevice device) { String identityAddress = device.getIdentityAddress(); if (identityAddress == null || identityAddress.equals(device.getAddress())) { return; } mCachedDevices.removeIf(d -> { boolean shouldRemove = d.getDevice().getAddress().equals(identityAddress); if (shouldRemove) { Log.d(TAG, "Remove instance for identity address " + d); } return shouldRemove; }); } public synchronized boolean onProfileConnectionStateChangedIfProcessed(CachedBluetoothDevice cachedDevice, int state, int profileId) { if (profileId == BluetoothProfile.HEARING_AID) { Loading Loading
packages/SettingsLib/aconfig/settingslib.aconfig +10 −0 Original line number Diff line number Diff line Loading @@ -7,3 +7,13 @@ flag { bug: "314812750" } flag { name: "enable_cached_bluetooth_device_dedup" namespace: "bluetooth" description: "Enable dedup in CachedBluetoothDevice" bug: "319197962" metadata { purpose: PURPOSE_BUGFIX } }
packages/SettingsLib/src/com/android/settingslib/bluetooth/BluetoothEventManager.java +6 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.settingslib.bluetooth; import static com.android.settingslib.flags.Flags.enableCachedBluetoothDeviceDedup; import android.bluetooth.BluetoothA2dp; import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothCsipSetCoordinator; Loading Loading @@ -377,6 +379,10 @@ public class BluetoothEventManager { cachedDevice = mDeviceManager.addDevice(device); } if (enableCachedBluetoothDeviceDedup() && bondState == BluetoothDevice.BOND_BONDED) { mDeviceManager.removeDuplicateInstanceForIdentityAddress(device); } for (BluetoothCallback callback : mCallbacks) { callback.onDeviceBondStateChanged(cachedDevice, bondState); } Loading
packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDeviceManager.java +14 −0 Original line number Diff line number Diff line Loading @@ -340,6 +340,20 @@ public class CachedBluetoothDeviceManager { } } synchronized void removeDuplicateInstanceForIdentityAddress(BluetoothDevice device) { String identityAddress = device.getIdentityAddress(); if (identityAddress == null || identityAddress.equals(device.getAddress())) { return; } mCachedDevices.removeIf(d -> { boolean shouldRemove = d.getDevice().getAddress().equals(identityAddress); if (shouldRemove) { Log.d(TAG, "Remove instance for identity address " + d); } return shouldRemove; }); } public synchronized boolean onProfileConnectionStateChangedIfProcessed(CachedBluetoothDevice cachedDevice, int state, int profileId) { if (profileId == BluetoothProfile.HEARING_AID) { Loading