summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIrfan Sheriff <isheriff@google.com>2013-02-20 15:12:41 -0800
committerIrfan Sheriff <isheriff@google.com>2013-02-21 08:49:54 -0800
commit8a64b1a7f4b07e71b9eb0f4a98710cb1409588bf (patch)
treee8da0b8b00bc4797150317133cbc4922b661fb74
parentb8c0e009a74ac2eaee8946fbe0bb3b3fe2749c9a (diff)
downloadframeworks_base-8a64b1a7f4b07e71b9eb0f4a98710cb1409588bf.zip
frameworks_base-8a64b1a7f4b07e71b9eb0f4a98710cb1409588bf.tar.gz
frameworks_base-8a64b1a7f4b07e71b9eb0f4a98710cb1409588bf.tar.bz2
Handle airplane settings properly
Fix bug dealing with airplane mode settings of whether wifi is sensitive to airplane mode change and whether wifi is allowed to override airplane mode that likely has been broken ever since. Bug: 8141918 Change-Id: Ia3116c9dfce2952cbe3911e9d81dbbae0430abef
-rw-r--r--services/java/com/android/server/wifi/WifiService.java10
-rw-r--r--services/java/com/android/server/wifi/WifiSettingsStore.java21
2 files changed, 23 insertions, 8 deletions
diff --git a/services/java/com/android/server/wifi/WifiService.java b/services/java/com/android/server/wifi/WifiService.java
index f27d2f6..3c14e3d 100644
--- a/services/java/com/android/server/wifi/WifiService.java
+++ b/services/java/com/android/server/wifi/WifiService.java
@@ -275,8 +275,9 @@ public final class WifiService extends IWifiManager.Stub {
new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
- mSettingsStore.handleAirplaneModeToggled();
- updateWifiState();
+ if (mSettingsStore.handleAirplaneModeToggled()) {
+ updateWifiState();
+ }
}
},
new IntentFilter(Intent.ACTION_AIRPLANE_MODE_CHANGED));
@@ -424,7 +425,10 @@ public final class WifiService extends IWifiManager.Stub {
long ident = Binder.clearCallingIdentity();
try {
- mSettingsStore.handleWifiToggled(enable);
+ if (! mSettingsStore.handleWifiToggled(enable)) {
+ // Nothing to do if wifi cannot be toggled
+ return true;
+ }
} finally {
Binder.restoreCallingIdentity(ident);
}
diff --git a/services/java/com/android/server/wifi/WifiSettingsStore.java b/services/java/com/android/server/wifi/WifiSettingsStore.java
index a286d14..d7c8752 100644
--- a/services/java/com/android/server/wifi/WifiSettingsStore.java
+++ b/services/java/com/android/server/wifi/WifiSettingsStore.java
@@ -70,10 +70,14 @@ final class WifiSettingsStore {
return mAirplaneModeOn;
}
- synchronized void handleWifiToggled(boolean wifiEnabled) {
- boolean airplaneEnabled = mAirplaneModeOn && isAirplaneToggleable();
+ synchronized boolean handleWifiToggled(boolean wifiEnabled) {
+ // Can Wi-Fi be toggled in airplane mode ?
+ if (mAirplaneModeOn && !isAirplaneToggleable()) {
+ return false;
+ }
+
if (wifiEnabled) {
- if (airplaneEnabled) {
+ if (mAirplaneModeOn) {
persistWifiState(WIFI_ENABLED_AIRPLANE_OVERRIDE);
} else {
persistWifiState(WIFI_ENABLED);
@@ -85,9 +89,15 @@ final class WifiSettingsStore {
// is handled handleAirplaneModeToggled()
persistWifiState(WIFI_DISABLED);
}
+ return true;
}
- synchronized void handleAirplaneModeToggled() {
+ synchronized boolean handleAirplaneModeToggled() {
+ // Is Wi-Fi sensitive to airplane mode changes ?
+ if (!isAirplaneSensitive()) {
+ return false;
+ }
+
mAirplaneModeOn = getPersistedAirplaneModeOn();
if (mAirplaneModeOn) {
// Wifi disabled due to airplane on
@@ -101,6 +111,7 @@ final class WifiSettingsStore {
persistWifiState(WIFI_ENABLED);
}
}
+ return true;
}
void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
@@ -161,7 +172,7 @@ final class WifiSettingsStore {
}
private boolean getPersistedAirplaneModeOn() {
- return isAirplaneSensitive() && Settings.Global.getInt(mContext.getContentResolver(),
+ return Settings.Global.getInt(mContext.getContentResolver(),
Settings.Global.AIRPLANE_MODE_ON, 0) == 1;
}
}