From ad6f2e580f783d5d320d3265bd617adedf55c944 Mon Sep 17 00:00:00 2001 From: Andrii Kulian Date: Wed, 15 Jun 2016 15:27:01 -0700 Subject: [PATCH] Bring task to front when we can't move to adjacent stack If task was requested to move to adjacent stack with mLaunchStackId set and FLAG_ACTIVITY_LAUNCH_ADJACENT not set - we don't move it from its current stack. If the task was covered with other task(s) it wouldn't be brought to front. This CL checks if mLaunchStackId is provided and is a valid stack for this task, then we move it to front of current stack as a safer option. Bug: 29103549 Change-Id: I3065960f082cfbf9a5b43c6e83b5cebe3dd69df6 --- .../android/server/am/ActivityStarter.java | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/services/core/java/com/android/server/am/ActivityStarter.java b/services/core/java/com/android/server/am/ActivityStarter.java index 522e42bda94be..e42548488ebe8 100644 --- a/services/core/java/com/android/server/am/ActivityStarter.java +++ b/services/core/java/com/android/server/am/ActivityStarter.java @@ -1465,14 +1465,23 @@ class ActivityStarter { intentActivity.task, mNoAnimation, mOptions, mStartActivity.appTimeTracker, "bringingFoundTaskToFront"); mMovedToFront = true; - } else if ((launchStack.mStackId == DOCKED_STACK_ID - || launchStack.mStackId == FULLSCREEN_WORKSPACE_STACK_ID) - && (mLaunchFlags & FLAG_ACTIVITY_LAUNCH_ADJACENT) != 0) { - // If we want to launch adjacent and mTargetStack is not the computed - // launch stack - move task to top of computed stack. - mSupervisor.moveTaskToStackLocked(intentActivity.task.taskId, - launchStack.mStackId, ON_TOP, FORCE_FOCUS, "launchToSide", - ANIMATE); + } else if (launchStack.mStackId == DOCKED_STACK_ID + || launchStack.mStackId == FULLSCREEN_WORKSPACE_STACK_ID) { + if ((mLaunchFlags & FLAG_ACTIVITY_LAUNCH_ADJACENT) != 0) { + // If we want to launch adjacent and mTargetStack is not the computed + // launch stack - move task to top of computed stack. + mSupervisor.moveTaskToStackLocked(intentActivity.task.taskId, + launchStack.mStackId, ON_TOP, FORCE_FOCUS, "launchToSide", + ANIMATE); + } else { + // TODO: This should be reevaluated in MW v2. + // We choose to move task to front instead of launching it adjacent + // when specific stack was requested explicitly and it appeared to be + // adjacent stack, but FLAG_ACTIVITY_LAUNCH_ADJACENT was not set. + mTargetStack.moveTaskToFrontLocked(intentActivity.task, mNoAnimation, + mOptions, mStartActivity.appTimeTracker, + "bringToFrontInsteadOfAdjacentLaunch"); + } mMovedToFront = true; } mOptions = null;