Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 985f54da authored by Winson Chung's avatar Winson Chung
Browse files

Fix issue with split screen launch bounds

- 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
parent 869c6f55
Loading
Loading
Loading
Loading
+31 −15
Original line number Diff line number Diff line
@@ -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) {
                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;
    }

    /**