diff options
5 files changed, 37 insertions, 11 deletions
diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java index 3272a5d90d4e..b6672d3c73c0 100644 --- a/services/core/java/com/android/server/wm/DisplayContent.java +++ b/services/core/java/com/android/server/wm/DisplayContent.java @@ -1486,8 +1486,16 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo return true; } - @Nullable ActivityRecord getFixedRotationLaunchingApp() { - return mFixedRotationLaunchingApp; + /** Returns {@code true} if the top activity is transformed with the new rotation of display. */ + boolean hasTopFixedRotationLaunchingApp() { + return mFixedRotationLaunchingApp != null + // Ignore animating recents because it hasn't really become the top. + && mFixedRotationLaunchingApp != mFixedRotationTransitionListener.mAnimatingRecents; + } + + @VisibleForTesting + boolean isFixedRotationLaunchingApp(ActivityRecord r) { + return mFixedRotationLaunchingApp == r; } @VisibleForTesting diff --git a/services/core/java/com/android/server/wm/DisplayRotation.java b/services/core/java/com/android/server/wm/DisplayRotation.java index 96f236310d83..831491dd145e 100644 --- a/services/core/java/com/android/server/wm/DisplayRotation.java +++ b/services/core/java/com/android/server/wm/DisplayRotation.java @@ -582,7 +582,7 @@ public class DisplayRotation { boolean shouldRotateSeamlessly(int oldRotation, int newRotation, boolean forceUpdate) { // Display doesn't need to be frozen because application has been started in correct // rotation already, so the rest of the windows can use seamless rotation. - if (mDisplayContent.getFixedRotationLaunchingApp() != null) { + if (mDisplayContent.hasTopFixedRotationLaunchingApp()) { return true; } 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 063568d0380c..4f14cd0b6fd9 100644 --- a/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java @@ -1412,7 +1412,7 @@ public class ActivityRecordTests extends ActivityTestsBase { // The launching rotated app should not be cleared when waiting for remote rotation. display.continueUpdateOrientationForDiffOrienLaunchingApp(); - assertNotNull(display.getFixedRotationLaunchingApp()); + assertTrue(display.isFixedRotationLaunchingApp(mActivity)); // Simulate the rotation has been updated to previous one, e.g. sensor updates before the // remote rotation is completed. @@ -1441,7 +1441,7 @@ public class ActivityRecordTests extends ActivityTestsBase { display.setFixedRotationLaunchingAppUnchecked(mActivity); display.sendNewConfiguration(); - assertNull(display.getFixedRotationLaunchingApp()); + assertFalse(display.hasTopFixedRotationLaunchingApp()); assertFalse(mActivity.hasFixedRotationTransform()); } @@ -1497,7 +1497,7 @@ public class ActivityRecordTests extends ActivityTestsBase { // rotation should be applied when creating snapshot surface if the display rotation may be // changed according to the activity orientation. assertTrue(mActivity.hasFixedRotationTransform()); - assertEquals(mActivity, mActivity.mDisplayContent.getFixedRotationLaunchingApp()); + assertTrue(mActivity.mDisplayContent.isFixedRotationLaunchingApp(mActivity)); } /** 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 d063f10d52e2..7be2b732ac62 100644 --- a/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java @@ -1148,6 +1148,24 @@ public class DisplayContentTests extends WindowTestsBase { } @Test + public void testRotateSeamlesslyWithFixedRotation() { + final DisplayRotation displayRotation = mDisplayContent.getDisplayRotation(); + final ActivityRecord app = mAppWindow.mActivityRecord; + mDisplayContent.setFixedRotationLaunchingAppUnchecked(app); + mAppWindow.mAttrs.rotationAnimation = WindowManager.LayoutParams.ROTATION_ANIMATION_ROTATE; + + // Use seamless rotation if the top app is rotated. + assertTrue(displayRotation.shouldRotateSeamlessly(ROTATION_0 /* oldRotation */, + ROTATION_90 /* newRotation */, false /* forceUpdate */)); + + mDisplayContent.mFixedRotationTransitionListener.onStartRecentsAnimation(app); + + // Use normal rotation because animating recents is an intermediate state. + assertFalse(displayRotation.shouldRotateSeamlessly(ROTATION_0 /* oldRotation */, + ROTATION_90 /* newRotation */, false /* forceUpdate */)); + } + + @Test public void testRemoteRotation() { DisplayContent dc = createNewDisplay(); 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 f330f0fc9f0b..ca6679d1eece 100644 --- a/services/tests/wmtests/src/com/android/server/wm/RecentsAnimationControllerTest.java +++ b/services/tests/wmtests/src/com/android/server/wm/RecentsAnimationControllerTest.java @@ -343,7 +343,7 @@ public class RecentsAnimationControllerTest extends WindowTestsBase { initializeRecentsAnimationController(mController, homeActivity); - assertEquals(homeActivity, mDefaultDisplay.getFixedRotationLaunchingApp()); + assertTrue(mDefaultDisplay.isFixedRotationLaunchingApp(homeActivity)); // Check that the home app is in portrait assertEquals(Configuration.ORIENTATION_PORTRAIT, @@ -353,7 +353,7 @@ public class RecentsAnimationControllerTest extends WindowTestsBase { // top rotated record should be cleared. mController.cleanupAnimation(REORDER_MOVE_TO_ORIGINAL_POSITION); assertFalse(homeActivity.hasFixedRotationTransform()); - assertNull(mDefaultDisplay.getFixedRotationLaunchingApp()); + assertFalse(mDefaultDisplay.hasTopFixedRotationLaunchingApp()); } @Test @@ -367,7 +367,7 @@ public class RecentsAnimationControllerTest extends WindowTestsBase { (mDefaultDisplay.getRotation() + 1) % 4); assertTrue(activity.hasFixedRotationTransform()); - assertEquals(activity, mDefaultDisplay.getFixedRotationLaunchingApp()); + assertTrue(mDefaultDisplay.isFixedRotationLaunchingApp(activity)); // Before the transition is done, the recents animation is triggered. initializeRecentsAnimationController(mController, homeActivity); @@ -377,7 +377,7 @@ public class RecentsAnimationControllerTest extends WindowTestsBase { mController.cleanupAnimation(REORDER_MOVE_TO_ORIGINAL_POSITION); // The rotation transform should be cleared after updating orientation with display. assertFalse(activity.hasFixedRotationTransform()); - assertNull(mDefaultDisplay.getFixedRotationLaunchingApp()); + assertFalse(mDefaultDisplay.hasTopFixedRotationLaunchingApp()); } @Test @@ -436,7 +436,7 @@ public class RecentsAnimationControllerTest extends WindowTestsBase { // The transform state should keep because we expect to listen the signal from the // transition executed by moving the task to front. assertTrue(homeActivity.hasFixedRotationTransform()); - assertEquals(homeActivity, mDefaultDisplay.getFixedRotationLaunchingApp()); + assertTrue(mDefaultDisplay.isFixedRotationLaunchingApp(homeActivity)); mDefaultDisplay.mFixedRotationTransitionListener.onAppTransitionFinishedLocked( homeActivity.token); |