summaryrefslogtreecommitdiffstats
path: root/services/devicepolicy
diff options
context:
space:
mode:
authorJessica Hummel <jhummel@google.com>2014-09-16 11:56:50 +0100
committerJessica Hummel <jhummel@google.com>2014-09-19 09:56:19 +0000
commitdd31a10c7f194d70411c8fb8ca8c0ab6751dccb2 (patch)
tree86db4d462c3a906a865fec895483da6ff8508968 /services/devicepolicy
parent52ee328054eeafa4f1503073813d0b52e9e3e87d (diff)
downloadframeworks_base-dd31a10c7f194d70411c8fb8ca8c0ab6751dccb2.zip
frameworks_base-dd31a10c7f194d70411c8fb8ca8c0ab6751dccb2.tar.gz
frameworks_base-dd31a10c7f194d70411c8fb8ca8c0ab6751dccb2.tar.bz2
bug fix: Allow enableSystemApps to be called by profile and device owner.
We had an additional check for managed profile in there, so it wasn't working for device owners. Also needed to look at uninstalled packages. Change-Id: I4813f23b00d7905e92ade582ce082a6f295a322d Bug: 17384318
Diffstat (limited to 'services/devicepolicy')
-rw-r--r--services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java28
1 files changed, 15 insertions, 13 deletions
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
index 95332bc..60ed93a 100644
--- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
+++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
@@ -17,6 +17,7 @@
package com.android.server.devicepolicy;
import static android.Manifest.permission.MANAGE_CA_CERTIFICATES;
+import static android.content.pm.PackageManager.GET_UNINSTALLED_PACKAGES;
import android.accessibilityservice.AccessibilityServiceInfo;
import android.accounts.AccountManager;
@@ -4801,17 +4802,17 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
long id = Binder.clearCallingIdentity();
try {
- UserManager um = UserManager.get(mContext);
- if (!um.getUserInfo(userId).isManagedProfile()) {
- throw new IllegalStateException(
- "Only call this method from a managed profile.");
+ if (DBG) {
+ Slog.v(LOG_TAG, "installing " + packageName + " for "
+ + userId);
}
+ UserManager um = UserManager.get(mContext);
UserInfo primaryUser = um.getProfileParent(userId);
- if (DBG) {
- Slog.v(LOG_TAG, "installing " + packageName + " for "
- + userId);
+ // Call did not come from a managed profile
+ if (primaryUser == null) {
+ primaryUser = um.getUserInfo(userId);
}
IPackageManager pm = AppGlobals.getPackageManager();
@@ -4847,13 +4848,13 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
try {
UserManager um = UserManager.get(mContext);
- if (!um.getUserInfo(userId).isManagedProfile()) {
- throw new IllegalStateException(
- "Only call this method from a managed profile.");
- }
-
UserInfo primaryUser = um.getProfileParent(userId);
+ // Call did not come from a managed profile.
+ if (primaryUser == null) {
+ primaryUser = um.getUserInfo(userId);
+ }
+
IPackageManager pm = AppGlobals.getPackageManager();
List<ResolveInfo> activitiesToEnable = pm.queryIntentActivities(intent,
intent.resolveTypeIfNeeded(mContext.getContentResolver()),
@@ -4890,7 +4891,8 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
private boolean isSystemApp(IPackageManager pm, String packageName, int userId)
throws RemoteException {
- ApplicationInfo appInfo = pm.getApplicationInfo(packageName, 0, userId);
+ ApplicationInfo appInfo = pm.getApplicationInfo(packageName, GET_UNINSTALLED_PACKAGES,
+ userId);
return (appInfo.flags & ApplicationInfo.FLAG_SYSTEM) > 0;
}