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

Commit bf82de42 authored by Kevin Chyn's avatar Kevin Chyn Committed by Automerger Merge Worker
Browse files

Merge "Also reverse rotation for #freezeRotation path" into udc-dev am: e324ae00

parents 2fbc5690 e324ae00
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package android.util;
import static android.util.RotationUtils.rotateBounds;
import static android.util.RotationUtils.rotatePoint;
import static android.util.RotationUtils.rotatePointF;
import static android.view.Surface.ROTATION_0;
import static android.view.Surface.ROTATION_180;
import static android.view.Surface.ROTATION_270;
import static android.view.Surface.ROTATION_90;
@@ -103,4 +104,19 @@ public class RotationUtilsTest {
        assertEquals(560f, testResult.x, .1f);
        assertEquals(60f, testResult.y, .1f);
    }

    @Test
    public void testReverseRotationDirectionAroundZAxis() {
        assertEquals(ROTATION_90,
                RotationUtils.reverseRotationDirectionAroundZAxis(ROTATION_270));
        assertEquals(ROTATION_270,
                RotationUtils.reverseRotationDirectionAroundZAxis(ROTATION_90));
        assertEquals(ROTATION_0,
                RotationUtils.reverseRotationDirectionAroundZAxis(ROTATION_0));
        assertEquals(ROTATION_180,
                RotationUtils.reverseRotationDirectionAroundZAxis(ROTATION_180));

        assertEquals(-1,
                RotationUtils.reverseRotationDirectionAroundZAxis(-1));
    }
}
+4 −0
Original line number Diff line number Diff line
@@ -946,6 +946,10 @@ public class DisplayRotation {
    }

    void freezeRotation(int rotation) {
        if (mDeviceStateController.shouldReverseRotationDirectionAroundZAxis()) {
            rotation = RotationUtils.reverseRotationDirectionAroundZAxis(rotation);
        }

        rotation = (rotation == -1) ? mRotation : rotation;
        setUserRotation(WindowManagerPolicy.USER_ROTATION_LOCKED, rotation);
    }
+18 −0
Original line number Diff line number Diff line
@@ -541,6 +541,24 @@ public class DisplayRotationTests {
                SCREEN_ORIENTATION_UNSPECIFIED, Surface.ROTATION_180));
    }

    @Test
    public void testFreezeRotation_reverseRotationDirectionAroundZAxis_yes() throws Exception {
        mBuilder.build();
        when(mDeviceStateController.shouldReverseRotationDirectionAroundZAxis()).thenReturn(true);

        freezeRotation(Surface.ROTATION_90);
        assertEquals(Surface.ROTATION_270, mTarget.getUserRotation());
    }

    @Test
    public void testFreezeRotation_reverseRotationDirectionAroundZAxis_no() throws Exception {
        mBuilder.build();
        when(mDeviceStateController.shouldReverseRotationDirectionAroundZAxis()).thenReturn(false);

        freezeRotation(Surface.ROTATION_90);
        assertEquals(Surface.ROTATION_90, mTarget.getUserRotation());
    }

    private boolean waitForUiHandler() {
        final CountDownLatch latch = new CountDownLatch(1);
        UiThread.getHandler().post(latch::countDown);