Skip to content

Commit 8408e51

Browse files
Ben KomaloAndroid (Google) Code Review
authored andcommitted
Merge "Fix remote device wipe to not hang." into ics-mr0
2 parents 70ac412 + ed48c8b commit 8408e51

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)