Loading core/java/android/content/pm/PackageParser.java +6 −5 Original line number Diff line number Diff line Loading @@ -3082,6 +3082,12 @@ public class PackageParser { a.info.flags |= ActivityInfo.FLAG_IMMERSIVE; } if (sa.getBoolean( com.android.internal.R.styleable.AndroidManifestActivity_primaryUserOnly, false)) { a.info.flags |= ActivityInfo.FLAG_PRIMARY_USER_ONLY; } if (!receiver) { if (sa.getBoolean( com.android.internal.R.styleable.AndroidManifestActivity_hardwareAccelerated, Loading Loading @@ -3153,11 +3159,6 @@ public class PackageParser { setExported = true; } } if (sa.getBoolean( com.android.internal.R.styleable.AndroidManifestActivity_primaryUserOnly, false)) { a.info.flags |= ActivityInfo.FLAG_PRIMARY_USER_ONLY; } } sa.recycle(); Loading services/core/java/com/android/server/pm/PackageManagerService.java +25 −4 Original line number Diff line number Diff line Loading @@ -3381,7 +3381,7 @@ public class PackageManagerService extends IPackageManager.Stub { if (resolveInfo != null) { List<ResolveInfo> result = new ArrayList<ResolveInfo>(1); result.add(resolveInfo); return result; return filterIfNotPrimaryUser(result, userId); } // Check for cross profile results. resolveInfo = queryCrossProfileIntents( Loading @@ -3394,17 +3394,38 @@ public class PackageManagerService extends IPackageManager.Stub { result.add(resolveInfo); Collections.sort(result, mResolvePrioritySorter); } return result; return filterIfNotPrimaryUser(result, userId); } final PackageParser.Package pkg = mPackages.get(pkgName); if (pkg != null) { return mActivities.queryIntentForPackage(intent, resolvedType, flags, pkg.activities, userId); return filterIfNotPrimaryUser( mActivities.queryIntentForPackage( intent, resolvedType, flags, pkg.activities, userId), userId); } return new ArrayList<ResolveInfo>(); } } /** * Filter out activities with primaryUserOnly flag set, when current user is not the owner. * * @return filtered list */ private List<ResolveInfo> filterIfNotPrimaryUser(List<ResolveInfo> resolveInfos, int userId) { if (userId == UserHandle.USER_OWNER) { return resolveInfos; } for (int i = resolveInfos.size() - 1; i >= 0; i--) { ResolveInfo info = resolveInfos.get(i); if ((info.activityInfo.flags & ActivityInfo.FLAG_PRIMARY_USER_ONLY) != 0) { resolveInfos.remove(i); } } return resolveInfos; } private ResolveInfo querySkipCurrentProfileIntents( List<CrossProfileIntentFilter> matchingFilters, Intent intent, String resolvedType, int flags, int sourceUserId) { Loading Loading
core/java/android/content/pm/PackageParser.java +6 −5 Original line number Diff line number Diff line Loading @@ -3082,6 +3082,12 @@ public class PackageParser { a.info.flags |= ActivityInfo.FLAG_IMMERSIVE; } if (sa.getBoolean( com.android.internal.R.styleable.AndroidManifestActivity_primaryUserOnly, false)) { a.info.flags |= ActivityInfo.FLAG_PRIMARY_USER_ONLY; } if (!receiver) { if (sa.getBoolean( com.android.internal.R.styleable.AndroidManifestActivity_hardwareAccelerated, Loading Loading @@ -3153,11 +3159,6 @@ public class PackageParser { setExported = true; } } if (sa.getBoolean( com.android.internal.R.styleable.AndroidManifestActivity_primaryUserOnly, false)) { a.info.flags |= ActivityInfo.FLAG_PRIMARY_USER_ONLY; } } sa.recycle(); Loading
services/core/java/com/android/server/pm/PackageManagerService.java +25 −4 Original line number Diff line number Diff line Loading @@ -3381,7 +3381,7 @@ public class PackageManagerService extends IPackageManager.Stub { if (resolveInfo != null) { List<ResolveInfo> result = new ArrayList<ResolveInfo>(1); result.add(resolveInfo); return result; return filterIfNotPrimaryUser(result, userId); } // Check for cross profile results. resolveInfo = queryCrossProfileIntents( Loading @@ -3394,17 +3394,38 @@ public class PackageManagerService extends IPackageManager.Stub { result.add(resolveInfo); Collections.sort(result, mResolvePrioritySorter); } return result; return filterIfNotPrimaryUser(result, userId); } final PackageParser.Package pkg = mPackages.get(pkgName); if (pkg != null) { return mActivities.queryIntentForPackage(intent, resolvedType, flags, pkg.activities, userId); return filterIfNotPrimaryUser( mActivities.queryIntentForPackage( intent, resolvedType, flags, pkg.activities, userId), userId); } return new ArrayList<ResolveInfo>(); } } /** * Filter out activities with primaryUserOnly flag set, when current user is not the owner. * * @return filtered list */ private List<ResolveInfo> filterIfNotPrimaryUser(List<ResolveInfo> resolveInfos, int userId) { if (userId == UserHandle.USER_OWNER) { return resolveInfos; } for (int i = resolveInfos.size() - 1; i >= 0; i--) { ResolveInfo info = resolveInfos.get(i); if ((info.activityInfo.flags & ActivityInfo.FLAG_PRIMARY_USER_ONLY) != 0) { resolveInfos.remove(i); } } return resolveInfos; } private ResolveInfo querySkipCurrentProfileIntents( List<CrossProfileIntentFilter> matchingFilters, Intent intent, String resolvedType, int flags, int sourceUserId) { Loading