diff options
| -rw-r--r-- | services/core/java/com/android/server/wm/DisplayContent.java | 2 | ||||
| -rw-r--r-- | services/tests/wmtests/src/com/android/server/wm/RecentsAnimationControllerTest.java | 35 |
2 files changed, 27 insertions, 10 deletions
diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java index a70e30f380f9..adf0b44040d9 100644 --- a/services/core/java/com/android/server/wm/DisplayContent.java +++ b/services/core/java/com/android/server/wm/DisplayContent.java @@ -5728,7 +5728,7 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo } if (animatingRecents != null && animatingRecents == mFixedRotationLaunchingApp - && animatingRecents.isVisible()) { + && animatingRecents.isVisible() && animatingRecents != topRunningActivity()) { // The recents activity should be going to be invisible (switch to another app or // return to original top). Only clear the top launching record without finishing // the transform immediately because it won't affect display orientation. And before diff --git a/services/tests/wmtests/src/com/android/server/wm/RecentsAnimationControllerTest.java b/services/tests/wmtests/src/com/android/server/wm/RecentsAnimationControllerTest.java index cfc50b5e95dc..d99fd0f3d18e 100644 --- a/services/tests/wmtests/src/com/android/server/wm/RecentsAnimationControllerTest.java +++ b/services/tests/wmtests/src/com/android/server/wm/RecentsAnimationControllerTest.java @@ -393,23 +393,25 @@ public class RecentsAnimationControllerTest extends WindowTestsBase { // Simulate giving up the swipe up gesture to keep the original activity as top. mController.cleanupAnimation(REORDER_MOVE_TO_ORIGINAL_POSITION); // The rotation transform should be cleared after updating orientation with display. - assertFalse(activity.hasFixedRotationTransform()); - assertFalse(mDefaultDisplay.hasTopFixedRotationLaunchingApp()); + assertTopFixedRotationLaunchingAppCleared(activity); // Simulate swiping up recents (home) in different rotation. final ActivityRecord home = mDefaultDisplay.getDefaultTaskDisplayArea().getHomeActivity(); - mDefaultDisplay.setFixedRotationLaunchingApp(home, (mDefaultDisplay.getRotation() + 1) % 4); - mController = new RecentsAnimationController(mWm, mMockRunner, mAnimationCallbacks, - mDefaultDisplay.getDisplayId()); - initializeRecentsAnimationController(mController, home); - assertTrue(home.hasFixedRotationTransform()); + startRecentsInDifferentRotation(home); + // If the recents activity becomes the top running activity (e.g. the original top activity + // is either finishing or moved to back during recents animation), the display orientation + // will be determined by it so the fixed rotation must be cleared. + activity.finishing = true; + mController.cleanupAnimation(REORDER_MOVE_TO_ORIGINAL_POSITION); + assertTopFixedRotationLaunchingAppCleared(home); + + startRecentsInDifferentRotation(home); // Assume recents activity becomes invisible for some reason (e.g. screen off). home.setVisible(false); mController.cleanupAnimation(REORDER_MOVE_TO_ORIGINAL_POSITION); // Although there won't be a transition finish callback, the fixed rotation must be cleared. - assertFalse(home.hasFixedRotationTransform()); - assertFalse(mDefaultDisplay.hasTopFixedRotationLaunchingApp()); + assertTopFixedRotationLaunchingAppCleared(home); } @Test @@ -503,6 +505,21 @@ public class RecentsAnimationControllerTest extends WindowTestsBase { return homeActivity; } + private void startRecentsInDifferentRotation(ActivityRecord recentsActivity) { + final DisplayContent displayContent = recentsActivity.mDisplayContent; + displayContent.setFixedRotationLaunchingApp(recentsActivity, + (displayContent.getRotation() + 1) % 4); + mController = new RecentsAnimationController(mWm, mMockRunner, mAnimationCallbacks, + displayContent.getDisplayId()); + initializeRecentsAnimationController(mController, recentsActivity); + assertTrue(recentsActivity.hasFixedRotationTransform()); + } + + private static void assertTopFixedRotationLaunchingAppCleared(ActivityRecord activity) { + assertFalse(activity.hasFixedRotationTransform()); + assertFalse(activity.mDisplayContent.hasTopFixedRotationLaunchingApp()); + } + private static void initializeRecentsAnimationController(RecentsAnimationController controller, ActivityRecord activity) { controller.initialize(activity.getActivityType(), new SparseBooleanArray(), activity); |