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

Commit 46ef3540 authored by Matt Garnes's avatar Matt Garnes
Browse files

Fix intent resolution of default preferred apps.

If more than one third party app matches the Intent specified in the
file that defines the default preferred apps, this was not persisted to
package-restrictions.xml.

This occurs because the loop breaks early when iterating over matching
components after the first third party app that matches is discovered.
So, any elements in the list of matching ResolveInfo objects would not
be placed into set, leaving those entries as null. In its constructor,
PreferredComponent will discard all components in set if any entry
is null.

Instead of breaking, continue after filling that entry in the
set array, so that the previously matched value won't be overwritten.
However, the set must be filled so that it will be persisted later in
PreferredComponent.

Fixes CYNGNOS-663.

Change-Id: I9a1d57219e3cd6f883a914e13f67b74241780665
(cherry picked from commit f97ee51e)
parent f644858b
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -2490,6 +2490,11 @@ final class Settings {
            for (int i=0; i<ri.size(); i++) {
                ActivityInfo ai = ri.get(i).activityInfo;
                set[i] = new ComponentName(ai.packageName, ai.name);
                // We have already discovered the best third party match,
                // so we only need to finish filling set with all results.
                if (haveNonSys != null) {
                    continue;
                }
                if ((ai.applicationInfo.flags&ApplicationInfo.FLAG_SYSTEM) == 0) {
                    if (ri.get(i).match >= thirdPartyMatch) {
                        // Keep track of the best match we find of all third
@@ -2498,7 +2503,6 @@ final class Settings {
                        if (PackageManagerService.DEBUG_PREFERRED) Log.d(TAG, "Result "
                                + ai.packageName + "/" + ai.name + ": non-system!");
                        haveNonSys = set[i];
                        break;
                    }
                } else if (cn.getPackageName().equals(ai.packageName)
                        && cn.getClassName().equals(ai.name)) {