Force storage wipe if not removable and encrypted
Bug: 5017638 Change-Id: I43c98359eff7202437249675060ba964e1bd085c
This commit is contained in:
@@ -16,8 +16,6 @@
|
|||||||
|
|
||||||
package com.android.settings;
|
package com.android.settings;
|
||||||
|
|
||||||
import com.android.settings.R;
|
|
||||||
|
|
||||||
import android.accounts.Account;
|
import android.accounts.Account;
|
||||||
import android.accounts.AccountManager;
|
import android.accounts.AccountManager;
|
||||||
import android.accounts.AuthenticatorDescription;
|
import android.accounts.AuthenticatorDescription;
|
||||||
@@ -30,6 +28,7 @@ import android.content.res.Resources;
|
|||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
|
import android.os.SystemProperties;
|
||||||
import android.preference.Preference;
|
import android.preference.Preference;
|
||||||
import android.preference.PreferenceActivity;
|
import android.preference.PreferenceActivity;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
@@ -107,7 +106,7 @@ public class MasterClear extends Fragment {
|
|||||||
* keyguard confirmation if the user has currently enabled one. If there
|
* keyguard confirmation if the user has currently enabled one. If there
|
||||||
* is no keyguard available, we simply go to the final confirmation prompt.
|
* 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) {
|
public void onClick(View v) {
|
||||||
if (!runKeyguardConfirmation(KEYGUARD_REQUEST)) {
|
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
|
* 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
|
* 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
|
* 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);
|
mExternalStorageContainer.setVisibility(View.GONE);
|
||||||
|
|
||||||
final View externalOption = mContentView.findViewById(R.id.erase_external_option_text);
|
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);
|
final View externalAlsoErased = mContentView.findViewById(R.id.also_erases_external);
|
||||||
externalAlsoErased.setVisibility(View.VISIBLE);
|
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 {
|
} else {
|
||||||
mExternalStorageContainer.setOnClickListener(new View.OnClickListener() {
|
mExternalStorageContainer.setOnClickListener(new View.OnClickListener() {
|
||||||
|
|
||||||
@@ -161,6 +167,11 @@ public class MasterClear extends Fragment {
|
|||||||
loadAccountList();
|
loadAccountList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isExtStorageEncrypted() {
|
||||||
|
String state = SystemProperties.get("vold.decrypt");
|
||||||
|
return !"".equals(state);
|
||||||
|
}
|
||||||
|
|
||||||
private void loadAccountList() {
|
private void loadAccountList() {
|
||||||
View accountsLabel = mContentView.findViewById(R.id.accounts_label);
|
View accountsLabel = mContentView.findViewById(R.id.accounts_label);
|
||||||
LinearLayout contents = (LinearLayout)mContentView.findViewById(R.id.accounts);
|
LinearLayout contents = (LinearLayout)mContentView.findViewById(R.id.accounts);
|
||||||
|
@@ -60,7 +60,7 @@ public class Memory extends SettingsPreferenceFragment {
|
|||||||
// one's preference is disabled
|
// one's preference is disabled
|
||||||
private Preference mLastClickedMountToggle;
|
private Preference mLastClickedMountToggle;
|
||||||
private String mClickedMountPoint;
|
private String mClickedMountPoint;
|
||||||
|
|
||||||
// Access using getMountService()
|
// Access using getMountService()
|
||||||
private IMountService mMountService = null;
|
private IMountService mMountService = null;
|
||||||
|
|
||||||
@@ -197,7 +197,7 @@ public class Memory extends SettingsPreferenceFragment {
|
|||||||
}
|
}
|
||||||
return mMountService;
|
return mMountService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
|
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
|
||||||
for (int i = 0; i < mStorageVolumePreferenceCategories.length; i++) {
|
for (int i = 0; i < mStorageVolumePreferenceCategories.length; i++) {
|
||||||
@@ -225,7 +225,7 @@ public class Memory extends SettingsPreferenceFragment {
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final BroadcastReceiver mMediaScannerReceiver = new BroadcastReceiver() {
|
private final BroadcastReceiver mMediaScannerReceiver = new BroadcastReceiver() {
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
@@ -267,7 +267,7 @@ public class Memory extends SettingsPreferenceFragment {
|
|||||||
mLastClickedMountToggle.setEnabled(false);
|
mLastClickedMountToggle.setEnabled(false);
|
||||||
mLastClickedMountToggle.setTitle(mResources.getString(R.string.sd_ejecting_title));
|
mLastClickedMountToggle.setTitle(mResources.getString(R.string.sd_ejecting_title));
|
||||||
mLastClickedMountToggle.setSummary(mResources.getString(R.string.sd_ejecting_summary));
|
mLastClickedMountToggle.setSummary(mResources.getString(R.string.sd_ejecting_summary));
|
||||||
mountService.unmountVolume(mClickedMountPoint, true);
|
mountService.unmountVolume(mClickedMountPoint, true, false);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
// Informative dialog to user that unmount failed.
|
// Informative dialog to user that unmount failed.
|
||||||
showDialogInner(DLG_ERROR_UNMOUNT);
|
showDialogInner(DLG_ERROR_UNMOUNT);
|
||||||
|
Reference in New Issue
Block a user