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

Commit 905e0279 authored by fukaipeng's avatar fukaipeng
Browse files

Block animation transfer after surface animation finishes.



When a surface animation finishes, SurfaceAnimator must reset its internal state and triggers callbacks.
A part of this post-animation process is executed immediately after animation finishes,but the others might be deferred.
When SurfaceAnimator is in this tentative state, we cannot transfer SurfaceAnimation anymore.

For example, we add AnimationAdapter to WindowManagerService#mAnimationTransferMap during the transfer process,
but the AnimationAdapter will never be removed from the map,
since the removal logic is triggered from an animation finish callback but the animation has already finished.

Test: go/wm-smoke
Test: SurfaceAnimatorTest
Bug: 214330806

Change-Id: I4e49c1742c0039e89f037fc98d8da3040b4ad67b
Signed-off-by: default avatarfukaipeng <fukaipeng@xiaomi.com>
parent 2e2a97c0
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -85,6 +85,8 @@ class SurfaceAnimator {

    private boolean mAnimationStartDelayed;

    private boolean mAnimationFinished;

    /**
     * @param animatable The object to animate.
     * @param staticAnimationFinishedCallback Callback to invoke when an animation has finished
@@ -134,6 +136,7 @@ class SurfaceAnimator {
                        || anim.shouldDeferAnimationFinish(resetAndInvokeFinish))) {
                    resetAndInvokeFinish.run();
                }
                mAnimationFinished = true;
            }
        };
    }
@@ -289,6 +292,9 @@ class SurfaceAnimator {
            Slog.w(TAG, "Unable to transfer animation, surface or parent is null");
            cancelAnimation();
            return;
        } else if (from.mAnimationFinished) {
            Slog.w(TAG, "Unable to transfer animation, because " + from + " animation is finished");
            return;
        }
        endDelayingAnimationStart();
        final Transaction t = mAnimatable.getPendingTransaction();
@@ -367,6 +373,7 @@ class SurfaceAnimator {
        SurfaceControl leash = mLeash;
        mLeash = null;
        final boolean scheduleAnim = removeLeash(t, mAnimatable, leash, destroyLeash);
        mAnimationFinished = false;
        if (scheduleAnim) {
            mService.scheduleAnimationLocked();
        }