Skip to content

Commit ed48c8b

Browse files
author
Ben Komalo
committed
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
1 parent f129988 commit ed48c8b

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

services/java/com/android/server/DevicePolicyManagerService.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
import android.content.pm.PackageManager.NameNotFoundException;
4545
import android.content.pm.ResolveInfo;
4646
import android.os.Binder;
47+
import android.os.Environment;
4748
import android.os.Handler;
4849
import android.os.IBinder;
4950
import android.os.IPowerManager;
@@ -1656,8 +1657,18 @@ public void lockNow() {
16561657
}
16571658
}
16581659

1660+
private boolean isExtStorageEncrypted() {
1661+
String state = SystemProperties.get("vold.decrypt");
1662+
return !"".equals(state);
1663+
}
1664+
16591665
void wipeDataLocked(int flags) {
1660-
if ((flags&DevicePolicyManager.WIPE_EXTERNAL_STORAGE) != 0) {
1666+
// If the SD card is encrypted and non-removable, we have to force a wipe.
1667+
boolean forceExtWipe = !Environment.isExternalStorageRemovable() && isExtStorageEncrypted();
1668+
boolean wipeExtRequested = (flags&DevicePolicyManager.WIPE_EXTERNAL_STORAGE) != 0;
1669+
1670+
// Note: we can only do the wipe via ExternalStorageFormatter if the volume is not emulated.
1671+
if ((forceExtWipe || wipeExtRequested) && !Environment.isExternalStorageEmulated()) {
16611672
Intent intent = new Intent(ExternalStorageFormatter.FORMAT_AND_FACTORY_RESET);
16621673
intent.setComponent(ExternalStorageFormatter.COMPONENT_NAME);
16631674
mWakeLock.acquire(10000);

0 commit comments

Comments
 (0)