From 44303922f14ac71b446a6e50e1180be4c8fed2c7 Mon Sep 17 00:00:00 2001 From: Jeff Sharkey Date: Tue, 1 Dec 2009 18:25:02 -0800 Subject: Watch for "bluetooth" in list of toggleable radios. Settings.System.AIRPLANE_MODE_TOGGLEABLE_RADIOS is a list of radios that can be toggled while in airplane mode. This change adds logic to BluetoothService to allow enabling when Settings.System.RADIO_BLUETOOTH appears in that list. Fixes http://b/2297314 --- core/java/android/server/BluetoothService.java | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'core/java/android/server/BluetoothService.java') diff --git a/core/java/android/server/BluetoothService.java b/core/java/android/server/BluetoothService.java index b590449..dfb775f 100644 --- a/core/java/android/server/BluetoothService.java +++ b/core/java/android/server/BluetoothService.java @@ -74,6 +74,7 @@ public class BluetoothService extends IBluetooth.Stub { private int mNativeData; private BluetoothEventLoop mEventLoop; private boolean mIsAirplaneSensitive; + private boolean mIsAirplaneToggleable; private int mBluetoothState; private boolean mRestart = false; // need to call enable() after disable() private boolean mIsDiscovering; @@ -370,7 +371,7 @@ public class BluetoothService extends IBluetooth.Stub { "Need BLUETOOTH_ADMIN permission"); // Airplane mode can prevent Bluetooth radio from being turned on. - if (mIsAirplaneSensitive && isAirplaneModeOn()) { + if (mIsAirplaneSensitive && isAirplaneModeOn() && !mIsAirplaneToggleable) { return false; } if (mBluetoothState != BluetoothAdapter.STATE_OFF) { @@ -545,7 +546,7 @@ public class BluetoothService extends IBluetooth.Stub { mEventLoop.onPropertyChanged(propVal); } - if (mIsAirplaneSensitive && isAirplaneModeOn()) { + if (mIsAirplaneSensitive && isAirplaneModeOn() && !mIsAirplaneToggleable) { disable(false); } @@ -1597,10 +1598,17 @@ public class BluetoothService extends IBluetooth.Stub { }; private void registerForAirplaneMode(IntentFilter filter) { - String airplaneModeRadios = Settings.System.getString(mContext.getContentResolver(), + final ContentResolver resolver = mContext.getContentResolver(); + final String airplaneModeRadios = Settings.System.getString(resolver, Settings.System.AIRPLANE_MODE_RADIOS); - mIsAirplaneSensitive = airplaneModeRadios == null - ? true : airplaneModeRadios.contains(Settings.System.RADIO_BLUETOOTH); + final String toggleableRadios = Settings.System.getString(resolver, + Settings.System.AIRPLANE_MODE_TOGGLEABLE_RADIOS); + + mIsAirplaneSensitive = airplaneModeRadios == null ? true : + airplaneModeRadios.contains(Settings.System.RADIO_BLUETOOTH); + mIsAirplaneToggleable = toggleableRadios == null ? false : + toggleableRadios.contains(Settings.System.RADIO_BLUETOOTH); + if (mIsAirplaneSensitive) { filter.addAction(Intent.ACTION_AIRPLANE_MODE_CHANGED); } @@ -1661,6 +1669,7 @@ public class BluetoothService extends IBluetooth.Stub { } pw.println("mIsAirplaneSensitive = " + mIsAirplaneSensitive); + pw.println("mIsAirplaneToggleable = " + mIsAirplaneToggleable); pw.println("Local address = " + getAddress()); pw.println("Local name = " + getName()); -- cgit v1.1