diff options
author | Matthew Xie <mattx@google.com> | 2014-09-08 22:30:18 -0700 |
---|---|---|
committer | Matthew Xie <mattx@google.com> | 2014-09-09 15:12:43 -0700 |
commit | b17031bed0ae81b5f342e0c0591b560f7c8849ed (patch) | |
tree | 4a88370cc92f99ce6a995fe505878078aed36c60 /src/com/android/settings/bluetooth | |
parent | 1f389c1996d754142c52c947105af4ec2db84f5c (diff) | |
download | packages_apps_Settings-b17031bed0ae81b5f342e0c0591b560f7c8849ed.zip packages_apps_Settings-b17031bed0ae81b5f342e0c0591b560f7c8849ed.tar.gz packages_apps_Settings-b17031bed0ae81b5f342e0c0591b560f7c8849ed.tar.bz2 |
Do not remove bonded devices from cached device list upon a device scan
Bug: 17405122
Change-Id: I3f5cc6ddc8f85d3b6223f9ff60e1d5eeb76c530a
Diffstat (limited to 'src/com/android/settings/bluetooth')
-rwxr-xr-x | src/com/android/settings/bluetooth/BluetoothSettings.java | 2 | ||||
-rwxr-xr-x | src/com/android/settings/bluetooth/CachedBluetoothDeviceManager.java | 13 |
2 files changed, 10 insertions, 5 deletions
diff --git a/src/com/android/settings/bluetooth/BluetoothSettings.java b/src/com/android/settings/bluetooth/BluetoothSettings.java index e29ccc9..105bdf2 100755 --- a/src/com/android/settings/bluetooth/BluetoothSettings.java +++ b/src/com/android/settings/bluetooth/BluetoothSettings.java @@ -244,7 +244,7 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment implem removeAllDevices(); } - mLocalManager.getCachedDeviceManager().clearCachedDevices(); + mLocalManager.getCachedDeviceManager().clearNonBondedDevices(); mAvailableDevicesCategory.removeAll(); mInitialScanStarted = true; mLocalAdapter.startScanning(true); diff --git a/src/com/android/settings/bluetooth/CachedBluetoothDeviceManager.java b/src/com/android/settings/bluetooth/CachedBluetoothDeviceManager.java index 0b53b1a..2b0e7f1 100755 --- a/src/com/android/settings/bluetooth/CachedBluetoothDeviceManager.java +++ b/src/com/android/settings/bluetooth/CachedBluetoothDeviceManager.java @@ -112,8 +112,13 @@ final class CachedBluetoothDeviceManager { return device.getAddress(); } - public synchronized void clearCachedDevices() { - mCachedDevices.clear(); + public synchronized void clearNonBondedDevices() { + for (int i = mCachedDevices.size() - 1; i >= 0; i--) { + CachedBluetoothDevice cachedDevice = mCachedDevices.get(i); + if (cachedDevice.getBondState() != BluetoothDevice.BOND_BONDED) { + mCachedDevices.remove(i); + } + } } public synchronized void onScanningStateChanged(boolean started) { @@ -148,8 +153,8 @@ final class CachedBluetoothDeviceManager { for (int i = mCachedDevices.size() - 1; i >= 0; i--) { CachedBluetoothDevice cachedDevice = mCachedDevices.get(i); if (cachedDevice.getBondState() != BluetoothDevice.BOND_BONDED) { - cachedDevice.setVisible(false); - mCachedDevices.remove(i); + cachedDevice.setVisible(false); + mCachedDevices.remove(i); } else { // For bonded devices, we need to clear the connection status so that // when BT is enabled next time, device connection status shall be retrieved |