summaryrefslogtreecommitdiffstats
path: root/src/com/android/settings/AirplaneModeEnabler.java
diff options
context:
space:
mode:
authorIrfan Sheriff <isheriff@google.com>2010-08-02 19:11:16 -0700
committerIrfan Sheriff <isheriff@google.com>2010-08-02 19:14:17 -0700
commitecea11f3e9a28818ff394f0bca2eb9d1c4c016ba (patch)
treedd69abae66db85378ec96e0f847c308684e2ca62 /src/com/android/settings/AirplaneModeEnabler.java
parentcdc8ee9ed7e945aca944609792cb4c6fd8f3e420 (diff)
downloadpackages_apps_settings-ecea11f3e9a28818ff394f0bca2eb9d1c4c016ba.zip
packages_apps_settings-ecea11f3e9a28818ff394f0bca2eb9d1c4c016ba.tar.gz
packages_apps_settings-ecea11f3e9a28818ff394f0bca2eb9d1c4c016ba.tar.bz2
Keep airplane mode UI & system settings in sync
If mobile radio bring up/down fails, airplane mode UI & system settings go out of sync and this prevents wifi from being brought up on every reboot. Bug: 2887841 Change-Id: Id0f1299e6b4e2c28b72c8fb8d853dad3fcaceaa7
Diffstat (limited to 'src/com/android/settings/AirplaneModeEnabler.java')
-rw-r--r--src/com/android/settings/AirplaneModeEnabler.java14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/com/android/settings/AirplaneModeEnabler.java b/src/com/android/settings/AirplaneModeEnabler.java
index ff4b27d..ccfe541 100644
--- a/src/com/android/settings/AirplaneModeEnabler.java
+++ b/src/com/android/settings/AirplaneModeEnabler.java
@@ -64,8 +64,6 @@ public class AirplaneModeEnabler implements Preference.OnPreferenceChangeListene
public void resume() {
- // This is the widget enabled state, not the preference toggled state
- mCheckBoxPref.setEnabled(true);
mCheckBoxPref.setChecked(isAirplaneModeOn(mContext));
mPhoneStateReceiver.registerIntent();
@@ -84,13 +82,14 @@ public class AirplaneModeEnabler implements Preference.OnPreferenceChangeListene
private void setAirplaneModeOn(boolean enabling) {
- mCheckBoxPref.setEnabled(false);
mCheckBoxPref.setSummary(enabling ? R.string.airplane_mode_turning_on
: R.string.airplane_mode_turning_off);
// Change the system setting
Settings.System.putInt(mContext.getContentResolver(), Settings.System.AIRPLANE_MODE_ON,
enabling ? 1 : 0);
+ // Update the UI to reflect system setting
+ mCheckBoxPref.setChecked(enabling);
// Post the intent
Intent intent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED);
@@ -100,14 +99,17 @@ public class AirplaneModeEnabler implements Preference.OnPreferenceChangeListene
/**
* Called when we've received confirmation that the airplane mode was set.
+ * TODO: We update the checkbox summary when we get notified
+ * that mobile radio is powered up/down. We should not have dependency
+ * on one radio alone. We need to do the following:
+ * - handle the case of wifi/bluetooth failures
+ * - mobile does not send failure notification, fail on timeout.
*/
private void onAirplaneModeChanged() {
ServiceState serviceState = mPhoneStateReceiver.getServiceState();
boolean airplaneModeEnabled = serviceState.getState() == ServiceState.STATE_POWER_OFF;
- mCheckBoxPref.setChecked(airplaneModeEnabled);
mCheckBoxPref.setSummary(airplaneModeEnabled ? null :
mContext.getString(R.string.airplane_mode_summary));
- mCheckBoxPref.setEnabled(true);
}
/**
@@ -128,7 +130,7 @@ public class AirplaneModeEnabler implements Preference.OnPreferenceChangeListene
// update database based on the current checkbox state
setAirplaneModeOn(isAirplaneModeOn);
} else {
- // update checkbox state based on database value
+ // update summary
onAirplaneModeChanged();
}
}