diff --git a/core/java/android/content/pm/PackageManager.java b/core/java/android/content/pm/PackageManager.java index 8e64e367a7230..36d15a08cc2da 100644 --- a/core/java/android/content/pm/PackageManager.java +++ b/core/java/android/content/pm/PackageManager.java @@ -200,12 +200,6 @@ 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 this flag is set: * when resolving an intent that matches the {@link CrossProfileIntentFilter}, the current @@ -2440,7 +2434,6 @@ public abstract class PackageManager { * @see #MATCH_DEFAULT_ONLY * @see #GET_INTENT_FILTERS * @see #GET_RESOLVED_FILTER - * @see #NO_CROSS_PROFILE * @hide */ public abstract List queryIntentActivitiesAsUser(Intent intent, diff --git a/services/core/java/com/android/server/pm/LauncherAppsService.java b/services/core/java/com/android/server/pm/LauncherAppsService.java index b7b1c233e77d2..dcc4f8d18c361 100644 --- a/services/core/java/com/android/server/pm/LauncherAppsService.java +++ b/services/core/java/com/android/server/pm/LauncherAppsService.java @@ -199,8 +199,7 @@ public class LauncherAppsService extends SystemService { mainIntent.setPackage(packageName); long ident = Binder.clearCallingIdentity(); try { - List apps = mPm.queryIntentActivitiesAsUser(mainIntent, - PackageManager.NO_CROSS_PROFILE, // We only want the apps for this user + List apps = mPm.queryIntentActivitiesAsUser(mainIntent, 0 /* flags */, user.getIdentifier()); return apps; } finally { @@ -288,8 +287,7 @@ public class LauncherAppsService extends SystemService { // as calling startActivityAsUser ignores the category and just // resolves based on the component if present. List apps = mPm.queryIntentActivitiesAsUser(launchIntent, - PackageManager.NO_CROSS_PROFILE, // We only want the apps for this user - user.getIdentifier()); + 0 /* flags */, user.getIdentifier()); final int size = apps.size(); for (int i = 0; i < size; ++i) { ActivityInfo activityInfo = apps.get(i).activityInfo; diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java index 7b4270b2ec226..d1bc35b5b75b6 100644 --- a/services/core/java/com/android/server/pm/PackageManagerService.java +++ b/services/core/java/com/android/server/pm/PackageManagerService.java @@ -3240,32 +3240,31 @@ 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 = null; - if (queryCrossProfile) { - // Check if the intent needs to be forwarded to another user for this package - ArrayList crossProfileResult = - queryIntentActivitiesCrossProfilePackage( - intent, resolvedType, flags, userId); - if (!crossProfileResult.isEmpty()) { - // Skip the current profile - return crossProfileResult; - } - List matchingFilters = - getMatchingCrossProfileIntentFilters(intent, resolvedType, userId); - // Check for results that need to skip the current profile. - resolveInfo = querySkipCurrentProfileIntents(matchingFilters, intent, - resolvedType, flags, userId); - if (resolveInfo != null) { - List result = new ArrayList(1); - result.add(resolveInfo); - return result; - } - // Check for cross profile results. - resolveInfo = queryCrossProfileIntents( - matchingFilters, intent, resolvedType, flags, userId); + + // Check if the intent needs to be forwarded to another user for this package + ArrayList crossProfileResult = + queryIntentActivitiesCrossProfilePackage( + intent, resolvedType, flags, userId); + if (!crossProfileResult.isEmpty()) { + // Skip the current profile + return crossProfileResult; } + List matchingFilters = + getMatchingCrossProfileIntentFilters(intent, resolvedType, userId); + // Check for results that need to skip the current profile. + resolveInfo = querySkipCurrentProfileIntents(matchingFilters, intent, + resolvedType, flags, userId); + if (resolveInfo != null) { + List result = new ArrayList(1); + result.add(resolveInfo); + return result; + } + // Check for cross profile results. + resolveInfo = queryCrossProfileIntents( + matchingFilters, intent, resolvedType, flags, userId); + // Check for results in the current profile. List result = mActivities.queryIntent( intent, resolvedType, flags, userId); @@ -3277,14 +3276,12 @@ public class PackageManagerService extends IPackageManager.Stub { } final PackageParser.Package pkg = mPackages.get(pkgName); if (pkg != null) { - if (queryCrossProfile) { - ArrayList crossProfileResult = - queryIntentActivitiesCrossProfilePackage( - intent, resolvedType, flags, userId, pkg, pkgName); - if (!crossProfileResult.isEmpty()) { - // Skip the current profile - return crossProfileResult; - } + ArrayList crossProfileResult = + queryIntentActivitiesCrossProfilePackage( + intent, resolvedType, flags, userId, pkg, pkgName); + if (!crossProfileResult.isEmpty()) { + // Skip the current profile + return crossProfileResult; } return mActivities.queryIntentForPackage(intent, resolvedType, flags, pkg.activities, userId);