Loading core/java/android/content/pm/PackageManager.java +7 −0 Original line number Diff line number Diff line Loading @@ -197,6 +197,12 @@ public abstract class PackageManager { */ public static final int MATCH_DEFAULT_ONLY = 0x00010000; /** * Resolution and querying flag: do not resolve intents cross-profile. * @hide */ public static final int NO_CROSS_PROFILE = 0x00020000; /** * Flag for {@link addCrossProfileIntentFilter}: if the cross-profile intent has been set by the * profile owner. Loading Loading @@ -2310,6 +2316,7 @@ public abstract class PackageManager { * @see #MATCH_DEFAULT_ONLY * @see #GET_INTENT_FILTERS * @see #GET_RESOLVED_FILTER * @see #NO_CROSS_PROFILE * @hide */ public abstract List<ResolveInfo> queryIntentActivitiesAsUser(Intent intent, Loading services/core/java/com/android/server/pm/LauncherAppsService.java +2 −1 Original line number Diff line number Diff line Loading @@ -197,7 +197,8 @@ public class LauncherAppsService extends SystemService { mainIntent.setPackage(packageName); long ident = Binder.clearCallingIdentity(); try { List<ResolveInfo> apps = mPm.queryIntentActivitiesAsUser(mainIntent, 0, List<ResolveInfo> apps = mPm.queryIntentActivitiesAsUser(mainIntent, PackageManager.NO_CROSS_PROFILE, // We only want the apps for this user user.getIdentifier()); return apps; } finally { Loading services/core/java/com/android/server/pm/PackageManagerService.java +34 −28 Original line number Diff line number Diff line Loading @@ -3425,7 +3425,10 @@ public class PackageManagerService extends IPackageManager.Stub { // reader synchronized (mPackages) { final String pkgName = intent.getPackage(); boolean queryCrossProfile = (flags & PackageManager.NO_CROSS_PROFILE) == 0; if (pkgName == null) { ResolveInfo resolveInfo; if (queryCrossProfile) { // Check if the intent needs to be forwarded to another user for this package ArrayList<ResolveInfo> crossProfileResult = queryIntentActivitiesCrossProfilePackage( Loading @@ -3434,22 +3437,23 @@ public class PackageManagerService extends IPackageManager.Stub { // Skip the current profile return crossProfileResult; } List<ResolveInfo> result; List<CrossProfileIntentFilter> matchingFilters = getMatchingCrossProfileIntentFilters(intent, resolvedType, userId); // Check for results that need to skip the current profile. ResolveInfo resolveInfo = querySkipCurrentProfileIntents(matchingFilters, intent, resolveInfo = querySkipCurrentProfileIntents(matchingFilters, intent, resolvedType, flags, userId); if (resolveInfo != null) { result = new ArrayList<ResolveInfo>(1); List<ResolveInfo> result = new ArrayList<ResolveInfo>(1); result.add(resolveInfo); return result; } // Check for results in the current profile. result = mActivities.queryIntent(intent, resolvedType, flags, 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) { result.add(resolveInfo); } Loading @@ -3457,6 +3461,7 @@ public class PackageManagerService extends IPackageManager.Stub { } final PackageParser.Package pkg = mPackages.get(pkgName); if (pkg != null) { if (queryCrossProfile) { ArrayList<ResolveInfo> crossProfileResult = queryIntentActivitiesCrossProfilePackage( intent, resolvedType, flags, userId, pkg, pkgName); Loading @@ -3464,6 +3469,7 @@ public class PackageManagerService extends IPackageManager.Stub { // Skip the current profile return crossProfileResult; } } return mActivities.queryIntentForPackage(intent, resolvedType, flags, pkg.activities, userId); } Loading Loading
core/java/android/content/pm/PackageManager.java +7 −0 Original line number Diff line number Diff line Loading @@ -197,6 +197,12 @@ public abstract class PackageManager { */ public static final int MATCH_DEFAULT_ONLY = 0x00010000; /** * Resolution and querying flag: do not resolve intents cross-profile. * @hide */ public static final int NO_CROSS_PROFILE = 0x00020000; /** * Flag for {@link addCrossProfileIntentFilter}: if the cross-profile intent has been set by the * profile owner. Loading Loading @@ -2310,6 +2316,7 @@ public abstract class PackageManager { * @see #MATCH_DEFAULT_ONLY * @see #GET_INTENT_FILTERS * @see #GET_RESOLVED_FILTER * @see #NO_CROSS_PROFILE * @hide */ public abstract List<ResolveInfo> queryIntentActivitiesAsUser(Intent intent, Loading
services/core/java/com/android/server/pm/LauncherAppsService.java +2 −1 Original line number Diff line number Diff line Loading @@ -197,7 +197,8 @@ public class LauncherAppsService extends SystemService { mainIntent.setPackage(packageName); long ident = Binder.clearCallingIdentity(); try { List<ResolveInfo> apps = mPm.queryIntentActivitiesAsUser(mainIntent, 0, List<ResolveInfo> apps = mPm.queryIntentActivitiesAsUser(mainIntent, PackageManager.NO_CROSS_PROFILE, // We only want the apps for this user user.getIdentifier()); return apps; } finally { Loading
services/core/java/com/android/server/pm/PackageManagerService.java +34 −28 Original line number Diff line number Diff line Loading @@ -3425,7 +3425,10 @@ public class PackageManagerService extends IPackageManager.Stub { // reader synchronized (mPackages) { final String pkgName = intent.getPackage(); boolean queryCrossProfile = (flags & PackageManager.NO_CROSS_PROFILE) == 0; if (pkgName == null) { ResolveInfo resolveInfo; if (queryCrossProfile) { // Check if the intent needs to be forwarded to another user for this package ArrayList<ResolveInfo> crossProfileResult = queryIntentActivitiesCrossProfilePackage( Loading @@ -3434,22 +3437,23 @@ public class PackageManagerService extends IPackageManager.Stub { // Skip the current profile return crossProfileResult; } List<ResolveInfo> result; List<CrossProfileIntentFilter> matchingFilters = getMatchingCrossProfileIntentFilters(intent, resolvedType, userId); // Check for results that need to skip the current profile. ResolveInfo resolveInfo = querySkipCurrentProfileIntents(matchingFilters, intent, resolveInfo = querySkipCurrentProfileIntents(matchingFilters, intent, resolvedType, flags, userId); if (resolveInfo != null) { result = new ArrayList<ResolveInfo>(1); List<ResolveInfo> result = new ArrayList<ResolveInfo>(1); result.add(resolveInfo); return result; } // Check for results in the current profile. result = mActivities.queryIntent(intent, resolvedType, flags, 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) { result.add(resolveInfo); } Loading @@ -3457,6 +3461,7 @@ public class PackageManagerService extends IPackageManager.Stub { } final PackageParser.Package pkg = mPackages.get(pkgName); if (pkg != null) { if (queryCrossProfile) { ArrayList<ResolveInfo> crossProfileResult = queryIntentActivitiesCrossProfilePackage( intent, resolvedType, flags, userId, pkg, pkgName); Loading @@ -3464,6 +3469,7 @@ public class PackageManagerService extends IPackageManager.Stub { // Skip the current profile return crossProfileResult; } } return mActivities.queryIntentForPackage(intent, resolvedType, flags, pkg.activities, userId); } Loading