From f8a97ab1d87617bf20f55d5d1ec8363072c9a886 Mon Sep 17 00:00:00 2001 From: Matt Casey Date: Wed, 27 Apr 2022 03:48:02 +0000 Subject: Fix "always" option in ResolverActivity mUnfilteredResolveList was incorrectly being set as null whenever performSecondaryResolveListFilterin didn't end up filtering anything (when its value should have been maintained in this case). This incorrect mUnfilteredResolveList null value causes most of ResolverActivity's onTargetSelected() logic to be skipped, thus it doesn't notify the package manager of the 'always' selection. This should match the behavior before ag/17509713 and fix the bug. Test: Manual testing (install two email apps, click an email addr link, choose a resolver target and press 'always', then do it again and resolver shouldn't appear). Test: atest CtsDynamicMimeHostTestCases:android.dynamicmime.cts.PreferredActivitiesTestCases#testModifyGroupWithoutActualGroupChanges Test: atest ResolverActivityTest Bug: 230149644 Change-Id: Ia23e95359d320a3a63e39f9c50a159879e94bf3b --- core/java/com/android/internal/app/ResolverListAdapter.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/core/java/com/android/internal/app/ResolverListAdapter.java b/core/java/com/android/internal/app/ResolverListAdapter.java index 351ac4587def..0a07e0a04a40 100644 --- a/core/java/com/android/internal/app/ResolverListAdapter.java +++ b/core/java/com/android/internal/app/ResolverListAdapter.java @@ -233,8 +233,14 @@ public class ResolverListAdapter extends BaseAdapter { // copied the original unfiltered items to a separate List instance and can now filter // the remainder in-place without any further bookkeeping. boolean needsCopyOfUnfiltered = (mUnfilteredResolveList == currentResolveList); - mUnfilteredResolveList = performSecondaryResolveListFiltering( + List originalList = performSecondaryResolveListFiltering( currentResolveList, needsCopyOfUnfiltered); + if (originalList != null) { + // Only need the originalList value if there was a modification (otherwise it's null + // and shouldn't overwrite mUnfilteredResolveList). + mUnfilteredResolveList = originalList; + } + return finishRebuildingListWithFilteredResults(currentResolveList, doPostProcessing); } @@ -293,7 +299,7 @@ public class ResolverListAdapter extends BaseAdapter { * appearing in the rebuilt-list results, while still considering those items for the "other * profile" special-treatment described in {@code rebuildList()}. * - * @return the same (possibly null) List reference as {@code currentResolveList}, if the list is + * @return the same (possibly null) List reference as {@code currentResolveList} if the list is * unmodified as a result of filtering; or, if some item(s) were removed, then either a copy of * the original {@code currentResolveList} (if {@code returnCopyOfOriginalListIfModified} is * true), or null (otherwise). -- cgit v1.2.3-59-g8ed1b