From f535cb04f08575d29118fab0342b1e6274091734 Mon Sep 17 00:00:00 2001 From: Masanori Ogino Date: Wed, 15 Feb 2012 19:25:50 +0900 Subject: [PATCH] Wipe the user data out in any case. When the external storage is not mounted, the android system won't wipe out the user data (i.e. "/data") if wipeData() is called with the flag WIPE_EXTERNAL_STORAGE. We think that the user data should be wiped out in any options and also wipeData(int) method currently supports also for a external storage. So we will also change the API reference comment. If we should care about backward compatibility of this method behavior with the option WIPE_EXTERNAL_STORAGE, then we would add an another bitmask something like a ALWAYS_RESET. Change-Id: Id7bf673c722bacc0480d32e46553b9a348513879 --- core/java/android/app/admin/DevicePolicyManager.java | 6 ++++-- .../java/com/android/server/DevicePolicyManagerService.java | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) mode change 100644 => 100755 core/java/android/app/admin/DevicePolicyManager.java diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java old mode 100644 new mode 100755 index c89396bc13e88..807bde5501f50 --- a/core/java/android/app/admin/DevicePolicyManager.java +++ b/core/java/android/app/admin/DevicePolicyManager.java @@ -1001,13 +1001,15 @@ public class DevicePolicyManager { /** * Ask the user date be wiped. This will cause the device to reboot, * erasing all user data while next booting up. External storage such - * as SD cards will not be erased. + * as SD cards will be also erased if the flag {@link #WIPE_EXTERNAL_STORAGE} + * is set. * *

The calling device admin must have requested * {@link DeviceAdminInfo#USES_POLICY_WIPE_DATA} to be able to call * this method; if it has not, a security exception will be thrown. * - * @param flags Bit mask of additional options: currently must be 0. + * @param flags Bit mask of additional options: currently 0 and + * {@link #WIPE_EXTERNAL_STORAGE} are supported. */ public void wipeData(int flags) { if (mService != null) { diff --git a/services/java/com/android/server/DevicePolicyManagerService.java b/services/java/com/android/server/DevicePolicyManagerService.java index 47644de158c73..03f73b73db0f2 100644 --- a/services/java/com/android/server/DevicePolicyManagerService.java +++ b/services/java/com/android/server/DevicePolicyManagerService.java @@ -1670,6 +1670,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { // 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.setComponent(ExternalStorageFormatter.COMPONENT_NAME); mWakeLock.acquire(10000); mContext.startService(intent);