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

Commit d8977076 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Make leash cleanup on-demand instead of default." into main

parents 40a6bf46 aa02d1b4
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -827,7 +827,7 @@ constructor(

    /** [Runner] wrapper that supports animation takeovers. */
    private inner class OriginTransition(private val runner: Runner) : IRemoteTransition {
        private val delegate = RemoteAnimationRunnerCompat.wrap(runner)
        private val delegate = RemoteAnimationRunnerCompat.wrap(runner, true)

        init {
            assertLongLivedReturnAnimations()
+16 −5
Original line number Diff line number Diff line
@@ -79,6 +79,15 @@ public abstract class RemoteAnimationRunnerCompat extends IRemoteAnimationRunner

    /** Wraps a remote animation runner in a remote-transition. */
    public static RemoteTransitionStub wrap(IRemoteAnimationRunner runner) {
        return wrap(runner, false);
    }

    /**
     * Wraps a remote animation runner in a remote-transition, optionally reparenting the transition
     * leashes to null to explicitly clean them up once the animation is finished.
     */
    public static RemoteTransitionStub wrap(
            IRemoteAnimationRunner runner, boolean reparentLeashesOnFinish) {
        return new RemoteTransitionStub() {
            final ArrayMap<IBinder, Runnable> mFinishRunnables = new ArrayMap<>();

@@ -198,6 +207,7 @@ public abstract class RemoteAnimationRunnerCompat extends IRemoteAnimationRunner
                    // before GC would.
                    info.releaseAllSurfaces();
                    // Make sure that the transition leashes created are not leaked.
                    if (reparentLeashesOnFinish) {
                        for (SurfaceControl leash : leashMap.values()) {
                            try {
                                finishTransaction.reparent(leash, null);
@@ -205,6 +215,7 @@ public abstract class RemoteAnimationRunnerCompat extends IRemoteAnimationRunner
                                Log.e(TAG, "Failed to reparent leash", e);
                            }
                        }
                    }
                    // Don't release here since launcher might still be using them. Instead
                    // let launcher release them (eg. via RemoteAnimationTargets)
                    leashMap.clear();