From 797fc45ff65eccb6f967e93de913622c5225fb95 Mon Sep 17 00:00:00 2001 From: PauloftheWest Date: Wed, 1 Oct 2014 06:14:58 -0700 Subject: [PATCH] Fixed a Setting Bluetooth Airplane mode bug. + This patch moves the switch listeners from setup/teardown of the SwitchBar to pause/resume of Bluetooth Settings. This prevents Bluetooth from receiving connect messages while Airplane mode is turning off Bluetooth (which is what caused Bluetooth to re-enable.) Bug: 17465951 Change-Id: I4d32fcf5bb3a2241ed03e2295c86390e15743954 --- src/com/android/settings/bluetooth/BluetoothEnabler.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/com/android/settings/bluetooth/BluetoothEnabler.java b/src/com/android/settings/bluetooth/BluetoothEnabler.java index 45f3d067258..b006c656194 100644 --- a/src/com/android/settings/bluetooth/BluetoothEnabler.java +++ b/src/com/android/settings/bluetooth/BluetoothEnabler.java @@ -90,12 +90,10 @@ public final class BluetoothEnabler implements SwitchBar.OnSwitchChangeListener } public void setupSwitchBar() { - mSwitchBar.addOnSwitchChangeListener(this); mSwitchBar.show(); } public void teardownSwitchBar() { - mSwitchBar.removeOnSwitchChangeListener(this); mSwitchBar.hide(); } @@ -112,6 +110,7 @@ public final class BluetoothEnabler implements SwitchBar.OnSwitchChangeListener // Bluetooth state is not sticky, so set it manually handleStateChanged(mLocalAdapter.getBluetoothState()); + mSwitchBar.addOnSwitchChangeListener(this); mContext.registerReceiver(mReceiver, mIntentFilter); mValidListener = true; } @@ -121,6 +120,7 @@ public final class BluetoothEnabler implements SwitchBar.OnSwitchChangeListener return; } + mSwitchBar.removeOnSwitchChangeListener(this); mContext.unregisterReceiver(mReceiver); mValidListener = false; }