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