Get correct factory reset reason from encryption failure

Requires matching framework change
https://googleplex-android-review.git.corp.google.com/#/c/535832/

Bug: 17213613
Change-Id: Ia8006f4a9cb5909d83f1848d9acfbc3f1e0ab5fb
This commit is contained in:
Paul Lawrence
2014-08-28 15:56:38 -07:00
committed by Rom Lemarchand
parent bde55601ba
commit 87abbd3ea0

View File

@@ -117,6 +117,8 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
private boolean mValidationRequested; private boolean mValidationRequested;
/** A flag to indicate that the volume is in a bad state (e.g. partially encrypted). */ /** A flag to indicate that the volume is in a bad state (e.g. partially encrypted). */
private boolean mEncryptionGoneBad; private boolean mEncryptionGoneBad;
/** If gone bad, should we show encryption failed (false) or corrupt (true)*/
private boolean mCorrupt;
/** A flag to indicate when the back event should be ignored */ /** A flag to indicate when the back event should be ignored */
private boolean mIgnoreBack = false; private boolean mIgnoreBack = false;
private int mCooldown; private int mCooldown;
@@ -224,12 +226,14 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
} }
private class ValidationTask extends AsyncTask<Void, Void, Boolean> { private class ValidationTask extends AsyncTask<Void, Void, Boolean> {
int state;
@Override @Override
protected Boolean doInBackground(Void... params) { protected Boolean doInBackground(Void... params) {
final IMountService service = getMountService(); final IMountService service = getMountService();
try { try {
Log.d(TAG, "Validating encryption state."); Log.d(TAG, "Validating encryption state.");
int state = service.getEncryptionState(); state = service.getEncryptionState();
if (state == IMountService.ENCRYPTION_STATE_NONE) { if (state == IMountService.ENCRYPTION_STATE_NONE) {
Log.w(TAG, "Unexpectedly in CryptKeeper even though there is no encryption."); Log.w(TAG, "Unexpectedly in CryptKeeper even though there is no encryption.");
return true; // Unexpected, but fine, I guess... return true; // Unexpected, but fine, I guess...
@@ -247,6 +251,7 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
if (Boolean.FALSE.equals(result)) { if (Boolean.FALSE.equals(result)) {
Log.w(TAG, "Incomplete, or corrupted encryption detected. Prompting user to wipe."); Log.w(TAG, "Incomplete, or corrupted encryption detected. Prompting user to wipe.");
mEncryptionGoneBad = true; mEncryptionGoneBad = true;
mCorrupt = state == IMountService.ENCRYPTION_STATE_ERROR_CORRUPT;
} else { } else {
Log.d(TAG, "Encryption state validated. Proceeding to configure UI"); Log.d(TAG, "Encryption state validated. Proceeding to configure UI");
} }
@@ -403,7 +408,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(false); showFactoryReset(mCorrupt);
return; return;
} }