Merge "DO NOT MERGE Do not call RecoverySystem with DPMS lock held" into lmp-mr1-dev

This commit is contained in:
Suprabh Shukla
2017-02-02 22:23:08 +00:00
committed by Android (Google) Code Review

View File

@@ -2980,7 +2980,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
return false; return false;
} }
private void wipeDataLocked(boolean wipeExtRequested, String reason) { private void wipeDataNoLock(boolean wipeExtRequested, String reason) {
// 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();
@@ -3007,13 +3007,13 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
return; return;
} }
enforceCrossUserPermission(userHandle); enforceCrossUserPermission(userHandle);
final String source;
synchronized (this) { synchronized (this) {
// This API can only be called by an active device admin, // This API can only be called by an active device admin,
// so try to retrieve it to check that the caller is one. // so try to retrieve it to check that the caller is one.
final ActiveAdmin admin = getActiveAdminForCallerLocked(null, final ActiveAdmin admin = getActiveAdminForCallerLocked(null,
DeviceAdminInfo.USES_POLICY_WIPE_DATA); DeviceAdminInfo.USES_POLICY_WIPE_DATA);
final String source;
final ComponentName cname = admin.info.getComponent(); final ComponentName cname = admin.info.getComponent();
if (cname != null) { if (cname != null) {
source = cname.flattenToShortString(); source = cname.flattenToShortString();
@@ -3035,18 +3035,20 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
manager.wipe(); manager.wipe();
} }
} }
boolean wipeExtRequested = (flags & WIPE_EXTERNAL_STORAGE) != 0;
wipeDeviceOrUserLocked(wipeExtRequested, userHandle,
"DevicePolicyManager.wipeData() from " + source);
} finally { } finally {
Binder.restoreCallingIdentity(ident); Binder.restoreCallingIdentity(ident);
} }
} }
boolean wipeExtRequested = (flags & WIPE_EXTERNAL_STORAGE) != 0;
wipeDeviceNoLock(wipeExtRequested, userHandle,
"DevicePolicyManager.wipeData() from " + source);
} }
private void wipeDeviceOrUserLocked(boolean wipeExtRequested, final int userHandle, String reason) { private void wipeDeviceNoLock(boolean wipeExtRequested, final int userHandle, String reason) {
final long iden = Binder.clearCallingIdentity();
try {
if (userHandle == UserHandle.USER_OWNER) { if (userHandle == UserHandle.USER_OWNER) {
wipeDataLocked(wipeExtRequested, reason); wipeDataNoLock(wipeExtRequested, reason);
} else { } else {
mHandler.post(new Runnable() { mHandler.post(new Runnable() {
public void run() { public void run() {
@@ -3064,6 +3066,9 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
} }
}); });
} }
} finally {
Binder.restoreCallingIdentity(iden);
}
} }
public void getRemoveWarning(ComponentName comp, final RemoteCallback result, int userHandle) { public void getRemoveWarning(ComponentName comp, final RemoteCallback result, int userHandle) {
@@ -3201,7 +3206,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
} }
if (wipeData) { if (wipeData) {
// Call without holding lock. // Call without holding lock.
wipeDeviceOrUserLocked(false, identifier, wipeDeviceNoLock(false, identifier,
"reportFailedPasswordAttempt()"); "reportFailedPasswordAttempt()");
} }
} finally { } finally {