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

Commit 76afce6f authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Finish fixed rotation while the task has done transition" into rvc-dev...

Merge "Finish fixed rotation while the task has done transition" into rvc-dev am: 1a346874 am: eb4731a0

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11894999

Change-Id: I6ddc788590ab317277767908b9addfa2c27b2051
parents 7bd5b7ca eb4731a0
Loading
Loading
Loading
Loading
+30 −9
Original line number Original line Diff line number Diff line
@@ -1464,9 +1464,10 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
            return true;
            return true;
        }
        }
        if (checkOpening) {
        if (checkOpening) {
            if (!mAppTransition.isTransitionSet() && !mOpeningApps.contains(r)) {
            if (!mAppTransition.isTransitionSet() || !mOpeningApps.contains(r)) {
                // Apply normal rotation animation in case of the activity set different requested
                // Apply normal rotation animation in case of the activity set different requested
                // orientation without activity switch.
                // orientation without activity switch, or the transition is unset due to starting
                // window was transferred ({@link #mSkipAppTransitionAnimation}).
                return false;
                return false;
            }
            }
        } else if (r != topRunningActivity()) {
        } else if (r != topRunningActivity()) {
@@ -5680,16 +5681,36 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
            if (r == null || r == mAnimatingRecents) {
            if (r == null || r == mAnimatingRecents) {
                return;
                return;
            }
            }
            if (mFixedRotationLaunchingApp != null
            if (mFixedRotationLaunchingApp == null) {
                    && mFixedRotationLaunchingApp.hasFixedRotationTransform(r)) {
                // In most cases this is a no-op if the activity doesn't have fixed rotation.
                // Otherwise it could be from finishing recents animation while the display has
                // different orientation.
                r.finishFixedRotationTransform();
                return;
            }
            if (mFixedRotationLaunchingApp.hasFixedRotationTransform(r)) {
                if (mFixedRotationLaunchingApp.hasAnimatingFixedRotationTransition()) {
                    // Waiting until all of the associated activities have done animation, or the
                    // Waiting until all of the associated activities have done animation, or the
                // orientation would be updated too early and cause flickers.
                    // orientation would be updated too early and cause flickering.
                if (!mFixedRotationLaunchingApp.hasAnimatingFixedRotationTransition()) {
                    return;
                    continueUpdateOrientationForDiffOrienLaunchingApp();
                }
                }
            } else {
            } else {
                r.finishFixedRotationTransform();
                // Handle a corner case that the task of {@link #mFixedRotationLaunchingApp} is no
                // longer animating but the corresponding transition finished event won't notify.
                // E.g. activity A transferred starting window to B, only A will receive transition
                // finished event. A doesn't have fixed rotation but B is the rotated launching app.
                final Task task = r.getTask();
                if (task == null || task != mFixedRotationLaunchingApp.getTask()) {
                    // Different tasks won't be in one activity transition animation.
                    return;
                }
                if (task.isAppTransitioning()) {
                    return;
                    // Continue to update orientation because the transition of the top rotated
                    // launching activity is done.
                }
            }
            }
            continueUpdateOrientationForDiffOrienLaunchingApp();
        }
        }


        @Override
        @Override
+23 −2
Original line number Original line Diff line number Diff line
@@ -1135,8 +1135,6 @@ public class DisplayContentTests extends WindowTestsBase {
        // Launch another activity before the transition is finished.
        // Launch another activity before the transition is finished.
        final ActivityRecord app2 = new ActivityTestsBase.StackBuilder(mWm.mRoot)
        final ActivityRecord app2 = new ActivityTestsBase.StackBuilder(mWm.mRoot)
                .setDisplay(mDisplayContent).build().getTopMostActivity();
                .setDisplay(mDisplayContent).build().getTopMostActivity();
        mDisplayContent.prepareAppTransition(WindowManager.TRANSIT_ACTIVITY_OPEN,
                false /* alwaysKeepCurrent */);
        mDisplayContent.mOpeningApps.add(app2);
        mDisplayContent.mOpeningApps.add(app2);
        app2.setRequestedOrientation(newOrientation);
        app2.setRequestedOrientation(newOrientation);


@@ -1162,6 +1160,29 @@ public class DisplayContentTests extends WindowTestsBase {
        assertNull(mDisplayContent.getFixedRotationAnimationController());
        assertNull(mDisplayContent.getFixedRotationAnimationController());
    }
    }


    @Test
    public void testFinishFixedRotationNoAppTransitioningTask() {
        final ActivityRecord app = mAppWindow.mActivityRecord;
        final Task task = app.getTask();
        final ActivityRecord app2 = new ActivityTestsBase.ActivityBuilder(mWm.mAtmService)
                .setTask(task).build();
        mDisplayContent.setFixedRotationLaunchingApp(app2, (mDisplayContent.getRotation() + 1) % 4);
        doReturn(true).when(task).isAppTransitioning();
        // If the task is animating transition, this should be no-op.
        mDisplayContent.mFixedRotationTransitionListener.onAppTransitionFinishedLocked(app.token);

        assertTrue(app2.hasFixedRotationTransform());
        assertTrue(mDisplayContent.hasTopFixedRotationLaunchingApp());

        doReturn(false).when(task).isAppTransitioning();
        // Although this notifies app instead of app2 that uses the fixed rotation, app2 should
        // still finish the transform because there is no more transition event.
        mDisplayContent.mFixedRotationTransitionListener.onAppTransitionFinishedLocked(app.token);

        assertFalse(app2.hasFixedRotationTransform());
        assertFalse(mDisplayContent.hasTopFixedRotationLaunchingApp());
    }

    @Test
    @Test
    public void testRotateSeamlesslyWithFixedRotation() {
    public void testRotateSeamlesslyWithFixedRotation() {
        final DisplayRotation displayRotation = mDisplayContent.getDisplayRotation();
        final DisplayRotation displayRotation = mDisplayContent.getDisplayRotation();