Merge "Merge "Don't pass initial intents to the inactive profile." into rvc-dev am: 04ccfdfae7 am: e1cdf50bc2" into rvc-d1-dev-plus-aosp
This commit is contained in:
committed by
Android (Google) Code Review
commit
b459a0407c
@@ -855,10 +855,11 @@ public class ChooserActivity extends ResolverActivity implements
|
||||
Intent[] initialIntents,
|
||||
List<ResolveInfo> rList,
|
||||
boolean filterLastUsed) {
|
||||
int selectedProfile = findSelectedProfile();
|
||||
ChooserGridAdapter personalAdapter = createChooserGridAdapter(
|
||||
/* context */ this,
|
||||
/* payloadIntents */ mIntents,
|
||||
initialIntents,
|
||||
selectedProfile == PROFILE_PERSONAL ? initialIntents : null,
|
||||
rList,
|
||||
filterLastUsed,
|
||||
mUseLayoutForBrowsables,
|
||||
@@ -866,12 +867,11 @@ public class ChooserActivity extends ResolverActivity implements
|
||||
ChooserGridAdapter workAdapter = createChooserGridAdapter(
|
||||
/* context */ this,
|
||||
/* payloadIntents */ mIntents,
|
||||
initialIntents,
|
||||
selectedProfile == PROFILE_WORK ? initialIntents : null,
|
||||
rList,
|
||||
filterLastUsed,
|
||||
mUseLayoutForBrowsables,
|
||||
/* userHandle */ getWorkProfileUserHandle());
|
||||
int selectedProfile = findSelectedProfile();
|
||||
return new ChooserMultiProfilePagerAdapter(
|
||||
/* context */ this,
|
||||
personalAdapter,
|
||||
|
||||
@@ -459,28 +459,6 @@ public class ResolverActivity extends Activity implements
|
||||
Intent[] initialIntents,
|
||||
List<ResolveInfo> rList,
|
||||
boolean filterLastUsed) {
|
||||
// We only show the default app for the profile of the current user. The filterLastUsed
|
||||
// flag determines whether to show a default app and that app is not shown in the
|
||||
// resolver list. So filterLastUsed should be false for the other profile.
|
||||
ResolverListAdapter personalAdapter = createResolverListAdapter(
|
||||
/* context */ this,
|
||||
/* payloadIntents */ mIntents,
|
||||
initialIntents,
|
||||
rList,
|
||||
(filterLastUsed && UserHandle.myUserId()
|
||||
== getPersonalProfileUserHandle().getIdentifier()),
|
||||
mUseLayoutForBrowsables,
|
||||
/* userHandle */ getPersonalProfileUserHandle());
|
||||
UserHandle workProfileUserHandle = getWorkProfileUserHandle();
|
||||
ResolverListAdapter workAdapter = createResolverListAdapter(
|
||||
/* context */ this,
|
||||
/* payloadIntents */ mIntents,
|
||||
initialIntents,
|
||||
rList,
|
||||
(filterLastUsed && UserHandle.myUserId()
|
||||
== workProfileUserHandle.getIdentifier()),
|
||||
mUseLayoutForBrowsables,
|
||||
/* userHandle */ workProfileUserHandle);
|
||||
// In the edge case when we have 0 apps in the current profile and >1 apps in the other,
|
||||
// the intent resolver is started in the other profile. Since this is the only case when
|
||||
// this happens, we check for it here and set the current profile's tab.
|
||||
@@ -493,6 +471,28 @@ public class ResolverActivity extends Activity implements
|
||||
selectedProfile = PROFILE_WORK;
|
||||
}
|
||||
}
|
||||
// We only show the default app for the profile of the current user. The filterLastUsed
|
||||
// flag determines whether to show a default app and that app is not shown in the
|
||||
// resolver list. So filterLastUsed should be false for the other profile.
|
||||
ResolverListAdapter personalAdapter = createResolverListAdapter(
|
||||
/* context */ this,
|
||||
/* payloadIntents */ mIntents,
|
||||
selectedProfile == PROFILE_PERSONAL ? initialIntents : null,
|
||||
rList,
|
||||
(filterLastUsed && UserHandle.myUserId()
|
||||
== getPersonalProfileUserHandle().getIdentifier()),
|
||||
mUseLayoutForBrowsables,
|
||||
/* userHandle */ getPersonalProfileUserHandle());
|
||||
UserHandle workProfileUserHandle = getWorkProfileUserHandle();
|
||||
ResolverListAdapter workAdapter = createResolverListAdapter(
|
||||
/* context */ this,
|
||||
/* payloadIntents */ mIntents,
|
||||
selectedProfile == PROFILE_WORK ? initialIntents : null,
|
||||
rList,
|
||||
(filterLastUsed && UserHandle.myUserId()
|
||||
== workProfileUserHandle.getIdentifier()),
|
||||
mUseLayoutForBrowsables,
|
||||
/* userHandle */ workProfileUserHandle);
|
||||
return new ResolverMultiProfilePagerAdapter(
|
||||
/* context */ this,
|
||||
personalAdapter,
|
||||
|
||||
@@ -1774,10 +1774,39 @@ public class ChooserActivityTest {
|
||||
when(sOverrides.packageManager.resolveActivity(any(Intent.class), anyInt())).thenReturn(ri);
|
||||
waitForIdle();
|
||||
|
||||
mActivityRule.launchActivity(chooserIntent);
|
||||
ChooserWrapperActivity activity = mActivityRule.launchActivity(chooserIntent);
|
||||
waitForIdle();
|
||||
|
||||
assertNull(chosen[0]);
|
||||
assertThat(activity.getPersonalListAdapter().getCallerTargetCount(), is(1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWorkTab_withInitialIntents_workTabDoesNotIncludePersonalInitialIntents() {
|
||||
// enable the work tab feature flag
|
||||
ResolverActivity.ENABLE_TABBED_VIEW = true;
|
||||
markWorkProfileUserAvailable();
|
||||
int workProfileTargets = 1;
|
||||
List<ResolvedComponentInfo> personalResolvedComponentInfos =
|
||||
createResolvedComponentsForTestWithOtherProfile(2, /* userId */ 10);
|
||||
List<ResolvedComponentInfo> workResolvedComponentInfos =
|
||||
createResolvedComponentsForTest(workProfileTargets);
|
||||
setupResolverControllers(personalResolvedComponentInfos, workResolvedComponentInfos);
|
||||
Intent[] initialIntents = {
|
||||
new Intent("action.fake1"),
|
||||
new Intent("action.fake2")
|
||||
};
|
||||
Intent chooserIntent = createChooserIntent(initialIntents);
|
||||
sOverrides.packageManager = mock(PackageManager.class);
|
||||
when(sOverrides.packageManager.resolveActivity(any(Intent.class), anyInt()))
|
||||
.thenReturn(createFakeResolveInfo());
|
||||
waitForIdle();
|
||||
|
||||
ChooserWrapperActivity activity = mActivityRule.launchActivity(chooserIntent);
|
||||
waitForIdle();
|
||||
|
||||
assertThat(activity.getPersonalListAdapter().getCallerTargetCount(), is(2));
|
||||
assertThat(activity.getWorkListAdapter().getCallerTargetCount(), is(0));
|
||||
}
|
||||
|
||||
private Intent createChooserIntent(Intent[] initialIntents) {
|
||||
|
||||
Reference in New Issue
Block a user