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

Commit 3f6d0dca authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fixes rotating tablet changing original dock side in landscape"

parents 5d815009 cb1b8e46
Loading
Loading
Loading
Loading
+30 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import static android.content.res.Configuration.ORIENTATION_PORTRAIT;
import static android.view.Surface.ROTATION_270;
import static android.view.Surface.ROTATION_90;
import static android.view.WindowManager.DOCKED_BOTTOM;
import static android.view.WindowManager.DOCKED_INVALID;
import static android.view.WindowManager.DOCKED_LEFT;
import static android.view.WindowManager.DOCKED_RIGHT;
import static android.view.WindowManager.DOCKED_TOP;
@@ -116,6 +117,7 @@ public class DockedStackDividerController implements DimLayerUser {
    private final DimLayer mDimLayer;

    private boolean mMinimizedDock;
    private int mOriginalDockedSide = DOCKED_INVALID;
    private boolean mAnimatingForMinimizedDockedStack;
    private boolean mAnimationStarted;
    private long mAnimationStartTime;
@@ -408,6 +410,31 @@ public class DockedStackDividerController implements DimLayerUser {
        mDockedStackListeners.finishBroadcast();
    }

    /**
     * Checks if the primary stack is allowed to dock to a specific side based on its original dock
     * side.
     *
     * @param dockSide the side to see if it is valid
     * @return true if the side provided is valid
     */
    boolean canPrimaryStackDockTo(int dockSide) {
        if (mService.mPolicy.isDockSideAllowed(dockSide)) {
            // Side is the same as original side
            if (dockSide == mOriginalDockedSide) {
                return true;
            }
            // Special rule that the top in portrait is always valid
            if (dockSide == DOCKED_TOP) {
                return true;
            }
            // Only if original docked side was top in portrait will allow left side for landscape
            if (dockSide == DOCKED_LEFT && mOriginalDockedSide == DOCKED_TOP) {
                return true;
            }
        }
        return false;
    }

    void notifyDockedStackExistsChanged(boolean exists) {
        // TODO(multi-display): Perform all actions only for current display.
        final int size = mDockedStackListeners.beginBroadcast();
@@ -430,8 +457,11 @@ public class DockedStackDividerController implements DimLayerUser {
                inputMethodManagerInternal.hideCurrentInputMethod();
                mImeHideRequested = true;
            }
            final TaskStack stack = mDisplayContent.getSplitScreenPrimaryStackIgnoringVisibility();
            mOriginalDockedSide = stack.getDockSide();
            return;
        }
        mOriginalDockedSide = DOCKED_INVALID;
        setMinimizedDockedStack(false /* minimizedDock */, false /* animate */);
    }

+6 −6
Original line number Diff line number Diff line
@@ -442,7 +442,7 @@ public class TaskStack extends WindowContainer<Task> implements DimLayer.DimLaye
        mTmpRect2.set(mBounds);
        mDisplayContent.rotateBounds(mRotation, newRotation, mTmpRect2);
        if (inSplitScreenPrimaryWindowingMode()) {
            repositionDockedStackAfterRotation(mTmpRect2);
            repositionPrimarySplitScreenStackAfterRotation(mTmpRect2);
            snapDockedStackAfterRotation(mTmpRect2);
            final int newDockSide = getDockSide(mTmpRect2);

@@ -466,14 +466,14 @@ public class TaskStack extends WindowContainer<Task> implements DimLayer.DimLaye
    }

    /**
     * Some dock sides are not allowed by the policy. This method queries the policy and moves
     * the docked stack around if needed.
     * Some primary split screen sides are not allowed by the policy. This method queries the policy
     * and moves the primary stack around if needed.
     *
     * @param inOutBounds the bounds of the docked stack to adjust
     * @param inOutBounds the bounds of the primary stack to adjust
     */
    private void repositionDockedStackAfterRotation(Rect inOutBounds) {
    private void repositionPrimarySplitScreenStackAfterRotation(Rect inOutBounds) {
        int dockSide = getDockSide(inOutBounds);
        if (mService.mPolicy.isDockSideAllowed(dockSide)) {
        if (mDisplayContent.getDockedDividerController().canPrimaryStackDockTo(dockSide)) {
            return;
        }
        mDisplayContent.getLogicalDisplayRect(mTmpRect);