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
This commit is contained in:
Jiaming Liu
2022-10-28 22:31:33 +00:00
parent fac53656ed
commit c1a18dea89

View File

@@ -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 */,