summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAmit Blay <ablay@codeaurora.org>2015-09-01 17:47:18 +0300
committerLinux Build Service Account <lnxbuild@localhost>2015-10-06 03:21:15 -0600
commit28ae1ff06b3c1805b452fa58ecb0d92291082dde (patch)
treefba87dcf9b77828f522a56be73f6b554098a76d7 /src
parent5def03792ca8a0e0daaafe756b70b8e0f471c05c (diff)
downloadpackages_apps_Settings-28ae1ff06b3c1805b452fa58ecb0d92291082dde.zip
packages_apps_Settings-28ae1ff06b3c1805b452fa58ecb0d92291082dde.tar.gz
packages_apps_Settings-28ae1ff06b3c1805b452fa58ecb0d92291082dde.tar.bz2
Modified the behavior of encryption failure, when MDTP is activated
If MDTP is activated the device will be wiped, instead of recovery. Change-Id: I6ab1b82841e4d6e90a8d156dea03448674f64446
Diffstat (limited to 'src')
-rw-r--r--src/com/android/settings/CryptKeeper.java64
1 files changed, 48 insertions, 16 deletions
diff --git a/src/com/android/settings/CryptKeeper.java b/src/com/android/settings/CryptKeeper.java
index 45b4ff1..8e4aae9 100644
--- a/src/com/android/settings/CryptKeeper.java
+++ b/src/com/android/settings/CryptKeeper.java
@@ -115,6 +115,8 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
private boolean mEncryptionGoneBad;
/** If gone bad, should we show encryption failed (false) or corrupt (true)*/
private boolean mCorrupt;
+ /** If gone bad and mdtp is activated we should not allow recovery screen, only wipe the data */
+ private boolean mMdtpActivated;
/** A flag to indicate when the back event should be ignored */
/** When set, blocks unlocking. Set every COOL_DOWN_ATTEMPTS attempts, only cleared
by power cycling phone. */
@@ -208,14 +210,27 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
hide(R.id.emergencyCallButton);
} else if (failedAttempts == MAX_FAILED_ATTEMPTS) {
// Factory reset the device.
- Intent intent = new Intent(Intent.ACTION_MASTER_CLEAR);
- intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
- intent.putExtra(Intent.EXTRA_REASON, "CryptKeeper.MAX_FAILED_ATTEMPTS");
- sendBroadcast(intent);
+ if(mMdtpActivated){
+ Log.d(TAG,
+ " CryptKeeper.MAX_FAILED_ATTEMPTS, calling encryptStorage with wipe");
+ try {
+ final IMountService service = getMountService();
+ service.encryptWipeStorage(StorageManager.CRYPT_TYPE_DEFAULT, "");
+
+ } catch (RemoteException e) {
+ Log.w(TAG, "Unable to call MountService properly");
+ return;
+ }
+ } else {
+ Intent intent = new Intent(Intent.ACTION_MASTER_CLEAR);
+ intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
+ intent.putExtra(Intent.EXTRA_REASON, "CryptKeeper.MAX_FAILED_ATTEMPTS");
+ sendBroadcast(intent);
+ }
} else if (failedAttempts == -1) {
// Right password, but decryption failed. Tell user bad news ...
setContentView(R.layout.crypt_keeper_progress);
- showFactoryReset(true);
+ showFactoryReset(true, false);
return;
} else {
handleBadAttempt(failedAttempts);
@@ -296,10 +311,13 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
Log.w(TAG, "Unexpectedly in CryptKeeper even though there is no encryption.");
return true; // Unexpected, but fine, I guess...
}
- return state == IMountService.ENCRYPTION_STATE_OK;
+ mMdtpActivated = (state == IMountService.ENCRYPTION_STATE_ERROR_MDTP_ACTIVATED) ||
+ (state == IMountService.ENCRYPTION_STATE_OK_MDTP_ACTIVATED);
+ return (state == IMountService.ENCRYPTION_STATE_OK) ||
+ (state == IMountService.ENCRYPTION_STATE_OK_MDTP_ACTIVATED);
} catch (RemoteException e) {
Log.w(TAG, "Unable to get encryption state properly");
- return true;
+ return false;
}
}
@@ -456,7 +474,7 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
private void setupUi() {
if (mEncryptionGoneBad || isDebugView(FORCE_VIEW_ERROR)) {
setContentView(R.layout.crypt_keeper_progress);
- showFactoryReset(mCorrupt);
+ showFactoryReset(mCorrupt, mMdtpActivated);
return;
}
@@ -590,8 +608,10 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
* there is nothing else we can do
* @param corrupt true if userdata is corrupt, false if encryption failed
* partway through
+ * @param mdtp_activated true if MDTP is activated according to MountService
+ * state.
*/
- private void showFactoryReset(final boolean corrupt) {
+ private void showFactoryReset(final boolean corrupt, final boolean mdtp_activated) {
// Hide the encryption-bot to make room for the "factory reset" button
findViewById(R.id.encroid).setVisibility(View.GONE);
@@ -601,12 +621,24 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
- // Factory reset the device.
- Intent intent = new Intent(Intent.ACTION_MASTER_CLEAR);
- intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
- intent.putExtra(Intent.EXTRA_REASON,
- "CryptKeeper.showFactoryReset() corrupt=" + corrupt);
- sendBroadcast(intent);
+ if(mdtp_activated){
+ Log.d(TAG, " Calling encryptStorage with wipe");
+ try {
+ final IMountService service = getMountService();
+ service.encryptWipeStorage(StorageManager.CRYPT_TYPE_DEFAULT, "");
+
+ } catch (RemoteException e) {
+ Log.w(TAG, "Unable to call MountService properly");
+ return;
+ }
+ } else {
+ // Factory reset the device.
+ Intent intent = new Intent(Intent.ACTION_MASTER_CLEAR);
+ intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
+ intent.putExtra(Intent.EXTRA_REASON,
+ "CryptKeeper.showFactoryReset() corrupt=" + corrupt);
+ sendBroadcast(intent);
+ }
}
});
@@ -630,7 +662,7 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
final String state = SystemProperties.get("vold.encrypt_progress");
if ("error_partially_encrypted".equals(state)) {
- showFactoryReset(false);
+ showFactoryReset(false, false);
return;
}