Clear the Available (unbonded devices) from the CachedDevices List
during BT disable. Change-Id: I576237a4165759fe952690f19fde59ce78cd1d29
This commit is contained in:
committed by
Matthew Xie
parent
00ec05985d
commit
737a30f593
@@ -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);
|
||||
|
Reference in New Issue
Block a user