diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java index 66e1b1758d851..a9f6a2f1334b5 100644 --- a/services/core/java/com/android/server/wm/Task.java +++ b/services/core/java/com/android/server/wm/Task.java @@ -2688,16 +2688,7 @@ class Task extends WindowContainer { return null; } - final String myReason = reason + " adjustFocusToNextFocusableStack"; - final ActivityRecord top = focusableTask.topRunningActivity(); final ActivityStack rootTask = (ActivityStack) focusableTask.getRootTask(); - if (focusableTask.isActivityTypeHome() && (top == null || !top.mVisibleRequested)) { - // If we will be focusing on the home stack next and its current top activity isn't - // visible, then use the move the home stack task to top to make the activity visible. - focusableTask.getDisplayArea().moveHomeActivityToTop(myReason); - return rootTask; - } - if (!moveParentsToTop) { // Only move the next stack to top in its task container. WindowContainer parent = focusableTask.getParent(); @@ -2705,6 +2696,15 @@ class Task extends WindowContainer { return rootTask; } + final String myReason = reason + " adjustFocusToNextFocusableStack"; + final ActivityRecord top = focusableTask.topRunningActivity(); + if (focusableTask.isActivityTypeHome() && (top == null || !top.mVisibleRequested)) { + // If we will be focusing on the home stack next and its current top activity isn't + // visible, then use the move the home stack task to top to make the activity visible. + focusableTask.getDisplayArea().moveHomeActivityToTop(myReason); + return rootTask; + } + // Move the entire hierarchy to top with updating global top resumed activity // and focused application if needed. focusableTask.moveToFront(myReason);