File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed
services/java/com/android/server Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change 4444import android .content .pm .PackageManager .NameNotFoundException ;
4545import android .content .pm .ResolveInfo ;
4646import android .os .Binder ;
47+ import android .os .Environment ;
4748import android .os .Handler ;
4849import android .os .IBinder ;
4950import 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 );
You can’t perform that action at this time.
0 commit comments