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

Commit 48e3cfc0 authored by Winson Chung's avatar Winson Chung Committed by Android (Google) Code Review
Browse files

Merge "Modify deferred recents animation cancel to work without screenshot" into qt-r1-dev

parents dc40ca59 7a545ae9
Loading
Loading
Loading
Loading
+30 −14
Original line number Diff line number Diff line
@@ -76,6 +76,21 @@ interface IRecentsAnimationController {
     */
    void hideCurrentInputMethod();

    /**
     * This call is deprecated, use #setDeferCancelUntilNextTransition() instead
     * TODO(138144750): Remove this method once there are no callers
     * @deprecated
     */
    void setCancelWithDeferredScreenshot(boolean screenshot);

    /**
     * Clean up the screenshot of previous task which was created during recents animation that
     * was cancelled by a stack order change.
     *
     * @see {@link IRecentsAnimationRunner#onAnimationCanceled}
     */
    void cleanupScreenshot();

    /**
     * Set a state for controller whether would like to cancel recents animations with deferred
     * task screenshot presentation.
@@ -86,22 +101,23 @@ interface IRecentsAnimationController {
     * screenshot, so that Launcher can still control the leash lifecycle & make the next app
     * transition animate smoothly without flickering.
     *
     * @param screenshot When set {@code true}, means recents animation will be canceled when the
     *                   next app launch. System will take previous task's screenshot when the next
     *                   app transition starting, and skip previous task's animation.
     *                   Set {@code false} means will not take screenshot & skip animation
     *                   for previous task.
     * @param defer When set {@code true}, means that the recents animation will defer canceling the
     *              animation when a stack order change is triggered until the subsequent app
     *              transition start and skip previous task's animation.
     *              When set to {@code false}, means that the recents animation will be canceled
     *              immediately when the stack order changes.
     * @param screenshot When set {@code true}, means that the system will take previous task's
     *                   screenshot and replace the contents of the leash with it when the next app
     *                   transition starting. The runner must call #cleanupScreenshot() to end the
     *                   recents animation.
     *                   When set to {@code false}, means that the system will simply wait for the
     *                   next app transition start to immediately cancel the recents animation. This
     *                   can be useful when you want an immediate transition into a state where the
     *                   task is shown in the home/recents activity (without waiting for a
     *                   screenshot).
     *
     * @see #cleanupScreenshot()
     * @see IRecentsAnimationRunner#onCancelled
     */
    void setCancelWithDeferredScreenshot(boolean screenshot);

    /**
     * Clean up the screenshot of previous task which was created during recents animation that
     * was cancelled by a stack order change.
     *
     * @see {@link IRecentsAnimationRunner#onAnimationCanceled}
     */
    void cleanupScreenshot();
    void setDeferCancelUntilNextTransition(boolean defer, boolean screenshot);
}
+1 −1
Original line number Diff line number Diff line
@@ -36,7 +36,7 @@ oneway interface IRecentsAnimationRunner {
     * @param deferredWithScreenshot If set to {@code true}, the contents of the task will be
     *                               replaced with a screenshot, such that the runner's leash is
     *                               still active. As soon as the runner doesn't need the leash
     *                               anymore, it can call
     *                               anymore, it must call
     *                               {@link IRecentsAnimationController#cleanupScreenshot).
     *
     * @see {@link RecentsAnimationController#cleanupScreenshot}
+9 −0
Original line number Diff line number Diff line
@@ -91,6 +91,7 @@ public class RecentsAnimationControllerCompat {
        }
    }

    @Deprecated
    public void setCancelWithDeferredScreenshot(boolean screenshot) {
        try {
            mAnimationController.setCancelWithDeferredScreenshot(screenshot);
@@ -99,6 +100,14 @@ public class RecentsAnimationControllerCompat {
        }
    }

    public void setDeferCancelUntilNextTransition(boolean defer, boolean screenshot) {
        try {
            mAnimationController.setDeferCancelUntilNextTransition(defer, screenshot);
        } catch (RemoteException e) {
            Log.e(TAG, "Failed to set deferred cancel with screenshot", e);
        }
    }

    public void cleanupScreenshot() {
        try {
            mAnimationController.cleanupScreenshot();
+1 −1
Original line number Diff line number Diff line
@@ -2477,7 +2477,7 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree
        // transformed the task.
        final RecentsAnimationController controller = mWmService.getRecentsAnimationController();
        if (controller != null && controller.isAnimatingTask(getTask())
                && controller.shouldCancelWithDeferredScreenshot()) {
                && controller.shouldDeferCancelUntilNextTransition()) {
            return false;
        }

+9 −7
Original line number Diff line number Diff line
@@ -355,7 +355,7 @@ class RecentsAnimation implements RecentsAnimationCallbacks,
                        // launch-behind state is restored. That also prevents the next transition
                        // type being disturbed if the visibility is updated after setting the next
                        // transition (the target activity will be one of closing apps).
                        if (!controller.shouldCancelWithDeferredScreenshot()
                        if (!controller.shouldDeferCancelWithScreenshot()
                                && !targetStack.isFocusedStackOnDisplay()) {
                            targetStack.ensureActivitiesVisibleLocked(null /* starting */,
                                    0 /* starting */, false /* preserveWindows */);
@@ -415,16 +415,18 @@ class RecentsAnimation implements RecentsAnimationCallbacks,
        final DisplayContent dc =
                mService.mRootActivityContainer.getDefaultDisplay().mDisplayContent;
        dc.mBoundsAnimationController.setAnimationType(
                controller.shouldCancelWithDeferredScreenshot() ? FADE_IN : BOUNDS);
                controller.shouldDeferCancelUntilNextTransition() ? FADE_IN : BOUNDS);

        // Cancel running recents animation and screenshot previous task when the next
        // transition starts in below cases:
        // 1) The next launching task is not in recents animation task.
        // We defer canceling the recents animation until the next app transition in the following
        // cases:
        // 1) The next launching task is not being animated by the recents animation
        // 2) The next task is home activity. (i.e. pressing home key to back home in recents).
        if ((!controller.isAnimatingTask(stack.getTaskStack().getTopChild())
                || controller.isTargetApp(stack.getTopActivity().mAppWindowToken))
                && controller.shouldCancelWithDeferredScreenshot()) {
            controller.cancelOnNextTransitionStart();
                && controller.shouldDeferCancelUntilNextTransition()) {
            // Always prepare an app transition since we rely on the transition callbacks to cleanup
            mWindowManager.prepareAppTransition(TRANSIT_NONE, false);
            controller.setCancelOnNextTransitionStart();
        } else {
            // Just cancel directly to unleash from launcher when the next launching task is the
            // current top task.
Loading