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

Commit 14c38b43 authored by Riddle Hsu's avatar Riddle Hsu Committed by android-build-merger
Browse files

Merge "Fix incorrect bounds of split-screen when rotation changes" into qt-dev

am: 9e6b293c

Change-Id: I4487aa0566939709a9a1c6c4f08d3e28b7c710e8
parents 69b7eba6 9e6b293c
Loading
Loading
Loading
Loading
+45 −49
Original line number Original line Diff line number Diff line
@@ -281,8 +281,9 @@ class ActivityStack extends ConfigurationContainer {
        if (display != null && inSplitScreenPrimaryWindowingMode()) {
        if (display != null && inSplitScreenPrimaryWindowingMode()) {
            // If we created a docked stack we want to resize it so it resizes all other stacks
            // If we created a docked stack we want to resize it so it resizes all other stacks
            // in the system.
            // in the system.
            getStackDockedModeBounds(null, null, mTmpRect2, mTmpRect3);
            getStackDockedModeBounds(null /* dockedBounds */, null /* currentTempTaskBounds */,
            mStackSupervisor.resizeDockedStackLocked(getRequestedOverrideBounds(), mTmpRect2,
                    mTmpRect /* outStackBounds */, mTmpRect2 /* outTempTaskBounds */);
            mStackSupervisor.resizeDockedStackLocked(getRequestedOverrideBounds(), mTmpRect,
                    mTmpRect2, null, null, PRESERVE_WINDOWS);
                    mTmpRect2, null, null, PRESERVE_WINDOWS);
        }
        }
        mRootActivityContainer.updateUIDsPresentOnDisplay();
        mRootActivityContainer.updateUIDsPresentOnDisplay();
@@ -396,7 +397,6 @@ class ActivityStack extends ConfigurationContainer {


    private final Rect mTmpRect = new Rect();
    private final Rect mTmpRect = new Rect();
    private final Rect mTmpRect2 = new Rect();
    private final Rect mTmpRect2 = new Rect();
    private final Rect mTmpRect3 = new Rect();
    private final ActivityOptions mTmpOptions = ActivityOptions.makeBasic();
    private final ActivityOptions mTmpOptions = ActivityOptions.makeBasic();


    /** List for processing through a set of activities */
    /** List for processing through a set of activities */
@@ -512,7 +512,6 @@ class ActivityStack extends ConfigurationContainer {
        mWindowManager = mService.mWindowManager;
        mWindowManager = mService.mWindowManager;
        mStackId = stackId;
        mStackId = stackId;
        mCurrentUser = mService.mAmInternal.getCurrentUserId();
        mCurrentUser = mService.mAmInternal.getCurrentUserId();
        mTmpRect2.setEmpty();
        // Set display id before setting activity and window type to make sure it won't affect
        // Set display id before setting activity and window type to make sure it won't affect
        // stacks on a wrong display.
        // stacks on a wrong display.
        mDisplayId = display.mDisplayId;
        mDisplayId = display.mDisplayId;
@@ -572,90 +571,87 @@ class ActivityStack extends ConfigurationContainer {
    public void onConfigurationChanged(Configuration newParentConfig) {
    public void onConfigurationChanged(Configuration newParentConfig) {
        final int prevWindowingMode = getWindowingMode();
        final int prevWindowingMode = getWindowingMode();
        final boolean prevIsAlwaysOnTop = isAlwaysOnTop();
        final boolean prevIsAlwaysOnTop = isAlwaysOnTop();
        final ActivityDisplay display = getDisplay();
        final int prevRotation = getWindowConfiguration().getRotation();
        final int prevRotation = getWindowConfiguration().getRotation();
        final int prevDensity = getConfiguration().densityDpi;
        final int prevDensity = getConfiguration().densityDpi;
        final int prevScreenW = getConfiguration().screenWidthDp;
        final int prevScreenW = getConfiguration().screenWidthDp;
        final int prevScreenH = getConfiguration().screenHeightDp;
        final int prevScreenH = getConfiguration().screenHeightDp;

        final Rect newBounds = mTmpRect;
        getBounds(mTmpRect); // previous bounds
        // Initialize the new bounds by previous bounds as the input and output for calculating
        // override bounds in pinned (pip) or split-screen mode.
        getBounds(newBounds);


        super.onConfigurationChanged(newParentConfig);
        super.onConfigurationChanged(newParentConfig);
        if (display == null) {
        final ActivityDisplay display = getDisplay();
            return;
        if (display == null || getTaskStack() == null) {
        }
        if (getTaskStack() == null) {
            return;
            return;
        }
        }


        final boolean windowingModeChanged = prevWindowingMode != getWindowingMode();
        final int overrideWindowingMode = getRequestedOverrideWindowingMode();
        // Update bounds if applicable
        // Update bounds if applicable
        boolean hasNewOverrideBounds = false;
        boolean hasNewOverrideBounds = false;
        // Use override windowing mode to prevent extra bounds changes if inheriting the mode.
        // Use override windowing mode to prevent extra bounds changes if inheriting the mode.
        if (getRequestedOverrideWindowingMode() == WINDOWING_MODE_PINNED) {
        if (overrideWindowingMode == WINDOWING_MODE_PINNED) {
            // Pinned calculation already includes rotation
            // Pinned calculation already includes rotation
            mTmpRect2.set(mTmpRect);
            hasNewOverrideBounds = getTaskStack().calculatePinnedBoundsForConfigChange(newBounds);
            hasNewOverrideBounds = getTaskStack().calculatePinnedBoundsForConfigChange(mTmpRect2);
        } else if (!matchParentBounds()) {
        } else {
            final int newRotation = getWindowConfiguration().getRotation();
            if (!matchParentBounds()) {
            // If the parent (display) has rotated, rotate our bounds to best-fit where their
            // If the parent (display) has rotated, rotate our bounds to best-fit where their
            // bounds were on the pre-rotated display.
            // bounds were on the pre-rotated display.
                if (prevRotation != newRotation) {
            final int newRotation = getWindowConfiguration().getRotation();
                    mTmpRect2.set(mTmpRect);
            final boolean rotationChanged = prevRotation != newRotation;
                    getDisplay().mDisplayContent
            if (rotationChanged) {
                            .rotateBounds(newParentConfig.windowConfiguration.getBounds(),
                display.mDisplayContent.rotateBounds(
                                    prevRotation, newRotation, mTmpRect2);
                        newParentConfig.windowConfiguration.getBounds(), prevRotation, newRotation,
                        newBounds);
                hasNewOverrideBounds = true;
                hasNewOverrideBounds = true;
            }
            }


            // Use override windowing mode to prevent extra bounds changes if inheriting the mode.
            if (overrideWindowingMode == WINDOWING_MODE_SPLIT_SCREEN_PRIMARY
                    || overrideWindowingMode == WINDOWING_MODE_SPLIT_SCREEN_SECONDARY) {
                // If entering split screen or if something about the available split area changes,
                // If entering split screen or if something about the available split area changes,
                // recalculate the split windows to match the new configuration.
                // recalculate the split windows to match the new configuration.
                if (prevRotation != newRotation
                if (rotationChanged || windowingModeChanged
                        || prevDensity != getConfiguration().densityDpi
                        || prevDensity != getConfiguration().densityDpi
                        || prevWindowingMode != getWindowingMode()
                        || prevScreenW != getConfiguration().screenWidthDp
                        || prevScreenW != getConfiguration().screenWidthDp
                        || prevScreenH != getConfiguration().screenHeightDp) {
                        || prevScreenH != getConfiguration().screenHeightDp) {
                    // Use override windowing mode to prevent extra bounds changes if inheriting
                    getTaskStack().calculateDockedBoundsForConfigChange(newParentConfig, newBounds);
                    // the mode.
                    if (getRequestedOverrideWindowingMode() == WINDOWING_MODE_SPLIT_SCREEN_PRIMARY
                            || getRequestedOverrideWindowingMode()
                            == WINDOWING_MODE_SPLIT_SCREEN_SECONDARY) {
                        mTmpRect2.set(mTmpRect);
                        getTaskStack()
                                .calculateDockedBoundsForConfigChange(newParentConfig, mTmpRect2);
                    hasNewOverrideBounds = true;
                    hasNewOverrideBounds = true;
                }
                }
            }
            }
        }
        }
        }

        if (getWindowingMode() != prevWindowingMode) {
        if (windowingModeChanged) {
            // Use override windowing mode to prevent extra bounds changes if inheriting the mode.
            // Use override windowing mode to prevent extra bounds changes if inheriting the mode.
            if (getRequestedOverrideWindowingMode() == WINDOWING_MODE_SPLIT_SCREEN_PRIMARY) {
            if (overrideWindowingMode == WINDOWING_MODE_SPLIT_SCREEN_PRIMARY) {
                getStackDockedModeBounds(null, null, mTmpRect2, mTmpRect3);
                getStackDockedModeBounds(null /* dockedBounds */, null /* currentTempTaskBounds */,
                        newBounds /* outStackBounds */, mTmpRect2 /* outTempTaskBounds */);
                // immediately resize so docked bounds are available in onSplitScreenModeActivated
                // immediately resize so docked bounds are available in onSplitScreenModeActivated
                setTaskDisplayedBounds(null);
                setTaskDisplayedBounds(null);
                setTaskBounds(mTmpRect2);
                setTaskBounds(newBounds);
                setBounds(mTmpRect2);
                setBounds(newBounds);
            } else if (
                newBounds.set(newBounds);
                    getRequestedOverrideWindowingMode() == WINDOWING_MODE_SPLIT_SCREEN_SECONDARY) {
            } else if (overrideWindowingMode == WINDOWING_MODE_SPLIT_SCREEN_SECONDARY) {
                Rect dockedBounds = display.getSplitScreenPrimaryStack().getBounds();
                Rect dockedBounds = display.getSplitScreenPrimaryStack().getBounds();
                final boolean isMinimizedDock =
                final boolean isMinimizedDock =
                        getDisplay().mDisplayContent.getDockedDividerController().isMinimizedDock();
                        display.mDisplayContent.getDockedDividerController().isMinimizedDock();
                if (isMinimizedDock) {
                if (isMinimizedDock) {
                    TaskRecord topTask = display.getSplitScreenPrimaryStack().topTask();
                    TaskRecord topTask = display.getSplitScreenPrimaryStack().topTask();
                    if (topTask != null) {
                    if (topTask != null) {
                        dockedBounds = topTask.getBounds();
                        dockedBounds = topTask.getBounds();
                    }
                    }
                }
                }
                getStackDockedModeBounds(dockedBounds, null, mTmpRect2, mTmpRect3);
                getStackDockedModeBounds(dockedBounds, null /* currentTempTaskBounds */,
                        newBounds /* outStackBounds */, mTmpRect2 /* outTempTaskBounds */);
                hasNewOverrideBounds = true;
                hasNewOverrideBounds = true;
            }
            }
        }
        if (prevWindowingMode != getWindowingMode()) {
            display.onStackWindowingModeChanged(this);
            display.onStackWindowingModeChanged(this);
        }
        }
        if (hasNewOverrideBounds) {
        if (hasNewOverrideBounds) {
            mRootActivityContainer.resizeStack(this, mTmpRect2, null, null, PRESERVE_WINDOWS,
            // Note the resizeStack may enter onConfigurationChanged recursively, so we make a copy
            // of the temporary bounds (newBounds is mTmpRect) to avoid it being modified.
            mRootActivityContainer.resizeStack(this, new Rect(newBounds), null /* tempTaskBounds */,
                    null /* tempTaskInsetBounds */, PRESERVE_WINDOWS,
                    true /* allowResizeInDockedMode */, true /* deferResume */);
                    true /* allowResizeInDockedMode */, true /* deferResume */);
        }
        }
        if (prevIsAlwaysOnTop != isAlwaysOnTop()) {
        if (prevIsAlwaysOnTop != isAlwaysOnTop()) {