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

Commit c412be68 authored by Adam Powell's avatar Adam Powell
Browse files

Fix ChooserActivity check for still-alive ChooserTargets

Only prune ChooserTargets if the resolved activity source they came
from is still present after refreshing the list. Compare this directly
against the ComponentName rather than ResolveInfo.equals, as the
latter isn't implemented.

Bug 21953672

Change-Id: I6486bda85c19d7371167affe2a2b80a2668bd734
parent 7cc40196
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -74,6 +74,7 @@ import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
import java.util.Set;

import static android.view.WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR;
@@ -867,6 +868,16 @@ public class ResolverActivity extends Activity {
        }
    }

    /**
     * Check a simple match for the component of two ResolveInfos.
     */
    static boolean resolveInfoMatch(ResolveInfo lhs, ResolveInfo rhs) {
        return lhs == null ? rhs == null
                : lhs.activityInfo == null ? rhs.activityInfo == null
                : Objects.equals(lhs.activityInfo.name, rhs.activityInfo.name)
                && Objects.equals(lhs.activityInfo.packageName, rhs.activityInfo.packageName);
    }

    final class DisplayResolveInfo implements TargetInfo {
        private final ResolveInfo mResolveInfo;
        private final CharSequence mDisplayLabel;
@@ -1462,7 +1473,7 @@ public class ResolverActivity extends Activity {

        public boolean hasResolvedTarget(ResolveInfo info) {
            for (int i = 0, N = mDisplayList.size(); i < N; i++) {
                if (info.equals(mDisplayList.get(i).getResolveInfo())) {
                if (resolveInfoMatch(info, mDisplayList.get(i).getResolveInfo())) {
                    return true;
                }
            }