diff options
3 files changed, 15 insertions, 8 deletions
diff --git a/services/core/java/com/android/server/wm/DeviceStateController.java b/services/core/java/com/android/server/wm/DeviceStateController.java index 31b1069dd022..db4762e5f877 100644 --- a/services/core/java/com/android/server/wm/DeviceStateController.java +++ b/services/core/java/com/android/server/wm/DeviceStateController.java @@ -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); } diff --git a/services/core/java/com/android/server/wm/DisplayRotation.java b/services/core/java/com/android/server/wm/DisplayRotation.java index 8be36f07a040..b681c198538f 100644 --- a/services/core/java/com/android/server/wm/DisplayRotation.java +++ b/services/core/java/com/android/server/wm/DisplayRotation.java @@ -950,7 +950,7 @@ public class DisplayRotation { } void freezeRotation(int rotation) { - if (mDeviceStateController.shouldReverseRotationDirectionAroundZAxis()) { + if (mDeviceStateController.shouldReverseRotationDirectionAroundZAxis(mDisplayContent)) { rotation = RotationUtils.reverseRotationDirectionAroundZAxis(rotation); } @@ -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; diff --git a/services/tests/wmtests/src/com/android/server/wm/DisplayRotationTests.java b/services/tests/wmtests/src/com/android/server/wm/DisplayRotationTests.java index 04e1d9c07a07..2a8f0ffc4d49 100644 --- a/services/tests/wmtests/src/com/android/server/wm/DisplayRotationTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/DisplayRotationTests.java @@ -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; @@ -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(); @@ -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()); @@ -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()); |