Loading core/java/com/android/internal/app/ResolverActivity.java +3 −2 Original line number Diff line number Diff line Loading @@ -363,8 +363,9 @@ public class ResolverActivity extends Activity implements // of the last used choice to highlight it in the list. We need to always // turn this off when running under voice interaction, since it results in // a more complicated UI that the current voice interaction flow is not able // to handle. boolean filterLastUsed = mSupportsAlwaysUseOption && !isVoiceInteraction(); // to handle. We also turn it off when the work tab is shown to simplify the UX. boolean filterLastUsed = mSupportsAlwaysUseOption && !isVoiceInteraction() && !shouldShowTabs(); mWorkProfileUserHandle = fetchWorkProfileUserProfile(); mMultiProfilePagerAdapter = createMultiProfilePagerAdapter(initialIntents, rList, filterLastUsed); if (configureContentView()) { Loading core/tests/coretests/src/com/android/internal/app/ResolverActivityTest.java +29 −0 Original line number Diff line number Diff line Loading @@ -43,6 +43,7 @@ import static org.testng.Assert.assertFalse; import android.content.Intent; import android.content.pm.ResolveInfo; import android.net.Uri; import android.os.RemoteException; import android.os.UserHandle; import android.text.TextUtils; import android.view.View; Loading Loading @@ -827,6 +828,34 @@ public class ResolverActivityTest { assertThat(chosen[0], is(personalResolvedComponentInfos.get(1).getResolveInfoAt(0))); } @Test public void testLayoutWithDefault_withWorkTab_neverShown() throws RemoteException { // enable the work tab feature flag ResolverActivity.ENABLE_TABBED_VIEW = true; markWorkProfileUserAvailable(); // In this case we prefer the other profile and don't display anything about the last // chosen activity. Intent sendIntent = createSendImageIntent(); List<ResolvedComponentInfo> resolvedComponentInfos = createResolvedComponentsForTest(2); when(sOverrides.resolverListController.getResolversForIntent(Mockito.anyBoolean(), Mockito.anyBoolean(), Mockito.isA(List.class))).thenReturn(resolvedComponentInfos); when(sOverrides.resolverListController.getLastChosen()) .thenReturn(resolvedComponentInfos.get(1).getResolveInfoAt(0)); final ResolverWrapperActivity activity = mActivityRule.launchActivity(sendIntent); Espresso.registerIdlingResources(activity.getAdapter().getLabelIdlingResource()); waitForIdle(); // The other entry is filtered to the last used slot assertThat(activity.getAdapter().hasFilteredItem(), is(false)); assertThat(activity.getAdapter().getCount(), is(2)); assertThat(activity.getAdapter().getPlaceholderCount(), is(2)); } private Intent createSendImageIntent() { Intent sendIntent = new Intent(); sendIntent.setAction(Intent.ACTION_SEND); Loading Loading
core/java/com/android/internal/app/ResolverActivity.java +3 −2 Original line number Diff line number Diff line Loading @@ -363,8 +363,9 @@ public class ResolverActivity extends Activity implements // of the last used choice to highlight it in the list. We need to always // turn this off when running under voice interaction, since it results in // a more complicated UI that the current voice interaction flow is not able // to handle. boolean filterLastUsed = mSupportsAlwaysUseOption && !isVoiceInteraction(); // to handle. We also turn it off when the work tab is shown to simplify the UX. boolean filterLastUsed = mSupportsAlwaysUseOption && !isVoiceInteraction() && !shouldShowTabs(); mWorkProfileUserHandle = fetchWorkProfileUserProfile(); mMultiProfilePagerAdapter = createMultiProfilePagerAdapter(initialIntents, rList, filterLastUsed); if (configureContentView()) { Loading
core/tests/coretests/src/com/android/internal/app/ResolverActivityTest.java +29 −0 Original line number Diff line number Diff line Loading @@ -43,6 +43,7 @@ import static org.testng.Assert.assertFalse; import android.content.Intent; import android.content.pm.ResolveInfo; import android.net.Uri; import android.os.RemoteException; import android.os.UserHandle; import android.text.TextUtils; import android.view.View; Loading Loading @@ -827,6 +828,34 @@ public class ResolverActivityTest { assertThat(chosen[0], is(personalResolvedComponentInfos.get(1).getResolveInfoAt(0))); } @Test public void testLayoutWithDefault_withWorkTab_neverShown() throws RemoteException { // enable the work tab feature flag ResolverActivity.ENABLE_TABBED_VIEW = true; markWorkProfileUserAvailable(); // In this case we prefer the other profile and don't display anything about the last // chosen activity. Intent sendIntent = createSendImageIntent(); List<ResolvedComponentInfo> resolvedComponentInfos = createResolvedComponentsForTest(2); when(sOverrides.resolverListController.getResolversForIntent(Mockito.anyBoolean(), Mockito.anyBoolean(), Mockito.isA(List.class))).thenReturn(resolvedComponentInfos); when(sOverrides.resolverListController.getLastChosen()) .thenReturn(resolvedComponentInfos.get(1).getResolveInfoAt(0)); final ResolverWrapperActivity activity = mActivityRule.launchActivity(sendIntent); Espresso.registerIdlingResources(activity.getAdapter().getLabelIdlingResource()); waitForIdle(); // The other entry is filtered to the last used slot assertThat(activity.getAdapter().hasFilteredItem(), is(false)); assertThat(activity.getAdapter().getCount(), is(2)); assertThat(activity.getAdapter().getPlaceholderCount(), is(2)); } private Intent createSendImageIntent() { Intent sendIntent = new Intent(); sendIntent.setAction(Intent.ACTION_SEND); Loading