Loading services/core/java/com/android/server/wm/DisplayRotation.java +10 −0 Original line number Diff line number Diff line Loading @@ -913,6 +913,16 @@ public class DisplayRotation { } void freezeRotation(int rotation) { if (mDeviceStateController.shouldReverseRotationDirectionAroundZAxis()) { // Flipping 270 and 90 has the same effect as changing the direction which rotation is // applied. if (rotation == Surface.ROTATION_90) { rotation = Surface.ROTATION_270; } else if (rotation == Surface.ROTATION_270) { rotation = Surface.ROTATION_90; } } rotation = (rotation == -1) ? mRotation : rotation; setUserRotation(WindowManagerPolicy.USER_ROTATION_LOCKED, rotation); } Loading services/tests/wmtests/src/com/android/server/wm/DisplayRotationTests.java +18 −0 Original line number Diff line number Diff line Loading @@ -537,6 +537,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); Loading Loading
services/core/java/com/android/server/wm/DisplayRotation.java +10 −0 Original line number Diff line number Diff line Loading @@ -913,6 +913,16 @@ public class DisplayRotation { } void freezeRotation(int rotation) { if (mDeviceStateController.shouldReverseRotationDirectionAroundZAxis()) { // Flipping 270 and 90 has the same effect as changing the direction which rotation is // applied. if (rotation == Surface.ROTATION_90) { rotation = Surface.ROTATION_270; } else if (rotation == Surface.ROTATION_270) { rotation = Surface.ROTATION_90; } } rotation = (rotation == -1) ? mRotation : rotation; setUserRotation(WindowManagerPolicy.USER_ROTATION_LOCKED, rotation); } Loading
services/tests/wmtests/src/com/android/server/wm/DisplayRotationTests.java +18 −0 Original line number Diff line number Diff line Loading @@ -537,6 +537,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); Loading