diff options
author | Jaikumar Ganesh <jaikumarg@android.com> | 2011-02-28 15:54:17 -0800 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2011-02-28 15:54:17 -0800 |
commit | 78c1c0eee41a1b6c6a259661d62d62d78841ad1f (patch) | |
tree | 937cf24e0cb394030ae77eca806cf0f818cc73bc | |
parent | 69eca7b7e77cb55f92b3eafd09f15be5644c3a4f (diff) | |
parent | c5813a6dcf079202d8dce16a37cbadd427804d9c (diff) | |
download | android_packages_apps_Bluetooth-78c1c0eee41a1b6c6a259661d62d62d78841ad1f.tar.gz android_packages_apps_Bluetooth-78c1c0eee41a1b6c6a259661d62d62d78841ad1f.tar.bz2 android_packages_apps_Bluetooth-78c1c0eee41a1b6c6a259661d62d62d78841ad1f.zip |
am c5813a6d: Merge "Check if BT is allowed in airplane mode"
* commit 'c5813a6dcf079202d8dce16a37cbadd427804d9c':
Check if BT is allowed in airplane mode
-rw-r--r-- | src/com/android/bluetooth/opp/BluetoothOppLauncherActivity.java | 39 |
1 files changed, 34 insertions, 5 deletions
diff --git a/src/com/android/bluetooth/opp/BluetoothOppLauncherActivity.java b/src/com/android/bluetooth/opp/BluetoothOppLauncherActivity.java index 353cadc3d..d358b8c22 100644 --- a/src/com/android/bluetooth/opp/BluetoothOppLauncherActivity.java +++ b/src/com/android/bluetooth/opp/BluetoothOppLauncherActivity.java @@ -43,6 +43,7 @@ import java.util.ArrayList; import android.app.Activity; import android.bluetooth.BluetoothDevicePicker; import android.content.Intent; +import android.content.ContentResolver; import android.content.Context; import android.net.Uri; import android.os.Bundle; @@ -118,7 +119,7 @@ public class BluetoothOppLauncherActivity extends Activity { } } - if (isAirplaneModeOn()) { + if (!isBluetoothAllowed()) { Intent in = new Intent(this, BluetoothOppBtErrorActivity.class); in.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); in.putExtra("title", this.getString(R.string.airplane_error_title)); @@ -164,11 +165,39 @@ public class BluetoothOppLauncherActivity extends Activity { finish(); } - /* Returns true if airplane mode is currently on */ - private final boolean isAirplaneModeOn() { - return Settings.System.getInt(this.getContentResolver(), Settings.System.AIRPLANE_MODE_ON, - 0) == 1; + /* Returns true if Bluetooth is allowed given current airplane mode settings. */ + private final boolean isBluetoothAllowed() { + final ContentResolver resolver = this.getContentResolver(); + + // Check if airplane mode is on + final boolean isAirplaneModeOn = Settings.System.getInt(resolver, + Settings.System.AIRPLANE_MODE_ON, 0) == 1; + if (!isAirplaneModeOn) { + return true; + } + + // Check if airplane mode matters + final String airplaneModeRadios = Settings.System.getString(resolver, + Settings.System.AIRPLANE_MODE_RADIOS); + final boolean isAirplaneSensitive = airplaneModeRadios == null ? true : + airplaneModeRadios.contains(Settings.System.RADIO_BLUETOOTH); + if (!isAirplaneSensitive) { + return true; + } + + // Check if Bluetooth may be enabled in airplane mode + final String airplaneModeToggleableRadios = Settings.System.getString(resolver, + Settings.System.AIRPLANE_MODE_TOGGLEABLE_RADIOS); + final boolean isAirplaneToggleable = airplaneModeToggleableRadios == null ? false : + airplaneModeToggleableRadios.contains(Settings.System.RADIO_BLUETOOTH); + if (isAirplaneToggleable) { + return true; + } + + // If we get here we're not allowed to use Bluetooth right now + return false; } + private Uri creatFileForSharedContent(Context context, CharSequence shareContent) { if (shareContent == null) { return null; |