OSDN Git Service

Fix issue with split screen launch bounds
authorWinson Chung <winsonc@google.com>
Wed, 2 May 2018 01:17:19 +0000 (18:17 -0700)
committerWinson Chung <winsonc@google.com>
Wed, 16 May 2018 04:32:41 +0000 (21:32 -0700)
- In O, the fullscreen stack was resized once we enter splitscreen (and
  is updated with the tempOtherTaskBounds as we resize for minimized
  state). However, in P, since we are creating a new stack for each task,
  the launch of a task while in splitscreen now falls into
  TaskStack.updateBoundsForWindowModeChange() which incorrectly calculates
  the bounds of the secondary stack using the minimized bounds of the
  primary stack. Subsequent launches are fine because the stack already
  exists and is just being brought forward.

Bug: 73745166
Test: atest CtsActivityManagerDeviceTestCases:ActivityManagerSplitScreenTests
Test: Enter split screen, launch an app from scratch and ensure it
      animates to the right place

Change-Id: I7da856b9bb88db0db9616d56bb9fefdce918d7c3

services/core/java/com/android/server/wm/TaskStack.java

index 891ee2e..2fbb846 100644 (file)
@@ -800,7 +800,21 @@ public class TaskStack extends WindowContainer<Task> implements
     }
 
     private void updateBoundsForWindowModeChange() {
-        Rect bounds = null;
+        final Rect bounds = calculateBoundsForWindowModeChange();
+
+        if (inSplitScreenSecondaryWindowingMode()) {
+            // When the stack is resized due to entering split screen secondary, offset the
+            // windows to compensate for the new stack position.
+            forAllWindows(w -> {
+                w.mWinAnimator.setOffsetPositionForStackResize(true);
+            }, true);
+        }
+
+        updateDisplayInfo(bounds);
+        updateSurfaceBounds();
+    }
+
+    private Rect calculateBoundsForWindowModeChange() {
         final boolean inSplitScreenPrimary = inSplitScreenPrimaryWindowingMode();
         final TaskStack splitScreenStack =
                 mDisplayContent.getSplitScreenPrimaryStackIgnoringVisibility();
@@ -810,35 +824,37 @@ public class TaskStack extends WindowContainer<Task> implements
             // the docked stack occupies a dedicated region on screen, but only if the dock stack is
             // not fullscreen. If it's fullscreen, it means that we are in the transition of
             // dismissing it, so we must not resize this stack.
-            bounds = new Rect();
+            final Rect bounds = new Rect();
             mDisplayContent.getBounds(mTmpRect);
             mTmpRect2.setEmpty();
             if (splitScreenStack != null) {
-                splitScreenStack.getRawBounds(mTmpRect2);
+                if (inSplitScreenSecondaryWindowingMode()
+                        && mDisplayContent.mDividerControllerLocked.isMinimizedDock()
+                        && splitScreenStack.getTopChild() != null) {
+                    // If the primary split screen stack is currently minimized, then don't use the
+                    // stack bounds of the minimized stack, instead, use the temporary task bounds
+                    // to calculate the appropriate uniminized size of any secondary split stack
+                    // TODO: Find a cleaner way for computing new stack bounds while minimized that
+                    //       doesn't assume the primary stack's task bounds as the temp task bounds
+                    splitScreenStack.getTopChild().getBounds(mTmpRect2);
+                } else {
+                    splitScreenStack.getRawBounds(mTmpRect2);
+                }
             }
             final boolean dockedOnTopOrLeft = mService.mDockedStackCreateMode
                     == SPLIT_SCREEN_CREATE_MODE_TOP_OR_LEFT;
             getStackDockedModeBounds(mTmpRect, bounds, mTmpRect2,
                     mDisplayContent.mDividerControllerLocked.getContentWidth(), dockedOnTopOrLeft);
+            return bounds;
         } else if (inPinnedWindowingMode()) {
             // Update the bounds based on any changes to the display info
             getAnimationOrCurrentBounds(mTmpRect2);
             if (mDisplayContent.mPinnedStackControllerLocked.onTaskStackBoundsChanged(
                     mTmpRect2, mTmpRect3)) {
-                bounds = new Rect(mTmpRect3);
+                return new Rect(mTmpRect3);
             }
         }
-
-        if (inSplitScreenSecondaryWindowingMode()) {
-            // When the stack is resized due to entering split screen secondary, offset the
-            // windows to compensate for the new stack position.
-            forAllWindows(w -> {
-                w.mWinAnimator.setOffsetPositionForStackResize(true);
-            }, true);
-        }
-
-        updateDisplayInfo(bounds);
-        updateSurfaceBounds();
+        return null;
     }
 
     /**