Merge "Do not remove bonded devices from cached device list upon a device scan" into lmp-dev
This commit is contained in:
@@ -245,7 +245,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);
|
||||||
|
@@ -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) {
|
||||||
@@ -148,8 +153,8 @@ final class CachedBluetoothDeviceManager {
|
|||||||
for (int i = mCachedDevices.size() - 1; i >= 0; i--) {
|
for (int i = mCachedDevices.size() - 1; i >= 0; i--) {
|
||||||
CachedBluetoothDevice cachedDevice = mCachedDevices.get(i);
|
CachedBluetoothDevice cachedDevice = mCachedDevices.get(i);
|
||||||
if (cachedDevice.getBondState() != BluetoothDevice.BOND_BONDED) {
|
if (cachedDevice.getBondState() != BluetoothDevice.BOND_BONDED) {
|
||||||
cachedDevice.setVisible(false);
|
cachedDevice.setVisible(false);
|
||||||
mCachedDevices.remove(i);
|
mCachedDevices.remove(i);
|
||||||
} else {
|
} else {
|
||||||
// For bonded devices, we need to clear the connection status so that
|
// For bonded devices, we need to clear the connection status so that
|
||||||
// when BT is enabled next time, device connection status shall be retrieved
|
// when BT is enabled next time, device connection status shall be retrieved
|
||||||
|
Reference in New Issue
Block a user