diff options
author | Ben Komalo <benkomalo@google.com> | 2011-09-07 16:42:34 -0700 |
---|---|---|
committer | Ben Komalo <benkomalo@google.com> | 2011-09-09 12:40:38 -0700 |
commit | 2a32192329ac47da1e64f7085f4317212e99a3bf (patch) | |
tree | 9eda90df234fe4ee7db87ec1b2f85553e84c62be /src/com/android/settings/MasterClear.java | |
parent | e5d6179291276ed95cfc1d4a89e890d5fb4d04f7 (diff) | |
download | packages_apps_Settings-2a32192329ac47da1e64f7085f4317212e99a3bf.zip packages_apps_Settings-2a32192329ac47da1e64f7085f4317212e99a3bf.tar.gz packages_apps_Settings-2a32192329ac47da1e64f7085f4317212e99a3bf.tar.bz2 |
Force storage wipe if not removable and encrypted
Bug: 5017638
Change-Id: I43c98359eff7202437249675060ba964e1bd085c
Diffstat (limited to 'src/com/android/settings/MasterClear.java')
-rw-r--r-- | src/com/android/settings/MasterClear.java | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/src/com/android/settings/MasterClear.java b/src/com/android/settings/MasterClear.java index 29a92b1..39b17a9 100644 --- a/src/com/android/settings/MasterClear.java +++ b/src/com/android/settings/MasterClear.java @@ -16,8 +16,6 @@ package com.android.settings; -import com.android.settings.R; - import android.accounts.Account; import android.accounts.AccountManager; import android.accounts.AuthenticatorDescription; @@ -30,6 +28,7 @@ import android.content.res.Resources; import android.graphics.drawable.Drawable; import android.os.Bundle; import android.os.Environment; +import android.os.SystemProperties; import android.preference.Preference; import android.preference.PreferenceActivity; import android.util.Log; @@ -107,7 +106,7 @@ public class MasterClear extends Fragment { * keyguard confirmation if the user has currently enabled one. If there * is no keyguard available, we simply go to the final confirmation prompt. */ - private Button.OnClickListener mInitiateListener = new Button.OnClickListener() { + private final Button.OnClickListener mInitiateListener = new Button.OnClickListener() { public void onClick(View v) { if (!runKeyguardConfirmation(KEYGUARD_REQUEST)) { @@ -138,9 +137,12 @@ public class MasterClear extends Fragment { * If the external storage is emulated, it will be erased with a factory * reset at any rate. There is no need to have a separate option until * we have a factory reset that only erases some directories and not - * others. + * others. Likewise, if it's non-removable storage, it could potentially have been + * encrypted, and will also need to be wiped. */ - if (Environment.isExternalStorageEmulated()) { + boolean isExtStorageEmulated = Environment.isExternalStorageEmulated(); + if (isExtStorageEmulated + || (!Environment.isExternalStorageRemovable() && isExtStorageEncrypted())) { mExternalStorageContainer.setVisibility(View.GONE); final View externalOption = mContentView.findViewById(R.id.erase_external_option_text); @@ -148,6 +150,10 @@ public class MasterClear extends Fragment { final View externalAlsoErased = mContentView.findViewById(R.id.also_erases_external); externalAlsoErased.setVisibility(View.VISIBLE); + + // If it's not emulated, it is on a separate partition but it means we're doing + // a force wipe due to encryption. + mExternalStorage.setChecked(!isExtStorageEmulated); } else { mExternalStorageContainer.setOnClickListener(new View.OnClickListener() { @@ -161,6 +167,11 @@ public class MasterClear extends Fragment { loadAccountList(); } + private boolean isExtStorageEncrypted() { + String state = SystemProperties.get("vold.decrypt"); + return !"".equals(state); + } + private void loadAccountList() { View accountsLabel = mContentView.findViewById(R.id.accounts_label); LinearLayout contents = (LinearLayout)mContentView.findViewById(R.id.accounts); |