summaryrefslogtreecommitdiffstats
path: root/services/devicepolicy/java
diff options
context:
space:
mode:
authorWolfgang Wiedmeyer <wolfgit@wiedmeyer.de>2017-05-02 19:22:30 +0200
committerWolfgang Wiedmeyer <wolfgit@wiedmeyer.de>2017-05-02 19:22:30 +0200
commita0ce80942766948d4cd1036b97e2ee721ed8ecce (patch)
tree5d596eea5771aa9f494d2b1fcf6b3b44da2d401c /services/devicepolicy/java
parenta3f7b1e4871de0b508bbefb0236d258d47a38f15 (diff)
parent0e4f9e2f03e376f0816c1e653bf97fe1d0176794 (diff)
downloadframeworks_base-replicant-6.0.zip
frameworks_base-replicant-6.0.tar.gz
frameworks_base-replicant-6.0.tar.bz2
Merge branch 'cm-13.0' of https://github.com/LineageOS/android_frameworks_base into replicant-6.0HEADreplicant-6.0-0001replicant-6.0
Diffstat (limited to 'services/devicepolicy/java')
-rw-r--r--services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java60
1 files changed, 33 insertions, 27 deletions
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
index 302d23a..911862e 100644
--- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
+++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
@@ -3322,7 +3322,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
}
}
- private void wipeDataLocked(boolean wipeExtRequested, String reason) {
+ private void wipeDataNoLock(boolean wipeExtRequested, String reason) {
if (wipeExtRequested) {
StorageManager sm = (StorageManager) mContext.getSystemService(
Context.STORAGE_SERVICE);
@@ -3341,13 +3341,14 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
return;
}
enforceCrossUserPermission(userHandle);
+
+ final String source;
synchronized (this) {
// This API can only be called by an active device admin,
// so try to retrieve it to check that the caller is one.
final ActiveAdmin admin = getActiveAdminForCallerLocked(null,
DeviceAdminInfo.USES_POLICY_WIPE_DATA);
- final String source;
final ComponentName cname = admin.info.getComponent();
if (cname != null) {
source = cname.flattenToShortString();
@@ -3372,39 +3373,44 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
manager.wipe();
}
}
- boolean wipeExtRequested = (flags & WIPE_EXTERNAL_STORAGE) != 0;
- wipeDeviceOrUserLocked(wipeExtRequested, userHandle,
- "DevicePolicyManager.wipeData() from " + source);
} finally {
Binder.restoreCallingIdentity(ident);
}
}
+ final boolean wipeExtRequested = (flags & WIPE_EXTERNAL_STORAGE) != 0;
+ wipeDeviceNoLock(wipeExtRequested, userHandle,
+ "DevicePolicyManager.wipeData() from " + source);
}
- private void wipeDeviceOrUserLocked(boolean wipeExtRequested, final int userHandle, String reason) {
- if (userHandle == UserHandle.USER_OWNER) {
- wipeDataLocked(wipeExtRequested, reason);
- } else {
- mHandler.post(new Runnable() {
- @Override
- public void run() {
- try {
- IActivityManager am = ActivityManagerNative.getDefault();
- if (am.getCurrentUser().id == userHandle) {
- am.switchUser(UserHandle.USER_OWNER);
- }
+ private void wipeDeviceNoLock(boolean wipeExtRequested, final int userHandle, String reason) {
+ final long ident = Binder.clearCallingIdentity();
+ try {
+ if (userHandle == UserHandle.USER_OWNER) {
+ wipeDataNoLock(wipeExtRequested, reason);
+ } else {
+ mHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ IActivityManager am = ActivityManagerNative.getDefault();
+ if (am.getCurrentUser().id == userHandle) {
+ am.switchUser(UserHandle.USER_OWNER);
+ }
- boolean isManagedProfile = isManagedProfile(userHandle);
- if (!mUserManager.removeUser(userHandle)) {
- Slog.w(LOG_TAG, "Couldn't remove user " + userHandle);
- } else if (isManagedProfile) {
- sendWipeProfileNotification();
+ boolean isManagedProfile = isManagedProfile(userHandle);
+ if (!mUserManager.removeUser(userHandle)) {
+ Slog.w(LOG_TAG, "Couldn't remove user " + userHandle);
+ } else if (isManagedProfile) {
+ sendWipeProfileNotification();
+ }
+ } catch (RemoteException re) {
+ // Shouldn't happen
}
- } catch (RemoteException re) {
- // Shouldn't happen
}
- }
- });
+ });
+ }
+ } finally {
+ Binder.restoreCallingIdentity(ident);
}
}
@@ -3562,7 +3568,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
}
if (wipeData) {
// Call without holding lock.
- wipeDeviceOrUserLocked(false, identifier,
+ wipeDeviceNoLock(false, identifier,
"reportFailedPasswordAttempt()");
}
} finally {