diff options
| author | 2011-10-19 10:31:42 -0700 | |
|---|---|---|
| committer | 2011-10-19 10:31:42 -0700 | |
| commit | 667580b716b36a8afbf8d910e14f0249eccd44c9 (patch) | |
| tree | 26fb5d7e68ba184282620ba26eccd92ad4cb2ba5 | |
| parent | e68a6936c7b3d3a041feeff9661b234a25e56e73 (diff) | |
| parent | 8408e5165a74ddee7d2d8698314cfda521fbfc76 (diff) | |
am 8408e516: Merge "Fix remote device wipe to not hang." into ics-mr0
* commit '8408e5165a74ddee7d2d8698314cfda521fbfc76':
Fix remote device wipe to not hang.
| -rw-r--r-- | services/java/com/android/server/DevicePolicyManagerService.java | 13 |
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); |