Bring up factory reset UI when decryption fails but password is correct

Needs string change
Bug: 11477689

Change-Id: I1dcca59483bff32a939b8a7d052eafebd8a1eef0
This commit is contained in:
Paul Lawrence
2014-08-08 15:11:36 -07:00
parent d58f0bd64f
commit 384d8e52b6

View File

@@ -170,6 +170,11 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
} else if (failedAttempts == MAX_FAILED_ATTEMPTS) { } else if (failedAttempts == MAX_FAILED_ATTEMPTS) {
// Factory reset the device. // Factory reset the device.
sendBroadcast(new Intent("android.intent.action.MASTER_CLEAR")); sendBroadcast(new Intent("android.intent.action.MASTER_CLEAR"));
} else if (failedAttempts == -1) {
// Right password, but decryption failed. Tell user bad news ...
setContentView(R.layout.crypt_keeper_progress);
showFactoryReset(true);
return;
} else { } else {
// Wrong entry. Handle pattern case. // Wrong entry. Handle pattern case.
if (mLockPatternView != null) { if (mLockPatternView != null) {
@@ -392,7 +397,7 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
private void setupUi() { private void setupUi() {
if (mEncryptionGoneBad || isDebugView(FORCE_VIEW_ERROR)) { if (mEncryptionGoneBad || isDebugView(FORCE_VIEW_ERROR)) {
setContentView(R.layout.crypt_keeper_progress); setContentView(R.layout.crypt_keeper_progress);
showFactoryReset(); showFactoryReset(false);
return; return;
} }
@@ -508,7 +513,13 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
updateProgress(); updateProgress();
} }
private void showFactoryReset() { /**
* Show factory reset screen allowing the user to reset their phone when
* there is nothing else we can do
* @param corrupt true if userdata is corrupt, false if encryption failed
* partway through
*/
private void showFactoryReset(boolean corrupt) {
// Hide the encryption-bot to make room for the "factory reset" button // Hide the encryption-bot to make room for the "factory reset" button
findViewById(R.id.encroid).setVisibility(View.GONE); findViewById(R.id.encroid).setVisibility(View.GONE);
@@ -524,8 +535,13 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
}); });
// Alert the user of the failure. // Alert the user of the failure.
if (corrupt) {
((TextView) findViewById(R.id.title)).setText(R.string.crypt_keeper_data_corrupt_title);
((TextView) findViewById(R.id.status)).setText(R.string.crypt_keeper_data_corrupt_summary);
} else {
((TextView) findViewById(R.id.title)).setText(R.string.crypt_keeper_failed_title); ((TextView) findViewById(R.id.title)).setText(R.string.crypt_keeper_failed_title);
((TextView) findViewById(R.id.status)).setText(R.string.crypt_keeper_failed_summary); ((TextView) findViewById(R.id.status)).setText(R.string.crypt_keeper_failed_summary);
}
final View view = findViewById(R.id.bottom_divider); final View view = findViewById(R.id.bottom_divider);
// TODO(viki): Why would the bottom divider be missing in certain layouts? Investigate. // TODO(viki): Why would the bottom divider be missing in certain layouts? Investigate.
@@ -538,7 +554,7 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
final String state = SystemProperties.get("vold.encrypt_progress"); final String state = SystemProperties.get("vold.encrypt_progress");
if ("error_partially_encrypted".equals(state)) { if ("error_partially_encrypted".equals(state)) {
showFactoryReset(); showFactoryReset(false);
return; return;
} }