Force storage wipe if not removable and encrypted

Bug: 5017638
Change-Id: I43c98359eff7202437249675060ba964e1bd085c
This commit is contained in:
Ben Komalo
2011-09-07 16:42:34 -07:00
parent e5d6179291
commit 2a32192329
2 changed files with 20 additions and 9 deletions

View File

@@ -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);

View File

@@ -60,7 +60,7 @@ public class Memory extends SettingsPreferenceFragment {
// one's preference is disabled
private Preference mLastClickedMountToggle;
private String mClickedMountPoint;
// Access using getMountService()
private IMountService mMountService = null;
@@ -197,7 +197,7 @@ public class Memory extends SettingsPreferenceFragment {
}
return mMountService;
}
@Override
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
for (int i = 0; i < mStorageVolumePreferenceCategories.length; i++) {
@@ -225,7 +225,7 @@ public class Memory extends SettingsPreferenceFragment {
return false;
}
private final BroadcastReceiver mMediaScannerReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
@@ -267,7 +267,7 @@ public class Memory extends SettingsPreferenceFragment {
mLastClickedMountToggle.setEnabled(false);
mLastClickedMountToggle.setTitle(mResources.getString(R.string.sd_ejecting_title));
mLastClickedMountToggle.setSummary(mResources.getString(R.string.sd_ejecting_summary));
mountService.unmountVolume(mClickedMountPoint, true);
mountService.unmountVolume(mClickedMountPoint, true, false);
} catch (RemoteException e) {
// Informative dialog to user that unmount failed.
showDialogInner(DLG_ERROR_UNMOUNT);