summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Ben Komalo <benkomalo@google.com> 2011-10-17 17:30:21 -0700
committer Ben Komalo <benkomalo@google.com> 2011-10-18 10:13:34 -0700
commited48c8b4f50e060add50ad72a8d7af2fa547885b (patch)
treeecf9d7ff3fd0d5c1121317364bb916771aca4620
parentf129988a1aa8a210dc125b0f427d848a2aeb8bb2 (diff)
Fix remote device wipe to not hang.
The DPM seemed to always go through ExternalStorageFormatter to wipe the device and SD card. For SD cards emulated on a fuse filesystem, this seems to fail unless the device is wholly encrypted. Bypass ExternalStorageFormatter in those cases and just wipe as normal. Bug: 5458396 Change-Id: Iec759ef894c6bd3863cb4e7329f4de4584c60c1a
-rw-r--r--services/java/com/android/server/DevicePolicyManagerService.java13
1 files changed, 12 insertions, 1 deletions
diff --git a/services/java/com/android/server/DevicePolicyManagerService.java b/services/java/com/android/server/DevicePolicyManagerService.java
index f1b8bae47fcb..47644de158c7 100644
--- a/services/java/com/android/server/DevicePolicyManagerService.java
+++ b/services/java/com/android/server/DevicePolicyManagerService.java
@@ -44,6 +44,7 @@ import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.ResolveInfo;
import android.os.Binder;
+import android.os.Environment;
import android.os.Handler;
import android.os.IBinder;
import android.os.IPowerManager;
@@ -1656,8 +1657,18 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
}
}
+ private boolean isExtStorageEncrypted() {
+ String state = SystemProperties.get("vold.decrypt");
+ return !"".equals(state);
+ }
+
void wipeDataLocked(int flags) {
- if ((flags&DevicePolicyManager.WIPE_EXTERNAL_STORAGE) != 0) {
+ // If the SD card is encrypted and non-removable, we have to force a wipe.
+ boolean forceExtWipe = !Environment.isExternalStorageRemovable() && isExtStorageEncrypted();
+ boolean wipeExtRequested = (flags&DevicePolicyManager.WIPE_EXTERNAL_STORAGE) != 0;
+
+ // 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.setComponent(ExternalStorageFormatter.COMPONENT_NAME);
mWakeLock.acquire(10000);