Loading services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +20 −16 Original line number Diff line number Diff line Loading @@ -2203,7 +2203,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { } } void wipeDataLocked(int flags) { void wipeDataNoLock(int flags) { // If the SD card is encrypted and non-removable, we have to force a wipe. boolean forceExtWipe = !Environment.isExternalStorageRemovable() && isExtStorageEncrypted(); boolean wipeExtRequested = (flags&DevicePolicyManager.WIPE_EXTERNAL_STORAGE) != 0; Loading Loading @@ -2234,18 +2234,18 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { // so try to retrieve it to check that the caller is one. getActiveAdminForCallerLocked(null, DeviceAdminInfo.USES_POLICY_WIPE_DATA); } long ident = Binder.clearCallingIdentity(); try { wipeDeviceOrUserLocked(flags, userHandle); wipeDeviceNoLock(flags, userHandle); } finally { Binder.restoreCallingIdentity(ident); } } } private void wipeDeviceOrUserLocked(int flags, final int userHandle) { private void wipeDeviceNoLock(int flags, final int userHandle) { if (userHandle == UserHandle.USER_OWNER) { wipeDataLocked(flags); wipeDataNoLock(flags); } else { lockNowUnchecked(); mHandler.post(new Runnable() { Loading Loading @@ -2361,25 +2361,29 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { mContext.enforceCallingOrSelfPermission( android.Manifest.permission.BIND_DEVICE_ADMIN, null); synchronized (this) { DevicePolicyData policy = getUserData(userHandle); long ident = Binder.clearCallingIdentity(); try { boolean wipeData = false; synchronized (this) { DevicePolicyData policy = getUserData(userHandle); policy.mFailedPasswordAttempts++; saveSettingsLocked(userHandle); if (mHasFeature) { int max = getMaximumFailedPasswordsForWipe(null, userHandle); if (max > 0 && policy.mFailedPasswordAttempts >= max) { wipeDeviceOrUserLocked(0, userHandle); wipeData = true; } sendAdminCommandLocked(DeviceAdminReceiver.ACTION_PASSWORD_FAILED, DeviceAdminInfo.USES_POLICY_WATCH_LOGIN, userHandle); } } if (wipeData) { wipeDeviceNoLock(0, userHandle); } } finally { Binder.restoreCallingIdentity(ident); } } } public void reportSuccessfulPasswordAttempt(int userHandle) { enforceCrossUserPermission(userHandle); Loading Loading
services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +20 −16 Original line number Diff line number Diff line Loading @@ -2203,7 +2203,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { } } void wipeDataLocked(int flags) { void wipeDataNoLock(int flags) { // If the SD card is encrypted and non-removable, we have to force a wipe. boolean forceExtWipe = !Environment.isExternalStorageRemovable() && isExtStorageEncrypted(); boolean wipeExtRequested = (flags&DevicePolicyManager.WIPE_EXTERNAL_STORAGE) != 0; Loading Loading @@ -2234,18 +2234,18 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { // so try to retrieve it to check that the caller is one. getActiveAdminForCallerLocked(null, DeviceAdminInfo.USES_POLICY_WIPE_DATA); } long ident = Binder.clearCallingIdentity(); try { wipeDeviceOrUserLocked(flags, userHandle); wipeDeviceNoLock(flags, userHandle); } finally { Binder.restoreCallingIdentity(ident); } } } private void wipeDeviceOrUserLocked(int flags, final int userHandle) { private void wipeDeviceNoLock(int flags, final int userHandle) { if (userHandle == UserHandle.USER_OWNER) { wipeDataLocked(flags); wipeDataNoLock(flags); } else { lockNowUnchecked(); mHandler.post(new Runnable() { Loading Loading @@ -2361,25 +2361,29 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { mContext.enforceCallingOrSelfPermission( android.Manifest.permission.BIND_DEVICE_ADMIN, null); synchronized (this) { DevicePolicyData policy = getUserData(userHandle); long ident = Binder.clearCallingIdentity(); try { boolean wipeData = false; synchronized (this) { DevicePolicyData policy = getUserData(userHandle); policy.mFailedPasswordAttempts++; saveSettingsLocked(userHandle); if (mHasFeature) { int max = getMaximumFailedPasswordsForWipe(null, userHandle); if (max > 0 && policy.mFailedPasswordAttempts >= max) { wipeDeviceOrUserLocked(0, userHandle); wipeData = true; } sendAdminCommandLocked(DeviceAdminReceiver.ACTION_PASSWORD_FAILED, DeviceAdminInfo.USES_POLICY_WATCH_LOGIN, userHandle); } } if (wipeData) { wipeDeviceNoLock(0, userHandle); } } finally { Binder.restoreCallingIdentity(ident); } } } public void reportSuccessfulPasswordAttempt(int userHandle) { enforceCrossUserPermission(userHandle); Loading