From 581a3c580074a1e2d3e3e4ced7818a52f9165c4c Mon Sep 17 00:00:00 2001 From: arangelov Date: Wed, 17 Jun 2020 13:43:20 +0100 Subject: [PATCH] Also check inactive profile targets in onHandlePackagesChanged Before we would only check the active tab for available targets and finish the activity if there are none. However, with the work tab, there can be cases where the active tab has no targets, but the inactive tab does. Fixes: 159202588 Test: manual Change-Id: Ie03ebd1b022362681df432ec29299df86dceb490 --- core/java/com/android/internal/app/ResolverActivity.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/core/java/com/android/internal/app/ResolverActivity.java b/core/java/com/android/internal/app/ResolverActivity.java index daacd459a1a70..86c13a0581c29 100644 --- a/core/java/com/android/internal/app/ResolverActivity.java +++ b/core/java/com/android/internal/app/ResolverActivity.java @@ -1938,7 +1938,7 @@ public class ResolverActivity extends Activity implements ResolverListAdapter activeListAdapter = mMultiProfilePagerAdapter.getActiveListAdapter(); activeListAdapter.notifyDataSetChanged(); - if (activeListAdapter.getCount() == 0) { + if (activeListAdapter.getCount() == 0 && !inactiveListAdapterHasItems()) { // We no longer have any items... just finish the activity. finish(); } @@ -1948,6 +1948,13 @@ public class ResolverActivity extends Activity implements } } + private boolean inactiveListAdapterHasItems() { + if (!shouldShowTabs()) { + return false; + } + return mMultiProfilePagerAdapter.getInactiveListAdapter().getCount() > 0; + } + private BroadcastReceiver createWorkProfileStateReceiver() { return new BroadcastReceiver() { @Override