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;
};
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() {
*/
@Override
public void onBackPressed() {
+ // In the rare case that something pressed back even though we were disabled.
if (mIgnoreBack)
return;
super.onBackPressed();
// 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);
((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();
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);
}
}
+ /**
+ * 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);
// 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);