diff options
| author | 2018-09-14 08:05:41 +0000 | |
|---|---|---|
| committer | 2018-09-14 08:05:41 +0000 | |
| commit | 068923f3de71560185de4cd5c2f05753707d1854 (patch) | |
| tree | d3e29ccc0fd1c376d5c82fb88a8a3ff3e6501bcd | |
| parent | 7b39606eae929485b240e002149b4efcf2ce3ff6 (diff) | |
| parent | 2f6e174c4afb2e2d171808033df7ad4133854e53 (diff) | |
Merge "Fix z-order of displays when adjusting position of stack"
| -rw-r--r-- | services/core/java/com/android/server/wm/DisplayContent.java | 12 | ||||
| -rw-r--r-- | services/tests/servicestests/src/com/android/server/wm/TaskStackContainersTests.java | 18 |
2 files changed, 30 insertions, 0 deletions
diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java index 5d0101f88c69..ac6582634bf8 100644 --- a/services/core/java/com/android/server/wm/DisplayContent.java +++ b/services/core/java/com/android/server/wm/DisplayContent.java @@ -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(); } diff --git a/services/tests/servicestests/src/com/android/server/wm/TaskStackContainersTests.java b/services/tests/servicestests/src/com/android/server/wm/TaskStackContainersTests.java index 9fa5ba42204f..ea44279b46a9 100644 --- a/services/tests/servicestests/src/com/android/server/wm/TaskStackContainersTests.java +++ b/services/tests/servicestests/src/com/android/server/wm/TaskStackContainersTests.java @@ -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); + } } |