DO NOT MERGE Do not call RecoverySystem with DPMS lock held am: 8cdc04957a

am: 21992d997b

Change-Id: Ib5ba5eb63227be2fbf25a79e7f8f8e42b1cc9a2b
This commit is contained in:
Suprabh Shukla
2017-02-02 22:36:03 +00:00
committed by android-build-merger

View File

@@ -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. // If the SD card is encrypted and non-removable, we have to force a wipe.
boolean forceExtWipe = !Environment.isExternalStorageRemovable() && isExtStorageEncrypted(); boolean forceExtWipe = !Environment.isExternalStorageRemovable() && isExtStorageEncrypted();
boolean wipeExtRequested = (flags&DevicePolicyManager.WIPE_EXTERNAL_STORAGE) != 0; boolean wipeExtRequested = (flags&DevicePolicyManager.WIPE_EXTERNAL_STORAGE) != 0;
@@ -2234,18 +2234,18 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
// so try to retrieve it to check that the caller is one. // so try to retrieve it to check that the caller is one.
getActiveAdminForCallerLocked(null, getActiveAdminForCallerLocked(null,
DeviceAdminInfo.USES_POLICY_WIPE_DATA); DeviceAdminInfo.USES_POLICY_WIPE_DATA);
long ident = Binder.clearCallingIdentity(); }
try { long ident = Binder.clearCallingIdentity();
wipeDeviceOrUserLocked(flags, userHandle); try {
} finally { wipeDeviceNoLock(flags, userHandle);
Binder.restoreCallingIdentity(ident); } 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) { if (userHandle == UserHandle.USER_OWNER) {
wipeDataLocked(flags); wipeDataNoLock(flags);
} else { } else {
lockNowUnchecked(); lockNowUnchecked();
mHandler.post(new Runnable() { mHandler.post(new Runnable() {
@@ -2361,23 +2361,27 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
mContext.enforceCallingOrSelfPermission( mContext.enforceCallingOrSelfPermission(
android.Manifest.permission.BIND_DEVICE_ADMIN, null); android.Manifest.permission.BIND_DEVICE_ADMIN, null);
synchronized (this) { long ident = Binder.clearCallingIdentity();
DevicePolicyData policy = getUserData(userHandle); try {
long ident = Binder.clearCallingIdentity(); boolean wipeData = false;
try { synchronized (this) {
DevicePolicyData policy = getUserData(userHandle);
policy.mFailedPasswordAttempts++; policy.mFailedPasswordAttempts++;
saveSettingsLocked(userHandle); saveSettingsLocked(userHandle);
if (mHasFeature) { if (mHasFeature) {
int max = getMaximumFailedPasswordsForWipe(null, userHandle); int max = getMaximumFailedPasswordsForWipe(null, userHandle);
if (max > 0 && policy.mFailedPasswordAttempts >= max) { if (max > 0 && policy.mFailedPasswordAttempts >= max) {
wipeDeviceOrUserLocked(0, userHandle); wipeData = true;
} }
sendAdminCommandLocked(DeviceAdminReceiver.ACTION_PASSWORD_FAILED, sendAdminCommandLocked(DeviceAdminReceiver.ACTION_PASSWORD_FAILED,
DeviceAdminInfo.USES_POLICY_WATCH_LOGIN, userHandle); DeviceAdminInfo.USES_POLICY_WATCH_LOGIN, userHandle);
} }
} finally {
Binder.restoreCallingIdentity(ident);
} }
if (wipeData) {
wipeDeviceNoLock(0, userHandle);
}
} finally {
Binder.restoreCallingIdentity(ident);
} }
} }