summaryrefslogtreecommitdiffstats
path: root/src/com/android/settings/bluetooth/CachedBluetoothDeviceManager.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/settings/bluetooth/CachedBluetoothDeviceManager.java')
-rw-r--r--src/com/android/settings/bluetooth/CachedBluetoothDeviceManager.java14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/com/android/settings/bluetooth/CachedBluetoothDeviceManager.java b/src/com/android/settings/bluetooth/CachedBluetoothDeviceManager.java
index 77f6b2c..06be3c4 100644
--- a/src/com/android/settings/bluetooth/CachedBluetoothDeviceManager.java
+++ b/src/com/android/settings/bluetooth/CachedBluetoothDeviceManager.java
@@ -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_BONDED) {
+ cachedDevice.setVisible(false);
+ mCachedDevices.remove(i);
+ }
+ }
+ }
+ }
private void log(String msg) {
if (DEBUG) {
Log.d(TAG, msg);