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

Commit e566602a authored by Riddle Hsu's avatar Riddle Hsu Committed by Automerger Merge Worker
Browse files

Merge "Use seamless rotation if navigation bar allows" into udc-dev am: 7e390e71

parents 302d8085 7e390e71
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -300,9 +300,12 @@ public class DisplayLayout {
        return mAllowSeamlessRotationDespiteNavBarMoving;
    }

    /** @return whether the navigation bar will change sides during rotation. */
    /**
     * Returns {@code true} if the navigation bar will change sides during rotation and the display
     * is not square.
     */
    public boolean navigationBarCanMove() {
        return mNavigationBarCanMove;
        return mNavigationBarCanMove && mWidth != mHeight;
    }

    /** @return the rotation that would make the physical display "upside down". */
+9 −7
Original line number Diff line number Diff line
@@ -260,6 +260,12 @@ public class DefaultTransitionHandler implements Transitions.TransitionHandler {
        // This is the only way to get display-id currently, so check display capabilities here.
        final DisplayLayout displayLayout = displayController.getDisplayLayout(
                topTaskInfo.displayId);
        // This condition should be true when using gesture navigation or the screen size is large
        // (>600dp) because the bar is small relative to screen.
        if (displayLayout.allowSeamlessRotationDespiteNavBarMoving()) {
            ProtoLog.v(ShellProtoLogGroup.WM_SHELL_TRANSITIONS, "  nav bar allows seamless.");
            return ROTATION_ANIMATION_SEAMLESS;
        }
        // For the upside down rotation we don't rotate seamlessly as the navigation bar moves
        // position. Note most apps (using orientation:sensor or user as opposed to fullSensor)
        // will not enter the reverse portrait orientation, so actually the orientation won't
@@ -272,13 +278,9 @@ public class DefaultTransitionHandler implements Transitions.TransitionHandler {
            return animationHint;
        }

        // If the navigation bar can't change sides, then it will jump when we change orientations
        // and we don't rotate seamlessly - unless that is allowed, e.g. with gesture navigation
        // where the navbar is low-profile enough that this isn't very noticeable.
        if (!displayLayout.allowSeamlessRotationDespiteNavBarMoving()
                && (!(displayLayout.navigationBarCanMove()
                        && (displayChange.getStartAbsBounds().width()
                                != displayChange.getStartAbsBounds().height())))) {
        // If the navigation bar cannot change sides, then it will jump when changing orientation
        // so do not use seamless rotation.
        if (!displayLayout.navigationBarCanMove()) {
            ProtoLog.v(ShellProtoLogGroup.WM_SHELL_TRANSITIONS,
                    "  nav bar changes sides, so not seamless.");
            return animationHint;
+4 −3
Original line number Diff line number Diff line
@@ -702,8 +702,8 @@ public class ShellTransitionTests extends ShellTestCase {
                createTaskInfo(1, WINDOWING_MODE_PINNED, ACTIVITY_TYPE_STANDARD);

        final DisplayController displays = createTestDisplayController();
        final @Surface.Rotation int upsideDown = displays
                .getDisplayLayout(DEFAULT_DISPLAY).getUpsideDownRotation();
        final DisplayLayout displayLayout = displays.getDisplayLayout(DEFAULT_DISPLAY);
        final @Surface.Rotation int upsideDown = displayLayout.getUpsideDownRotation();

        TransitionInfo.Change displayChange = new ChangeBuilder(TRANSIT_CHANGE)
                .setFlags(FLAG_IS_DISPLAY).setRotate().build();
@@ -743,7 +743,8 @@ public class ShellTransitionTests extends ShellTestCase {
        assertEquals(ROTATION_ANIMATION_ROTATE, DefaultTransitionHandler.getRotationAnimationHint(
                displayChange, noTask, displays));

        // Not seamless if one of rotations is upside-down
        // Not seamless if the nav bar cares rotation and one of rotations is upside-down.
        doReturn(false).when(displayLayout).allowSeamlessRotationDespiteNavBarMoving();
        displayChange = new ChangeBuilder(TRANSIT_CHANGE).setFlags(FLAG_IS_DISPLAY)
                .setRotate(upsideDown, ROTATION_ANIMATION_UNSPECIFIED).build();
        final TransitionInfo seamlessUpsideDown = new TransitionInfoBuilder(TRANSIT_CHANGE)