summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Andrii Kulian <akulian@google.com> 2017-03-21 19:37:09 -0700
committer Andrii Kulian <akulian@google.com> 2017-03-28 19:33:57 +0000
commitfab9cd89eef609affbed72d780dc2a006d73196f (patch)
tree2639d8bae95c93e041785a5e329d683c6d7a3268
parentcf1f1d9128853f0fa0cef657e2bbb7bf6904c732 (diff)
Move activity to display on launch
When an activity is launched with displayId specified and there is an existing matching task on some other display - that task should be move to the target display. Bug: 34396961 Test: android.server.cts.ActivityManagerDisplayTests Test: #testMoveToDisplayOnLaunch Change-Id: I18b1f0de320039f4f1ac4e248f048a367f886d29 (cherry picked from commit ede131cce47a1d2ebafd25156e5caf26eb880136)
-rw-r--r--services/core/java/com/android/server/am/ActivityStarter.java14
1 files changed, 14 insertions, 0 deletions
diff --git a/services/core/java/com/android/server/am/ActivityStarter.java b/services/core/java/com/android/server/am/ActivityStarter.java
index 4bd06b76e92e..2a1e0b307b7e 100644
--- a/services/core/java/com/android/server/am/ActivityStarter.java
+++ b/services/core/java/com/android/server/am/ActivityStarter.java
@@ -1453,6 +1453,12 @@ class ActivityStarter {
return intentActivity;
}
+ /**
+ * Figure out which task and activity to bring to front when we have found an existing matching
+ * activity record in history. May also clear the task if needed.
+ * @param intentActivity Existing matching activity.
+ * @return {@link ActivityRecord} brought to front.
+ */
private ActivityRecord setTargetStackAndMoveToFrontIfNeeded(ActivityRecord intentActivity) {
mTargetStack = intentActivity.getStack();
mTargetStack.mLastPausedActivity = null;
@@ -1514,6 +1520,14 @@ class ActivityStarter {
"bringToFrontInsteadOfAdjacentLaunch");
}
mMovedToFront = true;
+ } else if (launchStack.mDisplayId != mTargetStack.mDisplayId) {
+ // Target and computed stacks are on different displays and we've
+ // found a matching task - move the existing instance to that display and
+ // move it to front.
+ intentActivity.task.reparent(launchStack.mStackId, ON_TOP,
+ REPARENT_MOVE_STACK_TO_FRONT, ANIMATE, DEFER_RESUME,
+ "reparentToDisplay");
+ mMovedToFront = true;
}
mOptions = null;