Loading services/core/java/com/android/server/wm/DeviceStateController.java +6 −2 Original line number Diff line number Diff line Loading @@ -111,9 +111,13 @@ final class DeviceStateController { } /** * @return true if the rotation direction on the Z axis should be reversed. * @return true if the rotation direction on the Z axis should be reversed for the default * display. */ boolean shouldReverseRotationDirectionAroundZAxis() { boolean shouldReverseRotationDirectionAroundZAxis(@NonNull DisplayContent displayContent) { if (!displayContent.isDefaultDisplay) { return false; } return ArrayUtils.contains(mReverseRotationAroundZAxisStates, mCurrentState); } Loading services/core/java/com/android/server/wm/DisplayRotation.java +2 −2 Original line number Diff line number Diff line Loading @@ -950,7 +950,7 @@ public class DisplayRotation { } void freezeRotation(int rotation) { if (mDeviceStateController.shouldReverseRotationDirectionAroundZAxis()) { if (mDeviceStateController.shouldReverseRotationDirectionAroundZAxis(mDisplayContent)) { rotation = RotationUtils.reverseRotationDirectionAroundZAxis(rotation); } Loading Loading @@ -1225,7 +1225,7 @@ public class DisplayRotation { if (mFoldController != null && mFoldController.shouldIgnoreSensorRotation()) { sensorRotation = -1; } if (mDeviceStateController.shouldReverseRotationDirectionAroundZAxis()) { if (mDeviceStateController.shouldReverseRotationDirectionAroundZAxis(mDisplayContent)) { sensorRotation = RotationUtils.reverseRotationDirectionAroundZAxis(sensorRotation); } mLastSensorRotation = sensorRotation; Loading services/tests/wmtests/src/com/android/server/wm/DisplayRotationTests.java +7 −4 Original line number Diff line number Diff line Loading @@ -59,10 +59,10 @@ import android.hardware.SensorEvent; import android.hardware.SensorEventListener; import android.hardware.SensorManager; import android.hardware.devicestate.DeviceStateManager; import android.os.Handler; import android.os.IBinder; import android.os.PowerManagerInternal; import android.os.SystemClock; import android.os.Handler; import android.platform.test.annotations.Presubmit; import android.provider.Settings; import android.view.DisplayAddress; Loading Loading @@ -518,7 +518,8 @@ public class DisplayRotationTests { mBuilder.build(); configureDisplayRotation(SCREEN_ORIENTATION_PORTRAIT, false, false); when(mDeviceStateController.shouldReverseRotationDirectionAroundZAxis()).thenReturn(true); when(mDeviceStateController.shouldReverseRotationDirectionAroundZAxis(mMockDisplayContent)) .thenReturn(true); thawRotation(); Loading @@ -544,7 +545,8 @@ public class DisplayRotationTests { @Test public void testFreezeRotation_reverseRotationDirectionAroundZAxis_yes() throws Exception { mBuilder.build(); when(mDeviceStateController.shouldReverseRotationDirectionAroundZAxis()).thenReturn(true); when(mDeviceStateController.shouldReverseRotationDirectionAroundZAxis(mMockDisplayContent)) .thenReturn(true); freezeRotation(Surface.ROTATION_90); assertEquals(Surface.ROTATION_270, mTarget.getUserRotation()); Loading @@ -553,7 +555,8 @@ public class DisplayRotationTests { @Test public void testFreezeRotation_reverseRotationDirectionAroundZAxis_no() throws Exception { mBuilder.build(); when(mDeviceStateController.shouldReverseRotationDirectionAroundZAxis()).thenReturn(false); when(mDeviceStateController.shouldReverseRotationDirectionAroundZAxis(mMockDisplayContent)) .thenReturn(false); freezeRotation(Surface.ROTATION_90); assertEquals(Surface.ROTATION_90, mTarget.getUserRotation()); Loading Loading
services/core/java/com/android/server/wm/DeviceStateController.java +6 −2 Original line number Diff line number Diff line Loading @@ -111,9 +111,13 @@ final class DeviceStateController { } /** * @return true if the rotation direction on the Z axis should be reversed. * @return true if the rotation direction on the Z axis should be reversed for the default * display. */ boolean shouldReverseRotationDirectionAroundZAxis() { boolean shouldReverseRotationDirectionAroundZAxis(@NonNull DisplayContent displayContent) { if (!displayContent.isDefaultDisplay) { return false; } return ArrayUtils.contains(mReverseRotationAroundZAxisStates, mCurrentState); } Loading
services/core/java/com/android/server/wm/DisplayRotation.java +2 −2 Original line number Diff line number Diff line Loading @@ -950,7 +950,7 @@ public class DisplayRotation { } void freezeRotation(int rotation) { if (mDeviceStateController.shouldReverseRotationDirectionAroundZAxis()) { if (mDeviceStateController.shouldReverseRotationDirectionAroundZAxis(mDisplayContent)) { rotation = RotationUtils.reverseRotationDirectionAroundZAxis(rotation); } Loading Loading @@ -1225,7 +1225,7 @@ public class DisplayRotation { if (mFoldController != null && mFoldController.shouldIgnoreSensorRotation()) { sensorRotation = -1; } if (mDeviceStateController.shouldReverseRotationDirectionAroundZAxis()) { if (mDeviceStateController.shouldReverseRotationDirectionAroundZAxis(mDisplayContent)) { sensorRotation = RotationUtils.reverseRotationDirectionAroundZAxis(sensorRotation); } mLastSensorRotation = sensorRotation; Loading
services/tests/wmtests/src/com/android/server/wm/DisplayRotationTests.java +7 −4 Original line number Diff line number Diff line Loading @@ -59,10 +59,10 @@ import android.hardware.SensorEvent; import android.hardware.SensorEventListener; import android.hardware.SensorManager; import android.hardware.devicestate.DeviceStateManager; import android.os.Handler; import android.os.IBinder; import android.os.PowerManagerInternal; import android.os.SystemClock; import android.os.Handler; import android.platform.test.annotations.Presubmit; import android.provider.Settings; import android.view.DisplayAddress; Loading Loading @@ -518,7 +518,8 @@ public class DisplayRotationTests { mBuilder.build(); configureDisplayRotation(SCREEN_ORIENTATION_PORTRAIT, false, false); when(mDeviceStateController.shouldReverseRotationDirectionAroundZAxis()).thenReturn(true); when(mDeviceStateController.shouldReverseRotationDirectionAroundZAxis(mMockDisplayContent)) .thenReturn(true); thawRotation(); Loading @@ -544,7 +545,8 @@ public class DisplayRotationTests { @Test public void testFreezeRotation_reverseRotationDirectionAroundZAxis_yes() throws Exception { mBuilder.build(); when(mDeviceStateController.shouldReverseRotationDirectionAroundZAxis()).thenReturn(true); when(mDeviceStateController.shouldReverseRotationDirectionAroundZAxis(mMockDisplayContent)) .thenReturn(true); freezeRotation(Surface.ROTATION_90); assertEquals(Surface.ROTATION_270, mTarget.getUserRotation()); Loading @@ -553,7 +555,8 @@ public class DisplayRotationTests { @Test public void testFreezeRotation_reverseRotationDirectionAroundZAxis_no() throws Exception { mBuilder.build(); when(mDeviceStateController.shouldReverseRotationDirectionAroundZAxis()).thenReturn(false); when(mDeviceStateController.shouldReverseRotationDirectionAroundZAxis(mMockDisplayContent)) .thenReturn(false); freezeRotation(Surface.ROTATION_90); assertEquals(Surface.ROTATION_90, mTarget.getUserRotation()); Loading