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

Commit 54284465 authored by lumark's avatar lumark
Browse files

Better support for cleaning up the recents animation

With Life Tiles in QuickSteps (b/111697218), launcher will
“punch a hole” for TaskView & the app window will be transformed
in it & keep the task is running.

To prevent launcher animates on TaskView without the real app surface
during task switching, launcher start RecentsAnimation to monitor
onStackOrderChanged without cancel animation when swiping to recents.

We use this as signal to screenshot the previous app window when next
app transtion start, make leash with screenshot surface to let it below
homeAnimationLayer, so that launcher can still control the leash,
and then callback onAnimationCanceled with screenshot parameter for
launcher to know if need to call IRecentsAnimation#cleanupScreenshot for
clean up screenshot, to make the next app transtion animation can work
smoothly without flickering.

Bug: 122593881
Test: manual
Test: atest RecentsAnimationControllerTest RecentsAnimationTest
Change-Id: I83504d578a17856623a53c04a7d3c54e5bcab5f4
parent 214679b5
Loading
Loading
Loading
Loading
+29 −0
Original line number Diff line number Diff line
@@ -73,4 +73,33 @@ interface IRecentsAnimationController {
     * Hides the current input method if one is showing.
     */
    void hideCurrentInputMethod();

    /**
     * Set a state for controller whether would like to cancel recents animations with deferred
     * task screenshot presentation.
     *
     * When we cancel the recents animation due to a stack order change, we can't just cancel it
     * immediately as it would lead to a flicker in Launcher if we just remove the task from the
     * leash. Instead we screenshot the previous task and replace the child of the leash with the
     * 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.
     *
     * @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();
}
+9 −1
Original line number Diff line number Diff line
@@ -32,9 +32,17 @@ oneway interface IRecentsAnimationRunner {
     * Called when the system needs to cancel the current animation. This can be due to the
     * wallpaper not drawing in time, or the handler not finishing the animation within a predefined
     * amount of time.
     *
     * @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
     *                               {@link IRecentsAnimationController#cleanupScreenshot).
     *
     * @see {@link RecentsAnimationController#cleanupScreenshot}
     */
    @UnsupportedAppUsage
    void onAnimationCanceled() = 1;
    void onAnimationCanceled(boolean deferredWithScreenshot) = 1;

    /**
     * Called when the system is ready for the handler to start animating all the visible tasks.
+4 −2
Original line number Diff line number Diff line
@@ -219,6 +219,7 @@ public class ActivityManagerWrapper {
            IRecentsAnimationRunner runner = null;
            if (animationHandler != null) {
                runner = new IRecentsAnimationRunner.Stub() {
                    @Override
                    public void onAnimationStart(IRecentsAnimationController controller,
                            RemoteAnimationTarget[] apps, Rect homeContentInsets,
                            Rect minimizedHomeBounds) {
@@ -230,8 +231,9 @@ public class ActivityManagerWrapper {
                                homeContentInsets, minimizedHomeBounds);
                    }

                    public void onAnimationCanceled() {
                        animationHandler.onAnimationCanceled();
                    @Override
                    public void onAnimationCanceled(boolean deferredWithScreenshot) {
                        animationHandler.onAnimationCanceled(deferredWithScreenshot);
                    }
                };
            }
+16 −0
Original line number Diff line number Diff line
@@ -84,4 +84,20 @@ public class RecentsAnimationControllerCompat {
            Log.e(TAG, "Failed to finish recents animation", e);
        }
    }

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

    public void cleanupScreenshot() {
        try {
            mAnimationController.cleanupScreenshot();
        } catch (RemoteException e) {
            Log.e(TAG, "Failed to clean up screenshot of recents animation", e);
        }
    }
}
 No newline at end of file
+2 −2
Original line number Diff line number Diff line
@@ -29,5 +29,5 @@ public interface RecentsAnimationListener {
    /**
     * Called when the animation into Recents was canceled. This call is made on the binder thread.
     */
    void onAnimationCanceled();
    void onAnimationCanceled(boolean deferredWithScreenshot);
}
Loading