Skip to content

Commit f535cb0

Browse files
committed
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
1 parent 472512f commit f535cb0

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

core/java/android/app/admin/DevicePolicyManager.java

100644100755
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,13 +1001,15 @@ public void lockNow() {
10011001
/**
10021002
* Ask the user date be wiped. This will cause the device to reboot,
10031003
* erasing all user data while next booting up. External storage such
1004-
* as SD cards will not be erased.
1004+
* as SD cards will be also erased if the flag {@link #WIPE_EXTERNAL_STORAGE}
1005+
* is set.
10051006
*
10061007
* <p>The calling device admin must have requested
10071008
* {@link DeviceAdminInfo#USES_POLICY_WIPE_DATA} to be able to call
10081009
* this method; if it has not, a security exception will be thrown.
10091010
*
1010-
* @param flags Bit mask of additional options: currently must be 0.
1011+
* @param flags Bit mask of additional options: currently 0 and
1012+
* {@link #WIPE_EXTERNAL_STORAGE} are supported.
10111013
*/
10121014
public void wipeData(int flags) {
10131015
if (mService != null) {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1670,6 +1670,7 @@ void wipeDataLocked(int flags) {
16701670
// Note: we can only do the wipe via ExternalStorageFormatter if the volume is not emulated.
16711671
if ((forceExtWipe || wipeExtRequested) && !Environment.isExternalStorageEmulated()) {
16721672
Intent intent = new Intent(ExternalStorageFormatter.FORMAT_AND_FACTORY_RESET);
1673+
intent.putExtra(ExternalStorageFormatter.EXTRA_ALWAYS_RESET, true);
16731674
intent.setComponent(ExternalStorageFormatter.COMPONENT_NAME);
16741675
mWakeLock.acquire(10000);
16751676
mContext.startService(intent);

0 commit comments

Comments
 (0)