Merge "Don't pass initial intents to the inactive profile." into rvc-dev am: 04ccfdfae7
Change-Id: Ie05084a6733e945acd3ffd73e378f00c91f88cd9
This commit is contained in:
@@ -855,10 +855,11 @@ public class ChooserActivity extends ResolverActivity implements
|
|||||||
Intent[] initialIntents,
|
Intent[] initialIntents,
|
||||||
List<ResolveInfo> rList,
|
List<ResolveInfo> rList,
|
||||||
boolean filterLastUsed) {
|
boolean filterLastUsed) {
|
||||||
|
int selectedProfile = findSelectedProfile();
|
||||||
ChooserGridAdapter personalAdapter = createChooserGridAdapter(
|
ChooserGridAdapter personalAdapter = createChooserGridAdapter(
|
||||||
/* context */ this,
|
/* context */ this,
|
||||||
/* payloadIntents */ mIntents,
|
/* payloadIntents */ mIntents,
|
||||||
initialIntents,
|
selectedProfile == PROFILE_PERSONAL ? initialIntents : null,
|
||||||
rList,
|
rList,
|
||||||
filterLastUsed,
|
filterLastUsed,
|
||||||
mUseLayoutForBrowsables,
|
mUseLayoutForBrowsables,
|
||||||
@@ -866,12 +867,11 @@ public class ChooserActivity extends ResolverActivity implements
|
|||||||
ChooserGridAdapter workAdapter = createChooserGridAdapter(
|
ChooserGridAdapter workAdapter = createChooserGridAdapter(
|
||||||
/* context */ this,
|
/* context */ this,
|
||||||
/* payloadIntents */ mIntents,
|
/* payloadIntents */ mIntents,
|
||||||
initialIntents,
|
selectedProfile == PROFILE_WORK ? initialIntents : null,
|
||||||
rList,
|
rList,
|
||||||
filterLastUsed,
|
filterLastUsed,
|
||||||
mUseLayoutForBrowsables,
|
mUseLayoutForBrowsables,
|
||||||
/* userHandle */ getWorkProfileUserHandle());
|
/* userHandle */ getWorkProfileUserHandle());
|
||||||
int selectedProfile = findSelectedProfile();
|
|
||||||
return new ChooserMultiProfilePagerAdapter(
|
return new ChooserMultiProfilePagerAdapter(
|
||||||
/* context */ this,
|
/* context */ this,
|
||||||
personalAdapter,
|
personalAdapter,
|
||||||
|
|||||||
@@ -459,28 +459,6 @@ public class ResolverActivity extends Activity implements
|
|||||||
Intent[] initialIntents,
|
Intent[] initialIntents,
|
||||||
List<ResolveInfo> rList,
|
List<ResolveInfo> rList,
|
||||||
boolean filterLastUsed) {
|
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,
|
// 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
|
// 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.
|
// 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;
|
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(
|
return new ResolverMultiProfilePagerAdapter(
|
||||||
/* context */ this,
|
/* context */ this,
|
||||||
personalAdapter,
|
personalAdapter,
|
||||||
|
|||||||
@@ -1774,10 +1774,39 @@ public class ChooserActivityTest {
|
|||||||
when(sOverrides.packageManager.resolveActivity(any(Intent.class), anyInt())).thenReturn(ri);
|
when(sOverrides.packageManager.resolveActivity(any(Intent.class), anyInt())).thenReturn(ri);
|
||||||
waitForIdle();
|
waitForIdle();
|
||||||
|
|
||||||
mActivityRule.launchActivity(chooserIntent);
|
ChooserWrapperActivity activity = mActivityRule.launchActivity(chooserIntent);
|
||||||
waitForIdle();
|
waitForIdle();
|
||||||
|
|
||||||
assertNull(chosen[0]);
|
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) {
|
private Intent createChooserIntent(Intent[] initialIntents) {
|
||||||
|
|||||||
Reference in New Issue
Block a user