Loading services/core/java/com/android/server/wm/DisplayContent.java +31 −8 Original line number Diff line number Diff line Loading @@ -5158,14 +5158,7 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo final int currRotation = currOverrideConfig.windowConfiguration.getRotation(); final int overrideRotation = overrideConfiguration.windowConfiguration.getRotation(); if (currRotation != ROTATION_UNDEFINED && currRotation != overrideRotation) { if (mFixedRotationLaunchingApp != null) { mFixedRotationLaunchingApp.clearFixedRotationTransform( () -> applyRotation(currRotation, overrideRotation)); // Clear the record because the display will sync to current rotation. mFixedRotationLaunchingApp = null; } else { applyRotation(currRotation, overrideRotation); } applyRotationAndClearFixedRotation(currRotation, overrideRotation); } mCurrentOverrideConfigurationChanges = currOverrideConfig.diff(overrideConfiguration); super.onRequestedOverrideConfigurationChanged(overrideConfiguration); Loading @@ -5175,6 +5168,36 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo ActivityTaskManagerService.LAYOUT_REASON_CONFIG_CHANGED); } /** * If the launching rotated activity ({@link #mFixedRotationLaunchingApp}) is null, it simply * applies the rotation to display. Otherwise because the activity has shown as rotated, the * fixed rotation transform also needs to be cleared to make sure the rotated activity fits * the display naturally. */ private void applyRotationAndClearFixedRotation(int oldRotation, int newRotation) { if (mFixedRotationLaunchingApp == null) { applyRotation(oldRotation, newRotation); return; } // The display may be about to rotate seamlessly, and the animation of closing apps may // still animate in old rotation. So make sure the outdated animation won't show on the // rotated display. mTaskContainers.forAllActivities(a -> { if (a.nowVisible && a != mFixedRotationLaunchingApp && a.getWindowConfiguration().getRotation() != newRotation) { final WindowContainer<?> w = a.getAnimatingContainer(); if (w != null) { w.cancelAnimation(); } } }); mFixedRotationLaunchingApp.clearFixedRotationTransform( () -> applyRotation(oldRotation, newRotation)); mFixedRotationLaunchingApp = null; } /** Checks whether the given activity is in size compatibility mode and notifies the change. */ void handleActivitySizeCompatModeIfNeeded(ActivityRecord r) { if (!r.isState(RESUMED) || r.getWindowingMode() != WINDOWING_MODE_FULLSCREEN) { Loading services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java +10 −0 Original line number Diff line number Diff line Loading @@ -56,6 +56,7 @@ import static com.android.dx.mockito.inline.extended.ExtendedMockito.same; import static com.android.dx.mockito.inline.extended.ExtendedMockito.spyOn; import static com.android.dx.mockito.inline.extended.ExtendedMockito.times; import static com.android.dx.mockito.inline.extended.ExtendedMockito.verify; import static com.android.server.wm.SurfaceAnimator.ANIMATION_TYPE_APP_TRANSITION; import static com.android.server.wm.WindowContainer.POSITION_TOP; import static com.android.server.wm.WindowManagerService.UPDATE_FOCUS_NORMAL; Loading Loading @@ -1006,6 +1007,13 @@ public class DisplayContentTests extends WindowTestsBase { mDisplayContent.computeScreenConfiguration(config); mDisplayContent.onRequestedOverrideConfigurationChanged(config); final ActivityRecord closingApp = new ActivityTestsBase.StackBuilder(mWm.mRoot) .setDisplay(mDisplayContent).setOnTop(false).build().getTopMostActivity(); closingApp.nowVisible = true; closingApp.startAnimation(closingApp.getPendingTransaction(), mock(AnimationAdapter.class), false /* hidden */, ANIMATION_TYPE_APP_TRANSITION); assertTrue(closingApp.isAnimating()); final ActivityRecord app = mAppWindow.mActivityRecord; mDisplayContent.prepareAppTransition(WindowManager.TRANSIT_ACTIVITY_OPEN, false /* alwaysKeepCurrent */); Loading Loading @@ -1033,6 +1041,8 @@ public class DisplayContentTests extends WindowTestsBase { mDisplayContent.mAppTransition.notifyAppTransitionFinishedLocked(app.token); // The animation in old rotation should be cancelled. assertFalse(closingApp.isAnimating()); // The display should be rotated after the launch is finished. assertFalse(app.hasFixedRotationTransform()); assertEquals(config90.orientation, mDisplayContent.getConfiguration().orientation); Loading Loading
services/core/java/com/android/server/wm/DisplayContent.java +31 −8 Original line number Diff line number Diff line Loading @@ -5158,14 +5158,7 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo final int currRotation = currOverrideConfig.windowConfiguration.getRotation(); final int overrideRotation = overrideConfiguration.windowConfiguration.getRotation(); if (currRotation != ROTATION_UNDEFINED && currRotation != overrideRotation) { if (mFixedRotationLaunchingApp != null) { mFixedRotationLaunchingApp.clearFixedRotationTransform( () -> applyRotation(currRotation, overrideRotation)); // Clear the record because the display will sync to current rotation. mFixedRotationLaunchingApp = null; } else { applyRotation(currRotation, overrideRotation); } applyRotationAndClearFixedRotation(currRotation, overrideRotation); } mCurrentOverrideConfigurationChanges = currOverrideConfig.diff(overrideConfiguration); super.onRequestedOverrideConfigurationChanged(overrideConfiguration); Loading @@ -5175,6 +5168,36 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo ActivityTaskManagerService.LAYOUT_REASON_CONFIG_CHANGED); } /** * If the launching rotated activity ({@link #mFixedRotationLaunchingApp}) is null, it simply * applies the rotation to display. Otherwise because the activity has shown as rotated, the * fixed rotation transform also needs to be cleared to make sure the rotated activity fits * the display naturally. */ private void applyRotationAndClearFixedRotation(int oldRotation, int newRotation) { if (mFixedRotationLaunchingApp == null) { applyRotation(oldRotation, newRotation); return; } // The display may be about to rotate seamlessly, and the animation of closing apps may // still animate in old rotation. So make sure the outdated animation won't show on the // rotated display. mTaskContainers.forAllActivities(a -> { if (a.nowVisible && a != mFixedRotationLaunchingApp && a.getWindowConfiguration().getRotation() != newRotation) { final WindowContainer<?> w = a.getAnimatingContainer(); if (w != null) { w.cancelAnimation(); } } }); mFixedRotationLaunchingApp.clearFixedRotationTransform( () -> applyRotation(oldRotation, newRotation)); mFixedRotationLaunchingApp = null; } /** Checks whether the given activity is in size compatibility mode and notifies the change. */ void handleActivitySizeCompatModeIfNeeded(ActivityRecord r) { if (!r.isState(RESUMED) || r.getWindowingMode() != WINDOWING_MODE_FULLSCREEN) { Loading
services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java +10 −0 Original line number Diff line number Diff line Loading @@ -56,6 +56,7 @@ import static com.android.dx.mockito.inline.extended.ExtendedMockito.same; import static com.android.dx.mockito.inline.extended.ExtendedMockito.spyOn; import static com.android.dx.mockito.inline.extended.ExtendedMockito.times; import static com.android.dx.mockito.inline.extended.ExtendedMockito.verify; import static com.android.server.wm.SurfaceAnimator.ANIMATION_TYPE_APP_TRANSITION; import static com.android.server.wm.WindowContainer.POSITION_TOP; import static com.android.server.wm.WindowManagerService.UPDATE_FOCUS_NORMAL; Loading Loading @@ -1006,6 +1007,13 @@ public class DisplayContentTests extends WindowTestsBase { mDisplayContent.computeScreenConfiguration(config); mDisplayContent.onRequestedOverrideConfigurationChanged(config); final ActivityRecord closingApp = new ActivityTestsBase.StackBuilder(mWm.mRoot) .setDisplay(mDisplayContent).setOnTop(false).build().getTopMostActivity(); closingApp.nowVisible = true; closingApp.startAnimation(closingApp.getPendingTransaction(), mock(AnimationAdapter.class), false /* hidden */, ANIMATION_TYPE_APP_TRANSITION); assertTrue(closingApp.isAnimating()); final ActivityRecord app = mAppWindow.mActivityRecord; mDisplayContent.prepareAppTransition(WindowManager.TRANSIT_ACTIVITY_OPEN, false /* alwaysKeepCurrent */); Loading Loading @@ -1033,6 +1041,8 @@ public class DisplayContentTests extends WindowTestsBase { mDisplayContent.mAppTransition.notifyAppTransitionFinishedLocked(app.token); // The animation in old rotation should be cancelled. assertFalse(closingApp.isAnimating()); // The display should be rotated after the launch is finished. assertFalse(app.hasFixedRotationTransform()); assertEquals(config90.orientation, mDisplayContent.getConfiguration().orientation); Loading