Do not remove bonded devices from cached device list upon a device scan

Bug: 17405122

Change-Id: I3f5cc6ddc8f85d3b6223f9ff60e1d5eeb76c530a
This commit is contained in:
Matthew Xie
2014-09-08 22:30:18 -07:00
parent 1f389c1996
commit b17031bed0
2 changed files with 10 additions and 5 deletions

View File

@@ -244,7 +244,7 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment implem
removeAllDevices(); removeAllDevices();
} }
mLocalManager.getCachedDeviceManager().clearCachedDevices(); mLocalManager.getCachedDeviceManager().clearNonBondedDevices();
mAvailableDevicesCategory.removeAll(); mAvailableDevicesCategory.removeAll();
mInitialScanStarted = true; mInitialScanStarted = true;
mLocalAdapter.startScanning(true); mLocalAdapter.startScanning(true);

View File

@@ -112,8 +112,13 @@ final class CachedBluetoothDeviceManager {
return device.getAddress(); return device.getAddress();
} }
public synchronized void clearCachedDevices() { public synchronized void clearNonBondedDevices() {
mCachedDevices.clear(); 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) { public synchronized void onScanningStateChanged(boolean started) {