diff options
| author | 2014-09-26 16:36:42 +0000 | |
|---|---|---|
| committer | 2014-09-26 16:36:43 +0000 | |
| commit | a2b48057e1a15bc9e88a764cad16cda784dc4c04 (patch) | |
| tree | c8e7da11fefed33c12a45c0806f3f25cbc4f8c87 | |
| parent | 2b731e7b7cfaa146260607ae0b223cb3aef5d270 (diff) | |
| parent | 5dde6e334d06e5c2116b2169d7ad67e95238a6f0 (diff) | |
Merge "Uninstall for all users should check device admins." into lmp-dev
| -rw-r--r-- | services/core/java/com/android/server/pm/PackageManagerService.java | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java index a61d62180e14..271843904191 100644 --- a/services/core/java/com/android/server/pm/PackageManagerService.java +++ b/services/core/java/com/android/server/pm/PackageManagerService.java @@ -10444,9 +10444,21 @@ public class PackageManagerService extends IPackageManager.Stub { IDevicePolicyManager dpm = IDevicePolicyManager.Stub.asInterface( ServiceManager.getService(Context.DEVICE_POLICY_SERVICE)); try { - if (dpm != null && (dpm.packageHasActiveAdmins(packageName, userId) - || dpm.isDeviceOwner(packageName))) { - return true; + if (dpm != null) { + if (dpm.isDeviceOwner(packageName)) { + return true; + } + int[] users; + if (userId == UserHandle.USER_ALL) { + users = sUserManager.getUserIds(); + } else { + users = new int[]{userId}; + } + for (int i = 0; i < users.length; ++i) { + if (dpm.packageHasActiveAdmins(packageName, users[i])) { + return true; + } + } } } catch (RemoteException e) { } @@ -10471,7 +10483,10 @@ public class PackageManagerService extends IPackageManager.Stub { final PackageRemovedInfo info = new PackageRemovedInfo(); final boolean res; - if (isPackageDeviceAdmin(packageName, userId)) { + final UserHandle removeForUser = (flags & PackageManager.DELETE_ALL_USERS) != 0 + ? UserHandle.ALL : new UserHandle(userId); + + if (isPackageDeviceAdmin(packageName, removeForUser.getIdentifier())) { Slog.w(TAG, "Not removing package " + packageName + ": has active device admin"); return PackageManager.DELETE_FAILED_DEVICE_POLICY_MANAGER; } @@ -10494,9 +10509,7 @@ public class PackageManagerService extends IPackageManager.Stub { synchronized (mInstallLock) { if (DEBUG_REMOVE) Slog.d(TAG, "deletePackageX: pkg=" + packageName + " user=" + userId); - res = deletePackageLI(packageName, - (flags & PackageManager.DELETE_ALL_USERS) != 0 - ? UserHandle.ALL : new UserHandle(userId), + res = deletePackageLI(packageName, removeForUser, true, allUsers, perUserInstalled, flags | REMOVE_CHATTY, info, true); systemUpdate = info.isRemovedPackageSystemUpdate; |