From 8bbb95fd4148272b09999cacd862943df86576ad Mon Sep 17 00:00:00 2001 From: Riddle Hsu Date: Thu, 16 Sep 2021 00:53:40 +0800 Subject: [PATCH] Update rotation with animating recents if the device will sleep Since live tile, the recents animation doesn't finish until back to the original activity or switch to other activity. If AOD shows when recents animates a task in different orientation, the rotation change will be skipped and cause the AOD screen to show with old rotation. Fix: 199527653 Test: DisplayContentTests#testRecentsNotRotatingWithFixedRotation Test: On a device with AOD2 enabled, enter recents from a landscape app and press power key to enter AOD. The notification shade should show in portrait. Change-Id: I134293cf083377b575f7560a39424a540ec53be9 --- .../core/java/com/android/server/wm/DisplayRotation.java | 4 +++- .../src/com/android/server/wm/DisplayContentTests.java | 6 ++++++ 2 files changed, 9 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 73d6cecd9155b..c9db14de507c0 100644 --- a/services/core/java/com/android/server/wm/DisplayRotation.java +++ b/services/core/java/com/android/server/wm/DisplayRotation.java @@ -444,7 +444,9 @@ public class DisplayRotation { } if (mDisplayContent.mFixedRotationTransitionListener - .isTopFixedOrientationRecentsAnimating()) { + .isTopFixedOrientationRecentsAnimating() + // If screen is off or the device is going to sleep, then still allow to update. + && mService.mPolicy.okToAnimate(false /* ignoreScreenOn */)) { // During the recents animation, the closing app might still be considered on top. // In order to ignore its requested orientation to avoid a sensor led rotation (e.g // user rotating the device while the recents animation is running), we ignore diff --git a/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java b/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java index 5a6581f941542..51e289f4d8336 100644 --- a/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java @@ -1565,6 +1565,12 @@ public class DisplayContentTests extends WindowTestsBase { mDisplayContent.mFixedRotationTransitionListener.onFinishRecentsAnimation(); assertTrue(displayRotation.updateRotationUnchecked(false)); + // Rotation can be updated if the policy is not ok to animate (e.g. going to sleep). + mDisplayContent.mFixedRotationTransitionListener.onStartRecentsAnimation(recentsActivity); + displayRotation.setRotation((displayRotation.getRotation() + 1) % 4); + ((TestWindowManagerPolicy) mWm.mPolicy).mOkToAnimate = false; + assertTrue(displayRotation.updateRotationUnchecked(false)); + // Rotation can be updated if the recents animation is animating but it is not on top, e.g. // switching activities in different orientations by quickstep gesture. mDisplayContent.mFixedRotationTransitionListener.onStartRecentsAnimation(recentsActivity);