From 81cdaff7b5aed3ea2b987b23e2e9a6c0213b0aa5 Mon Sep 17 00:00:00 2001 From: Michael Chan Date: Wed, 7 Oct 2009 16:13:47 -0700 Subject: [PATCH] b/2173596 Cancel Bluetooth scanning when the user leaves Bluetooth Settings. Change-Id: Ib4dd6254c90da619e853b1be22fba3ff1365258e --- src/com/android/settings/bluetooth/BluetoothSettings.java | 6 ++++++ .../android/settings/bluetooth/CachedBluetoothDevice.java | 2 +- .../android/settings/bluetooth/LocalBluetoothManager.java | 6 ++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/com/android/settings/bluetooth/BluetoothSettings.java b/src/com/android/settings/bluetooth/BluetoothSettings.java index 4175a828840..02d84bc313b 100644 --- a/src/com/android/settings/bluetooth/BluetoothSettings.java +++ b/src/com/android/settings/bluetooth/BluetoothSettings.java @@ -203,6 +203,12 @@ public class BluetoothSettings extends PreferenceActivity } } + @Override + protected void onUserLeaveHint() { + super.onUserLeaveHint(); + mLocalManager.stopScanning(); + } + private void addDevices() { List cachedDevices = mLocalManager.getCachedDeviceManager().getCachedDevicesCopy(); diff --git a/src/com/android/settings/bluetooth/CachedBluetoothDevice.java b/src/com/android/settings/bluetooth/CachedBluetoothDevice.java index 1b45628c567..25c7f14bc4a 100644 --- a/src/com/android/settings/bluetooth/CachedBluetoothDevice.java +++ b/src/com/android/settings/bluetooth/CachedBluetoothDevice.java @@ -52,7 +52,7 @@ public class CachedBluetoothDevice implements Comparable private static final String TAG = "CachedBluetoothDevice"; private static final boolean D = LocalBluetoothManager.D; private static final boolean V = LocalBluetoothManager.V; - private static final boolean DEBUG = false; + private static final boolean DEBUG = true; // STOPSHIP - disable before final rom private static final int CONTEXT_ITEM_CONNECT = Menu.FIRST + 1; private static final int CONTEXT_ITEM_DISCONNECT = Menu.FIRST + 2; diff --git a/src/com/android/settings/bluetooth/LocalBluetoothManager.java b/src/com/android/settings/bluetooth/LocalBluetoothManager.java index f1315794388..5fb13bd7757 100644 --- a/src/com/android/settings/bluetooth/LocalBluetoothManager.java +++ b/src/com/android/settings/bluetooth/LocalBluetoothManager.java @@ -185,6 +185,12 @@ public class LocalBluetoothManager { } } + public void stopScanning() { + if (mAdapter.isDiscovering()) { + mAdapter.cancelDiscovery(); + } + } + public int getBluetoothState() { if (mState == BluetoothAdapter.ERROR) {