summaryrefslogtreecommitdiffstats
path: root/services/devicepolicy
diff options
context:
space:
mode:
authorRubin Xu <rubinxu@google.com>2015-06-25 12:17:48 +0100
committerRubin Xu <rubinxu@google.com>2015-06-26 15:58:21 +0100
commite8490f1d78a62826742ddf4af8943e6666a1a8d0 (patch)
tree154d2a3a6a7cb94fa8b5e088f51b464cce4d560f /services/devicepolicy
parent729ffa299ca786eb21ba8330096b33c7bcd66fbf (diff)
downloadframeworks_base-e8490f1d78a62826742ddf4af8943e6666a1a8d0.zip
frameworks_base-e8490f1d78a62826742ddf4af8943e6666a1a8d0.tar.gz
frameworks_base-e8490f1d78a62826742ddf4af8943e6666a1a8d0.tar.bz2
Use StorageManager.wipeAdoptableDisks to wipe external disks
Retire FORMAT_AND_FACTORY_RESET which is more fragile. Bug: 9433509 Change-Id: I158ee987274bb4db41d466de9f1e3c60ffc1d140
Diffstat (limited to 'services/devicepolicy')
-rw-r--r--services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java30
1 files changed, 10 insertions, 20 deletions
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
index 491b412..5cfbb40 100644
--- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
+++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
@@ -85,6 +85,7 @@ import android.os.SystemClock;
import android.os.SystemProperties;
import android.os.UserHandle;
import android.os.UserManager;
+import android.os.storage.StorageManager;
import android.provider.ContactsContract.QuickContact;
import android.provider.ContactsInternal;
import android.provider.Settings;
@@ -108,7 +109,6 @@ import android.view.inputmethod.InputMethodInfo;
import android.view.inputmethod.InputMethodManager;
import com.android.internal.R;
-import com.android.internal.os.storage.ExternalStorageFormatter;
import com.android.internal.statusbar.IStatusBarService;
import com.android.internal.util.FastXmlSerializer;
import com.android.internal.util.JournaledFile;
@@ -3307,25 +3307,15 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
}
private void wipeDataLocked(boolean wipeExtRequested, String reason) {
- // TODO: wipe all public volumes on device
-
- // If the SD card is encrypted and non-removable, we have to force a wipe.
- boolean forceExtWipe = !Environment.isExternalStorageRemovable() && isExtStorageEncrypted();
-
- // Note: we can only do the wipe via ExternalStorageFormatter if the volume is not emulated.
- if ((forceExtWipe || wipeExtRequested) && !Environment.isExternalStorageEmulated()) {
- Intent intent = new Intent(ExternalStorageFormatter.FORMAT_AND_FACTORY_RESET);
- intent.putExtra(ExternalStorageFormatter.EXTRA_ALWAYS_RESET, true);
- intent.putExtra(Intent.EXTRA_REASON, reason);
- intent.setComponent(ExternalStorageFormatter.COMPONENT_NAME);
- mWakeLock.acquire(10000);
- mContext.startService(intent);
- } else {
- try {
- RecoverySystem.rebootWipeUserData(mContext, reason);
- } catch (IOException | SecurityException e) {
- Slog.w(LOG_TAG, "Failed requesting data wipe", e);
- }
+ if (wipeExtRequested) {
+ StorageManager sm = (StorageManager) mContext.getSystemService(
+ Context.STORAGE_SERVICE);
+ sm.wipeAdoptableDisks();
+ }
+ try {
+ RecoverySystem.rebootWipeUserData(mContext, reason);
+ } catch (IOException | SecurityException e) {
+ Slog.w(LOG_TAG, "Failed requesting data wipe", e);
}
}