From c1a18dea89f0462979a31b7f1799cabd369a4135 Mon Sep 17 00:00:00 2001 From: Jiaming Liu Date: Fri, 28 Oct 2022 22:31:33 +0000 Subject: [PATCH] Fix invalidate rotation value which causes CTS failures The rotation value should be restored only if there is a valid value for mHalfFoldSavedRotation (i.e. mHalfFoldSavedRotation != -1), otherwise, the rotation value will become -1 and cause failures in tests. Bug: 255241217 Test: atest android.hardware.devicestate.cts.DeviceStateManagerTests Change-Id: I07f0d2543d345016c5508046e568e8372f048e27 --- services/core/java/com/android/server/wm/DisplayRotation.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/wm/DisplayRotation.java b/services/core/java/com/android/server/wm/DisplayRotation.java index a8d13c57ffa20..eaa08fd5eb0b8 100644 --- a/services/core/java/com/android/server/wm/DisplayRotation.java +++ b/services/core/java/com/android/server/wm/DisplayRotation.java @@ -1578,7 +1578,9 @@ public class DisplayRotation { false /* forceRelayout */); } else { // Revert the rotation to our saved value if we transition from HALF_FOLDED. - mRotation = mHalfFoldSavedRotation; + if (mHalfFoldSavedRotation != -1) { + mRotation = mHalfFoldSavedRotation; + } // Tell the device to update its orientation (mFoldState is still HALF_FOLDED here // so we will override USER_ROTATION_LOCKED and allow a rotation). mService.updateRotation(false /* alwaysSendConfiguration */,