diff --git a/src/com/android/settings/CryptKeeper.java b/src/com/android/settings/CryptKeeper.java index 770ee122db5..3d752a32bca 100644 --- a/src/com/android/settings/CryptKeeper.java +++ b/src/com/android/settings/CryptKeeper.java @@ -99,6 +99,7 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + // If we are not encrypted or encrypting, get out quickly. String state = SystemProperties.get("vold.decrypt"); if ("".equals(state) || DECRYPT_STATE.equals(state)) { // Disable the crypt keeper. @@ -108,17 +109,6 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList return; } - // Check to see why we were started. - String progress = SystemProperties.get("vold.encrypt_progress"); - - if (!"".equals(progress)) { - setContentView(R.layout.crypt_keeper_progress); - encryptionProgressInit(); - } else { - setContentView(R.layout.crypt_keeper_password_entry); - passwordEntryInit(); - } - // Disable the status bar StatusBarManager sbm = (StatusBarManager) getSystemService(Context.STATUS_BAR_SERVICE); sbm.disable(StatusBarManager.DISABLE_EXPAND @@ -136,6 +126,26 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList } } + /** + * Note, we defer the state check and screen setup to onStart() because this will be + * re-run if the user clicks the power button (sleeping/waking the screen), and this is + * especially important if we were to lose the wakelock for any reason. + */ + @Override + public void onStart() { + super.onStart(); + + // Check to see why we were started. + String progress = SystemProperties.get("vold.encrypt_progress"); + if (!"".equals(progress)) { + setContentView(R.layout.crypt_keeper_progress); + encryptionProgressInit(); + } else { + setContentView(R.layout.crypt_keeper_password_entry); + passwordEntryInit(); + } + } + @Override public void onStop() { super.onStop();