Clear the Available (unbonded devices) from the CachedDevices List

during BT disable.

Change-Id: I576237a4165759fe952690f19fde59ce78cd1d29
This commit is contained in:
Kausik Sinnaswamy
2012-05-16 14:31:45 +05:30
committed by Matthew Xie
parent 00ec05985d
commit 737a30f593
2 changed files with 16 additions and 0 deletions

View File

@@ -16,6 +16,7 @@
package com.android.settings.bluetooth;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.content.Context;
import android.util.Log;
@@ -134,6 +135,19 @@ final class CachedBluetoothDeviceManager {
}
}
public synchronized void onBluetoothStateChanged(int bluetoothState) {
// When Bluetooth is turning off, we need to clear the non-bonded devices
// Otherwise, they end up showing up on the next BT enable
if (bluetoothState == BluetoothAdapter.STATE_TURNING_OFF) {
for (int i = mCachedDevices.size() - 1; i >= 0; i--) {
CachedBluetoothDevice cachedDevice = mCachedDevices.get(i);
if (cachedDevice.getBondState() == BluetoothDevice.BOND_NONE) {
cachedDevice.setVisible(false);
mCachedDevices.remove(i);
}
}
}
}
private void log(String msg) {
if (DEBUG) {
Log.d(TAG, msg);