Merge "Launch all activities into the same root task" into tm-qpr-dev am: a45c7f7de3
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/19989745 Change-Id: I3a493527e397e43d8b53a9f869bf8e8aaeeecdb8 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -392,9 +392,9 @@ public class ActivityStartController {
|
|||||||
SafeActivityOptions bottomOptions = null;
|
SafeActivityOptions bottomOptions = null;
|
||||||
if (options != null) {
|
if (options != null) {
|
||||||
// To ensure the first N-1 activities (N == total # of activities) are also launched
|
// To ensure the first N-1 activities (N == total # of activities) are also launched
|
||||||
// into the correct display, use a copy of the passed-in options (keeping only
|
// into the correct display and root task, use a copy of the passed-in options (keeping
|
||||||
// display-related info) for these activities.
|
// only display-related and launch-root-task information) for these activities.
|
||||||
bottomOptions = options.selectiveCloneDisplayOptions();
|
bottomOptions = options.selectiveCloneLaunchOptions();
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
intents = ArrayUtils.filterNotNull(intents, Intent[]::new);
|
intents = ArrayUtils.filterNotNull(intents, Intent[]::new);
|
||||||
|
|||||||
@@ -119,13 +119,13 @@ public class SafeActivityOptions {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* To ensure that two activities, one using this object, and the other using the
|
* To ensure that two activities, one using this object, and the other using the
|
||||||
* SafeActivityOptions returned from this function, are launched into the same display through
|
* SafeActivityOptions returned from this function, are launched into the same display/root task
|
||||||
* ActivityStartController#startActivities, all display-related information, i.e.
|
* through ActivityStartController#startActivities, all display-related information, i.e.
|
||||||
* displayAreaToken, launchDisplayId and callerDisplayId, are cloned.
|
* displayAreaToken, launchDisplayId, callerDisplayId and the launch root task are cloned.
|
||||||
*/
|
*/
|
||||||
@Nullable SafeActivityOptions selectiveCloneDisplayOptions() {
|
@Nullable SafeActivityOptions selectiveCloneLaunchOptions() {
|
||||||
final ActivityOptions options = cloneLaunchingDisplayOptions(mOriginalOptions);
|
final ActivityOptions options = cloneLaunchingOptions(mOriginalOptions);
|
||||||
final ActivityOptions callerOptions = cloneLaunchingDisplayOptions(mCallerOptions);
|
final ActivityOptions callerOptions = cloneLaunchingOptions(mCallerOptions);
|
||||||
if (options == null && callerOptions == null) {
|
if (options == null && callerOptions == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -138,11 +138,12 @@ public class SafeActivityOptions {
|
|||||||
return safeOptions;
|
return safeOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ActivityOptions cloneLaunchingDisplayOptions(ActivityOptions options) {
|
private ActivityOptions cloneLaunchingOptions(ActivityOptions options) {
|
||||||
return options == null ? null : ActivityOptions.makeBasic()
|
return options == null ? null : ActivityOptions.makeBasic()
|
||||||
.setLaunchTaskDisplayArea(options.getLaunchTaskDisplayArea())
|
.setLaunchTaskDisplayArea(options.getLaunchTaskDisplayArea())
|
||||||
.setLaunchDisplayId(options.getLaunchDisplayId())
|
.setLaunchDisplayId(options.getLaunchDisplayId())
|
||||||
.setCallerDisplayId((options.getCallerDisplayId()));
|
.setCallerDisplayId(options.getCallerDisplayId())
|
||||||
|
.setLaunchRootTask(options.getLaunchRootTask());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -57,10 +57,20 @@ public class SafeActivityOptionsTest {
|
|||||||
.setLaunchTaskDisplayArea(token)
|
.setLaunchTaskDisplayArea(token)
|
||||||
.setLaunchDisplayId(launchDisplayId)
|
.setLaunchDisplayId(launchDisplayId)
|
||||||
.setCallerDisplayId(callerDisplayId))
|
.setCallerDisplayId(callerDisplayId))
|
||||||
.selectiveCloneDisplayOptions();
|
.selectiveCloneLaunchOptions();
|
||||||
|
|
||||||
assertSame(clone.getOriginalOptions().getLaunchTaskDisplayArea(), token);
|
assertSame(clone.getOriginalOptions().getLaunchTaskDisplayArea(), token);
|
||||||
assertEquals(clone.getOriginalOptions().getLaunchDisplayId(), launchDisplayId);
|
assertEquals(clone.getOriginalOptions().getLaunchDisplayId(), launchDisplayId);
|
||||||
assertEquals(clone.getOriginalOptions().getCallerDisplayId(), callerDisplayId);
|
assertEquals(clone.getOriginalOptions().getCallerDisplayId(), callerDisplayId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test_selectiveCloneLunchRootTask() {
|
||||||
|
final WindowContainerToken token = mock(WindowContainerToken.class);
|
||||||
|
final SafeActivityOptions clone = new SafeActivityOptions(ActivityOptions.makeBasic()
|
||||||
|
.setLaunchRootTask(token))
|
||||||
|
.selectiveCloneLaunchOptions();
|
||||||
|
|
||||||
|
assertSame(clone.getOriginalOptions().getLaunchRootTask(), token);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user