From 27f2ae36763ddb6f71ae3e5c99cf79c5a8473714 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Mazzucato?= Date: Mon, 27 Mar 2023 18:01:18 +0000 Subject: [PATCH] Revert "Add a delay to rotation updates to help avoid fold state race" This reverts commit 48c42107e624f50f0d6f0381a3649da139eef5e2. Reason for revert: b/275032356 Change-Id: I129d1d9876542ba152e07664ad08acfb0425f24a --- .../java/com/android/server/wm/DisplayRotation.java | 12 +++++------- .../com/android/server/wm/DisplayRotationTests.java | 4 ++-- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/services/core/java/com/android/server/wm/DisplayRotation.java b/services/core/java/com/android/server/wm/DisplayRotation.java index 57ee2744b5515..c0ed08d2607d9 100644 --- a/services/core/java/com/android/server/wm/DisplayRotation.java +++ b/services/core/java/com/android/server/wm/DisplayRotation.java @@ -87,8 +87,6 @@ import java.util.Set; */ public class DisplayRotation { private static final String TAG = TAG_WITH_CLASS_NAME ? "DisplayRotation" : TAG_WM; - // Delay to avoid race between fold update and orientation update. - private static final int ORIENTATION_UPDATE_DELAY_MS = 800; // Delay in milliseconds when updating config due to folding events. This prevents // config changes and unexpected jumps while folding the device to closed state. @@ -1740,15 +1738,15 @@ public class DisplayRotation { mDeviceState = newState; // Now mFoldState is set to HALF_FOLDED, the overrideFrozenRotation function will // return true, so rotation is unlocked. + mService.updateRotation(false /* alwaysSendConfiguration */, + false /* forceRelayout */); } else { mInHalfFoldTransition = true; mDeviceState = newState; + // Tell the device to update its orientation. + mService.updateRotation(false /* alwaysSendConfiguration */, + false /* forceRelayout */); } - UiThread.getHandler().postDelayed( - () -> { - mService.updateRotation(false /* alwaysSendConfiguration */, - false /* forceRelayout */); - }, ORIENTATION_UPDATE_DELAY_MS); // Alert the activity of possible new bounds. UiThread.getHandler().removeCallbacks(mActivityBoundsUpdateCallback); UiThread.getHandler().postDelayed(mActivityBoundsUpdateCallback, 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 eb82cedad278f..ed2b0a36cd5c8 100644 --- a/services/tests/wmtests/src/com/android/server/wm/DisplayRotationTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/DisplayRotationTests.java @@ -748,7 +748,7 @@ public class DisplayRotationTests { // ... until half-fold mTarget.foldStateChanged(DeviceStateController.DeviceState.HALF_FOLDED); assertTrue(waitForUiHandler()); - verify(sMockWm).updateRotation(anyBoolean(), anyBoolean()); + verify(sMockWm).updateRotation(false, false); assertTrue(waitForUiHandler()); assertEquals(Surface.ROTATION_0, mTarget.rotationForOrientation( SCREEN_ORIENTATION_UNSPECIFIED, Surface.ROTATION_0)); @@ -756,7 +756,7 @@ public class DisplayRotationTests { // ... then transition back to flat mTarget.foldStateChanged(DeviceStateController.DeviceState.OPEN); assertTrue(waitForUiHandler()); - verify(sMockWm, atLeast(1)).updateRotation(anyBoolean(), anyBoolean()); + verify(sMockWm, atLeast(1)).updateRotation(false, false); assertTrue(waitForUiHandler()); assertEquals(Surface.ROTATION_270, mTarget.rotationForOrientation( SCREEN_ORIENTATION_UNSPECIFIED, Surface.ROTATION_0));