Notify task about display change when moved to new stack
Bug: 34176283
Test: android.server.cts.ActivityManagerDisplayTests
Test: #testMoveTaskBetweenDisplays
Test: bit FrameworksServicesTests:com.android.server.wm.TaskWindowContainerControllerTests
Test: bit FrameworksServicesTests:com.android.server.wm.TaskStackContainersTests
Change-Id: If085246926790089e014a94093d788805e812489
diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java
index 47003fa..592eaec 100644
--- a/services/core/java/com/android/server/wm/DisplayContent.java
+++ b/services/core/java/com/android/server/wm/DisplayContent.java
@@ -1437,6 +1437,12 @@
return "Display " + mDisplayId + " name=\"" + mDisplayInfo.name + "\"";
}
+ /** Checks if stack with provided id is visible on this display. */
+ boolean isStackVisible(int stackId) {
+ final TaskStack stack = getStackById(stackId);
+ return (stack != null && stack.isVisible());
+ }
+
/**
* @return The docked stack, but only if it is visible, and {@code null} otherwise.
*/
@@ -2565,9 +2571,7 @@
: requestedPosition >= topChildPosition;
int targetPosition = requestedPosition;
- if (toTop
- && mService.isStackVisibleLocked(PINNED_STACK_ID)
- && stack.mStackId != PINNED_STACK_ID) {
+ if (toTop && isStackVisible(PINNED_STACK_ID) && stack.mStackId != PINNED_STACK_ID) {
// The pinned stack is always the top most stack (always-on-top) when it is visible.
TaskStack topStack = mChildren.get(topChildPosition);
if (topStack.mStackId != PINNED_STACK_ID) {
@@ -2577,8 +2581,8 @@
// So, stack is moved just below the pinned stack.
// When we're adding a new stack the target is the current pinned stack position.
// When we're positioning an existing stack the target is the position below pinned
- // stack, because WindowContainer#positionAt() first removes element and then adds it
- // to specified place.
+ // stack, because WindowContainer#positionAt() first removes element and then adds
+ // it to specified place.
targetPosition = adding ? topChildPosition : topChildPosition - 1;
}