Remove back button entirely when disabled
Bug: 7480506 Encryption screen shows back button
Change-Id: Iba2706fd6b61303178b472071f32d65bdf72e50d
diff --git a/src/com/android/settings/CryptKeeper.java b/src/com/android/settings/CryptKeeper.java
index f07d6fa..94c793d 100644
--- a/src/com/android/settings/CryptKeeper.java
+++ b/src/com/android/settings/CryptKeeper.java
@@ -55,6 +55,7 @@
import android.widget.ProgressBar;
import android.widget.TextView;
+import com.android.internal.statusbar.StatusBarIcon;
import com.android.internal.telephony.ITelephony;
import com.android.internal.telephony.Phone;
import com.android.internal.telephony.PhoneConstants;
@@ -229,6 +230,16 @@
};
private AudioManager mAudioManager;
+ /** The status bar where back/home/recent buttons are shown. */
+ private StatusBarManager mStatusBar;
+
+ /** All the widgets to disable in the status bar */
+ final private static int sWidgetsToDisable = StatusBarManager.DISABLE_EXPAND
+ | StatusBarManager.DISABLE_NOTIFICATION_ICONS
+ | StatusBarManager.DISABLE_NOTIFICATION_ALERTS
+ | StatusBarManager.DISABLE_SYSTEM_INFO
+ | StatusBarManager.DISABLE_HOME
+ | StatusBarManager.DISABLE_RECENT;
/** @return whether or not this Activity was started for debugging the UI only. */
private boolean isDebugView() {
@@ -269,6 +280,7 @@
*/
@Override
public void onBackPressed() {
+ // In the rare case that something pressed back even though we were disabled.
if (mIgnoreBack)
return;
super.onBackPressed();
@@ -299,13 +311,8 @@
// Disable the status bar, but do NOT disable back because the user needs a way to go
// from keyboard settings and back to the password screen.
- StatusBarManager sbm = (StatusBarManager) getSystemService(Context.STATUS_BAR_SERVICE);
- sbm.disable(StatusBarManager.DISABLE_EXPAND
- | StatusBarManager.DISABLE_NOTIFICATION_ICONS
- | StatusBarManager.DISABLE_NOTIFICATION_ALERTS
- | StatusBarManager.DISABLE_SYSTEM_INFO
- | StatusBarManager.DISABLE_HOME
- | StatusBarManager.DISABLE_RECENT);
+ mStatusBar = (StatusBarManager) getSystemService(Context.STATUS_BAR_SERVICE);
+ mStatusBar.disable(sWidgetsToDisable);
setAirplaneModeIfNecessary();
mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
@@ -403,7 +410,7 @@
((ProgressBar) findViewById(R.id.progress_bar)).setIndeterminate(true);
// Ignore all back presses from now, both hard and soft keys.
- mIgnoreBack = true;
+ setBackFunctionality(false);
// Start the first run of progress manually. This method sets up messages to occur at
// repeated intervals.
updateProgress();
@@ -469,7 +476,7 @@
if (mCooldown <= 0) {
// Re-enable the password entry and back presses.
mPasswordEntry.setEnabled(true);
- mIgnoreBack = false;
+ setBackFunctionality(true);
status.setText(R.string.enter_password);
} else {
CharSequence template = getText(R.string.crypt_keeper_cooldown);
@@ -481,6 +488,19 @@
}
}
+ /**
+ * Sets the back status: enabled or disabled according to the parameter.
+ * @param isEnabled true if back is enabled, false otherwise.
+ */
+ private final void setBackFunctionality(boolean isEnabled) {
+ mIgnoreBack = !isEnabled;
+ if (isEnabled) {
+ mStatusBar.disable(sWidgetsToDisable);
+ } else {
+ mStatusBar.disable(sWidgetsToDisable | StatusBarManager.DISABLE_BACK);
+ }
+ }
+
private void passwordEntryInit() {
mPasswordEntry = (EditText) findViewById(R.id.passwordEntry);
mPasswordEntry.setOnEditorActionListener(this);
@@ -610,7 +630,7 @@
// Disable the password entry and back keypress while checking the password. These
// we either be re-enabled if the password was wrong or after the cooldown period.
mPasswordEntry.setEnabled(false);
- mIgnoreBack = true;
+ setBackFunctionality(false);
Log.d(TAG, "Attempting to send command to decrypt");
new DecryptTask().execute(password);