frameworks/base
Revision | 5d11899b6d8ab3edd8ef0d5ca3ca5ea89a009c89 (tree) |
---|---|
Time | 2020-07-11 16:40:13 |
Author | utzcoz <utzcoz@outl...> |
Commiter | utzcoz |
Keep stack order when starting activity from recents
When starting activity from recents, the AMS will move home stack to
front and then move selected activity stack to front. So when we start
many freeform windows, the operation will move unselected freeform
windows to back. It's not good for usage. So this patch will remove the
logic to move home stack to front when starting activity from recents,
and move recents stack to background to dismiss the recents page.
For split screen secondary windowing, we keep the origin logic to move
home stack to front. If we find rigid problems when starting split
screen window or pip window, we should review this patch again to check
whether this patch causes the problem.
Signed-off-by: utzcoz <utzcoz@outlook.com>
@@ -1048,7 +1048,11 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai | ||
1048 | 1048 | } |
1049 | 1049 | } |
1050 | 1050 | |
1051 | - if (!isActivityTypeHome() && returnsToHomeStack()) { | |
1051 | + // region @boringdroid | |
1052 | + // if (!isActivityTypeHome() && returnsToHomeStack()) { | |
1053 | + // We don't need to move to home stack after recents finished. | |
1054 | + if (!isActivityTypeHome() && !isActivityTypeRecents() && returnsToHomeStack()) { | |
1055 | + // endregion | |
1052 | 1056 | // Make sure the home stack is behind this stack since that is where we should return to |
1053 | 1057 | // when this stack is no longer visible. |
1054 | 1058 | mStackSupervisor.moveHomeStackToFront(reason + " returnToHome"); |
@@ -738,6 +738,15 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D | ||
738 | 738 | recentsStack.moveToFront(reason); |
739 | 739 | } |
740 | 740 | } |
741 | + // region @boringdroid | |
742 | + void moveRecentsStackToBack(String reason) { | |
743 | + final ActivityStack recentsStack = getDefaultDisplay().getStack( | |
744 | + WINDOWING_MODE_UNDEFINED, ACTIVITY_TYPE_RECENTS); | |
745 | + if (recentsStack != null) { | |
746 | + recentsStack.moveToBack(reason, null); | |
747 | + } | |
748 | + } | |
749 | + // endregion | |
741 | 750 | |
742 | 751 | /** Returns true if the focus activity was adjusted to the home stack top activity. */ |
743 | 752 | boolean moveHomeStackTaskToTop(String reason) { |
@@ -2293,8 +2302,12 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D | ||
2293 | 2302 | |
2294 | 2303 | final ActivityRecord prev = topRunningActivityLocked(); |
2295 | 2304 | |
2296 | - if ((flags & ActivityManager.MOVE_TASK_WITH_HOME) != 0 | |
2297 | - || (prev != null && prev.isActivityTypeRecents())) { | |
2305 | + // region @boringdroid | |
2306 | + // We only move home stack to from if the task wants to move task with home. | |
2307 | + if ((flags & ActivityManager.MOVE_TASK_WITH_HOME) != 0) { | |
2308 | + // if ((flags & ActivityManager.MOVE_TASK_WITH_HOME) != 0 | |
2309 | + // || (prev != null && prev.isActivityTypeRecents())) { | |
2310 | + // endregion | |
2298 | 2311 | // Caller wants the home activity moved with it or the previous task is recents in which |
2299 | 2312 | // case we always return home from the task we are moving to the front. |
2300 | 2313 | moveHomeStackToFront("findTaskToMoveToFront"); |
@@ -4811,7 +4824,17 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D | ||
4811 | 4824 | // We always want to return to the home activity instead of the recents activity |
4812 | 4825 | // from whatever is started from the recents activity, so move the home stack |
4813 | 4826 | // forward. |
4814 | - moveHomeStackToFront("startActivityFromRecents"); | |
4827 | + // region @boringdroid | |
4828 | + // We only move the home stack forward for split screen. We don't do it for | |
4829 | + // fullscreen or freeform activity. For other windowing mode activity, we should | |
4830 | + // consider this check logic when encountering rigid problem. | |
4831 | + // moveHomeStackToFront("startActivityFromRecents"); | |
4832 | + if (windowingMode == WINDOWING_MODE_SPLIT_SCREEN_SECONDARY) { | |
4833 | + moveHomeStackToFront("startActivityFromRecents"); | |
4834 | + } else { | |
4835 | + moveRecentsStackToBack("startActivityFromRecents"); | |
4836 | + } | |
4837 | + // endregion | |
4815 | 4838 | } |
4816 | 4839 | |
4817 | 4840 | // If the user must confirm credentials (e.g. when first launching a work app and the |