Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3691c1fb authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Revert cancellation of animation in old rotation

In most of cases, the duration of closing apps should not be
longer than the opening apps, otherwise that should be fixed.
The cancellation is too rough and not safe because it may lead
to unpredictable flow such as interrupt recents animation.

Fixes: 155029580
Test: DisplayContentTests#testApplyTopFixedRotationTransform
Change-Id: Ifb23a73ac2635cc7631324cee679e5a663250f99
parent 84ce067c
Loading
Loading
Loading
Loading
+3 −15
Original line number Diff line number Diff line
@@ -5241,25 +5241,13 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
     * the display naturally.
     */
    private void applyRotationAndFinishFixedRotation(int oldRotation, int newRotation) {
        if (mFixedRotationLaunchingApp == null) {
        final WindowToken rotatedLaunchingApp = mFixedRotationLaunchingApp;
        if (rotatedLaunchingApp == 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.
        forAllActivities(a -> {
            if (a.nowVisible && a != mFixedRotationLaunchingApp
                    && a.getWindowConfiguration().getRotation() != newRotation) {
                final WindowContainer<?> w = a.getAnimatingContainer();
                if (w != null) {
                    w.cancelAnimation();
                }
            }
        });

        mFixedRotationLaunchingApp.finishFixedRotationTransform(
        rotatedLaunchingApp.finishFixedRotationTransform(
                () -> applyRotation(oldRotation, newRotation));
        mFixedRotationLaunchingApp = null;
    }
+0 −10
Original line number Diff line number Diff line
@@ -57,7 +57,6 @@ 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;

@@ -1068,13 +1067,6 @@ 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 */);
@@ -1135,8 +1127,6 @@ public class DisplayContentTests extends WindowTestsBase {
        // The display should be rotated after the launch is finished.
        mDisplayContent.mAppTransition.notifyAppTransitionFinishedLocked(app.token);

        // The animation in old rotation should be cancelled.
        assertFalse(closingApp.isAnimating());
        // The fixed rotation should be cleared and the new rotation is applied to display.
        assertFalse(app.hasFixedRotationTransform());
        assertFalse(app2.hasFixedRotationTransform());