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

Commit 160a3c57 authored by Jorim Jaggi's avatar Jorim Jaggi
Browse files

Fix invalid divider state while rotating

- Sometimes there is no window attached to the app token during a
rotation. In this case, we also want to return a valid dock side, so
we check for hiddenRequested instead of traversing the windows
of an app window token.
- The logic to notify SystemUI about rotation changes never really
worked. Remove the dock side check as the dock side is guaranteed
to change if we change the screen rotation
- Also clean up visibility methods a bit.

Test: Manually tested the interaction when in docked state landscape,
and going home with locked home rotation like 20 times. Also tested
multi-user interaction with docking.

Change-Id: Ibcd181cadc9bc5a97dbd20e67d15bb1c88de5b97
Fixes: 29569499
parent 80c031cb
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -637,7 +637,7 @@ class DisplayContent {
     */
    TaskStack getDockedStackVisibleForUserLocked() {
        final TaskStack stack = mService.mStackIdToStack.get(DOCKED_STACK_ID);
        return (stack != null && stack.isVisibleForUserLocked()) ? stack : null;
        return (stack != null && stack.isVisibleLocked(true /* ignoreKeyguard */)) ? stack : null;
    }

    /**
+0 −13
Original line number Diff line number Diff line
@@ -677,19 +677,6 @@ class Task implements DimLayer.DimLayerUser {
        return (tokensCount != 0) && mAppTokens.get(tokensCount - 1).showForAllUsers;
    }

    boolean isVisibleForUser() {
        for (int i = mAppTokens.size() - 1; i >= 0; i--) {
            final AppWindowToken appToken = mAppTokens.get(i);
            for (int j = appToken.allAppWindows.size() - 1; j >= 0; j--) {
                WindowState window = appToken.allAppWindows.get(j);
                if (!window.isHiddenFromUserLocked()) {
                    return true;
                }
            }
        }
        return false;
    }

    boolean isVisible() {
        for (int i = mAppTokens.size() - 1; i >= 0; i--) {
            final AppWindowToken appToken = mAppTokens.get(i);
+17 −29
Original line number Diff line number Diff line
@@ -398,14 +398,13 @@ public class TaskStack implements DimLayer.DimLayerUser,
            return false;
        }

        final int oldDockSide = mStackId == DOCKED_STACK_ID ? getDockSide() : DOCKED_INVALID;
        mTmpRect2.set(mBounds);
        mDisplayContent.rotateBounds(mRotation, newRotation, mTmpRect2);
        if (mStackId == DOCKED_STACK_ID) {
            repositionDockedStackAfterRotation(mTmpRect2);
            snapDockedStackAfterRotation(mTmpRect2);
            final int newDockSide = getDockSide(mTmpRect2);
            if (oldDockSide != newDockSide) {

            // Update the dock create mode and clear the dock create bounds, these
            // might change after a rotation and the original values will be invalid.
            mService.setDockedStackCreateStateLocked(
@@ -415,7 +414,6 @@ public class TaskStack implements DimLayer.DimLayerUser,
                    null);
            mDisplayContent.getDockedDividerController().notifyDockSideChanged(newDockSide);
        }
        }

        mBoundsAfterRotation.set(mTmpRect2);
        return true;
@@ -890,7 +888,7 @@ public class TaskStack implements DimLayer.DimLayerUser,
            mAdjustImeAmount = adjustAmount;
            mAdjustDividerAmount = adjustDividerAmount;
            updateAdjustedBounds();
            return isVisibleForUserLocked();
            return isVisibleLocked(true /* ignoreKeyguard */);
        } else {
            return false;
        }
@@ -926,7 +924,7 @@ public class TaskStack implements DimLayer.DimLayerUser,
        if (minimizeAmount != mMinimizeAmount) {
            mMinimizeAmount = minimizeAmount;
            updateAdjustedBounds();
            return isVisibleForUserLocked();
            return isVisibleLocked(true /* ignoreKeyguard*/);
        } else {
            return false;
        }
@@ -943,7 +941,7 @@ public class TaskStack implements DimLayer.DimLayerUser,
    void beginImeAdjustAnimation() {
        for (int j = mTasks.size() - 1; j >= 0; j--) {
            final Task task = mTasks.get(j);
            if (task.isVisibleForUser()) {
            if (task.isVisible()) {
                task.setDragResizing(true, DRAG_RESIZE_MODE_DOCKED_DIVIDER);
                task.addWindowsWaitingForDrawnIfResizingChanged();
            }
@@ -1233,9 +1231,13 @@ public class TaskStack implements DimLayer.DimLayerUser,
    }

    boolean isVisibleLocked() {
        return isVisibleLocked(false /* ignoreKeyguard */);
    }

    boolean isVisibleLocked(boolean ignoreKeyguard) {
        final boolean keyguardOn = mService.mPolicy.isKeyguardShowingOrOccluded()
                && !mService.mAnimator.mKeyguardGoingAway;
        if (keyguardOn && !StackId.isAllowedOverLockscreen(mStackId)) {
        if (!ignoreKeyguard && keyguardOn && !StackId.isAllowedOverLockscreen(mStackId)) {
            // The keyguard is showing and the stack shouldn't show on top of the keyguard.
            return false;
        }
@@ -1252,20 +1254,6 @@ public class TaskStack implements DimLayer.DimLayerUser,
        return false;
    }

    /**
     * @return true if a the stack is visible for the current in user, ignoring any other visibility
     *         aspects, and false otherwise
     */
    boolean isVisibleForUserLocked() {
        for (int i = mTasks.size() - 1; i >= 0; i--) {
            final Task task = mTasks.get(i);
            if (task.isVisibleForUser()) {
                return true;
            }
        }
        return false;
    }

    boolean isDragResizing() {
        return mDragResizing;
    }