From acafcf6a66afb4a7d59c210294aa346fcafbe748 Mon Sep 17 00:00:00 2001 From: Cristoforo Cataldo Date: Fri, 31 Jan 2014 07:36:29 +0100 Subject: [PATCH] GlobalActions: Set the initial status of airplane mode toggle Actually, the initial status of airplane mode toggle is set to false when the power menu dialog is initialized. This causes an issue if you set airplane mode and then reboot. After the reboot, the dialog displays the wrong airplane mode status, eg. "Airplane mode is not active", and if you toggle that option, a wrong intent is sent again to put ON the airplane mode, instead of OFF, the toggle (that is in transition state) will be set disabled. This commit fixes this issue. Change-Id: Id30355c1e090355645c437086c79ab59093c27a8 --- .../java/com/android/server/policy/GlobalActions.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/services/core/java/com/android/server/policy/GlobalActions.java b/services/core/java/com/android/server/policy/GlobalActions.java index 38ab3690cfbb..32d665d4423b 100644 --- a/services/core/java/com/android/server/policy/GlobalActions.java +++ b/services/core/java/com/android/server/policy/GlobalActions.java @@ -163,6 +163,9 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac mShowSilentToggle = SHOW_SILENT_TOGGLE && !mContext.getResources().getBoolean( com.android.internal.R.bool.config_useFixedVolume); + // Set the initial status of airplane mode toggle + mAirplaneState = getUpdatedAirplaneToggleState(); + updatePowerMenuActions(); } @@ -1262,15 +1265,17 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac } }; + private ToggleAction.State getUpdatedAirplaneToggleState() { + return (Settings.Global.getInt(mContext.getContentResolver(), + Settings.Global.AIRPLANE_MODE_ON, 0) == 1) ? + ToggleAction.State.On : ToggleAction.State.Off; + } + private void onAirplaneModeChanged() { // Let the service state callbacks handle the state. if (mHasTelephony) return; - boolean airplaneModeOn = Settings.Global.getInt( - mContext.getContentResolver(), - Settings.Global.AIRPLANE_MODE_ON, - 0) == 1; - mAirplaneState = airplaneModeOn ? ToggleAction.State.On : ToggleAction.State.Off; + mAirplaneState = getUpdatedAirplaneToggleState(); mAirplaneModeOn.updateState(mAirplaneState); } -- 2.11.0