From 6a0044a07cbcf633bf8e9a9b5fecd57d279d7d07 Mon Sep 17 00:00:00 2001 From: Nick Chameyev Date: Fri, 15 Oct 2021 15:10:06 +0000 Subject: Do not run rotation animation when folding/unfolding Disables screen freezing and rotation animation when screen blocker is not removed (e.g. when folding or unfoding a foldable device with two screens). Fixes: 199897277 Test: manual fold/unfolds on foldable devices Test: rotation animation works on inner/outer screen Change-Id: I2b353b5cb31042cdf4789915a04510062231e29c --- services/core/java/com/android/server/wm/WindowManagerService.java | 4 +++- .../tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java index 4cde0489bba3..02b6e4e2a276 100644 --- a/services/core/java/com/android/server/wm/WindowManagerService.java +++ b/services/core/java/com/android/server/wm/WindowManagerService.java @@ -5824,7 +5824,9 @@ public class WindowManagerService extends IWindowManager.Stub return; } - if (!displayContent.isReady() || !mPolicy.isScreenOn() || !displayContent.okToAnimate()) { + if (!displayContent.isReady() || !displayContent.getDisplayPolicy().isScreenOnFully() + || displayContent.getDisplayInfo().state == Display.STATE_OFF + || !displayContent.okToAnimate()) { // No need to freeze the screen before the display is ready, if the screen is off, // or we can't currently animate. return; diff --git a/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java b/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java index 65733d7a4129..a50ceabae445 100644 --- a/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java @@ -1751,6 +1751,11 @@ public class ActivityRecordTests extends WindowTestsBase { anyInt() /* orientation */, anyInt() /* lastRotation */); // Set to visible so the activity can freeze the screen. activity.setVisibility(true); + // Update the display policy to make the screen fully turned on so the freeze is allowed + display.getDisplayPolicy().screenTurnedOn(null); + display.getDisplayPolicy().finishKeyguardDrawn(); + display.getDisplayPolicy().finishWindowsDrawn(); + display.getDisplayPolicy().finishScreenTurningOn(); display.rotateInDifferentOrientationIfNeeded(activity); display.setFixedRotationLaunchingAppUnchecked(activity); -- cgit v1.2.3-59-g8ed1b