Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fa4533f3 authored by Alexandra Gherghina's avatar Alexandra Gherghina
Browse files

Skip forwarding launcher intents

If we forward intents when looking up launcher icons, we end up
having an icon for a disambig activity instead of the apps for that user.

Bug: 15769854
Change-Id: Ia57525466dba57b6669b2b5cedf98f202d08f586
parent 775a159e
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -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.
@@ -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,
+2 −1
Original line number Diff line number Diff line
@@ -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 {
+34 −28
Original line number Diff line number Diff line
@@ -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(
@@ -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);
                }
@@ -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);
@@ -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);
            }