Loading services/core/java/com/android/server/wm/DisplayContent.java +12 −0 Original line number Diff line number Diff line Loading @@ -3606,6 +3606,18 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo final int targetPosition = findPositionForStack(position, child, false /* adding */); super.positionChildAt(targetPosition, child, includingParents); if (includingParents) { // We still want to move the display of this stack container to top because even the // target position is adjusted to non-top, the intention of the condition is to have // higher z-order to gain focus (e.g. moving a task of a fullscreen stack to front // in a non-top display which is using picture-in-picture mode). final int topChildPosition = getChildCount() - 1; if (targetPosition < topChildPosition && position >= topChildPosition) { getParent().positionChildAt(POSITION_TOP, this /* child */, true /* includingParents */); } } setLayoutNeeded(); } Loading services/tests/servicestests/src/com/android/server/wm/TaskStackContainersTests.java +18 −0 Original line number Diff line number Diff line Loading @@ -109,4 +109,22 @@ public class TaskStackContainersTests extends WindowTestsBase { assertEquals(taskStackContainer.mChildren.get(stackPos), stack1); assertEquals(taskStackContainer.mChildren.get(pinnedStackPos), mPinnedStack); } @Test public void testDisplayPositionWithPinnedStack() { // The display contains pinned stack that was added in {@link #setUp}. final TaskStack stack = createTaskStackOnDisplay(mDisplayContent); final Task task = createTaskInStack(stack, 0 /* userId */); // Add another display at top. sWm.mRoot.positionChildAt(WindowContainer.POSITION_TOP, createNewDisplay(), false /* includingParents */); // Move the task of {@code mDisplayContent} to top. stack.positionChildAt(WindowContainer.POSITION_TOP, task, true /* includingParents */); final int indexOfDisplayWithPinnedStack = sWm.mRoot.mChildren.indexOf(mDisplayContent); assertEquals("The testing DisplayContent should be moved to top with task", sWm.mRoot.getChildCount() - 1, indexOfDisplayWithPinnedStack); } } Loading
services/core/java/com/android/server/wm/DisplayContent.java +12 −0 Original line number Diff line number Diff line Loading @@ -3606,6 +3606,18 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo final int targetPosition = findPositionForStack(position, child, false /* adding */); super.positionChildAt(targetPosition, child, includingParents); if (includingParents) { // We still want to move the display of this stack container to top because even the // target position is adjusted to non-top, the intention of the condition is to have // higher z-order to gain focus (e.g. moving a task of a fullscreen stack to front // in a non-top display which is using picture-in-picture mode). final int topChildPosition = getChildCount() - 1; if (targetPosition < topChildPosition && position >= topChildPosition) { getParent().positionChildAt(POSITION_TOP, this /* child */, true /* includingParents */); } } setLayoutNeeded(); } Loading
services/tests/servicestests/src/com/android/server/wm/TaskStackContainersTests.java +18 −0 Original line number Diff line number Diff line Loading @@ -109,4 +109,22 @@ public class TaskStackContainersTests extends WindowTestsBase { assertEquals(taskStackContainer.mChildren.get(stackPos), stack1); assertEquals(taskStackContainer.mChildren.get(pinnedStackPos), mPinnedStack); } @Test public void testDisplayPositionWithPinnedStack() { // The display contains pinned stack that was added in {@link #setUp}. final TaskStack stack = createTaskStackOnDisplay(mDisplayContent); final Task task = createTaskInStack(stack, 0 /* userId */); // Add another display at top. sWm.mRoot.positionChildAt(WindowContainer.POSITION_TOP, createNewDisplay(), false /* includingParents */); // Move the task of {@code mDisplayContent} to top. stack.positionChildAt(WindowContainer.POSITION_TOP, task, true /* includingParents */); final int indexOfDisplayWithPinnedStack = sWm.mRoot.mChildren.indexOf(mDisplayContent); assertEquals("The testing DisplayContent should be moved to top with task", sWm.mRoot.getChildCount() - 1, indexOfDisplayWithPinnedStack); } }