diff options
author | Nicolas Prevot <nprevot@google.com> | 2015-04-23 17:11:47 +0100 |
---|---|---|
committer | Nicolas Prévot <nprevot@google.com> | 2015-04-29 11:10:19 +0000 |
commit | 1c4a44e577c7b8316172d1bf5357d006776ae75e (patch) | |
tree | 2ebf2513ba8f79ce7b00b63a80a9d73aaefdf9c7 /services | |
parent | c4aa3c781a0ddce64853cd5d88bf97f8a9faf98b (diff) | |
download | frameworks_base-1c4a44e577c7b8316172d1bf5357d006776ae75e.zip frameworks_base-1c4a44e577c7b8316172d1bf5357d006776ae75e.tar.gz frameworks_base-1c4a44e577c7b8316172d1bf5357d006776ae75e.tar.bz2 |
Do not return cross-profile intent results to a non-enabled user.
In PackageManagerService.queryIntentActivities, do not return
ResolveInfos targeting a user which is not enabled.
BUG:19578138
Change-Id: Id4e730ca8671c26f8cf077bc9c66b3dbd37be482
Diffstat (limited to 'services')
-rw-r--r-- | services/core/java/com/android/server/pm/PackageManagerService.java | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java index 26f8f70..8a19056 100644 --- a/services/core/java/com/android/server/pm/PackageManagerService.java +++ b/services/core/java/com/android/server/pm/PackageManagerService.java @@ -3929,19 +3929,20 @@ public class PackageManagerService extends IPackageManager.Stub { // Check for results that need to skip the current profile. ResolveInfo resolveInfo = querySkipCurrentProfileIntents(matchingFilters, intent, resolvedType, flags, userId); - if (resolveInfo != null) { + if (resolveInfo != null && isUserEnabled(resolveInfo.targetUserId)) { List<ResolveInfo> result = new ArrayList<ResolveInfo>(1); result.add(resolveInfo); return filterIfNotPrimaryUser(result, userId); } - // Check for cross profile results. - resolveInfo = queryCrossProfileIntents( - matchingFilters, intent, resolvedType, flags, userId); // Check for results in the current profile. List<ResolveInfo> result = mActivities.queryIntent( intent, resolvedType, flags, userId); - if (resolveInfo != null) { + + // Check for cross profile results. + resolveInfo = queryCrossProfileIntents( + matchingFilters, intent, resolvedType, flags, userId); + if (resolveInfo != null && isUserEnabled(resolveInfo.targetUserId)) { result.add(resolveInfo); Collections.sort(result, mResolvePrioritySorter); } @@ -3962,6 +3963,16 @@ public class PackageManagerService extends IPackageManager.Stub { } } + private boolean isUserEnabled(int userId) { + long callingId = Binder.clearCallingIdentity(); + try { + UserInfo userInfo = sUserManager.getUserInfo(userId); + return userInfo != null && userInfo.isEnabled(); + } finally { + Binder.restoreCallingIdentity(callingId); + } + } + /** * Filter out activities with primaryUserOnly flag set, when current user is not the owner. * |