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

Commit 35c3af36 authored by ot903107's avatar ot903107 Committed by chuanghua zhao
Browse files

Prevent duplicate release same transaction from TransactionPool

Sometimes split transition immediatelly abort due to app does't
support multiwindow or other reasons, it may cause the fadeAnimation
duplicate release same transaction with SplashScreen exit shiftUpAnimation.

Bug: 295124138
Test: run auto monkey test

Change-Id: I17c73b8dae9e0f32558bc3401877dcc82bc66f70
parent 03bf8643
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -478,18 +478,20 @@ class SplitScreenTransitions {
    private void startFadeAnimation(@NonNull SurfaceControl leash, boolean show) {
        final float end = show ? 1.f : 0.f;
        final float start = 1.f - end;
        final SurfaceControl.Transaction transaction = mTransactionPool.acquire();
        final ValueAnimator va = ValueAnimator.ofFloat(start, end);
        va.setDuration(FADE_DURATION);
        va.setInterpolator(show ? ALPHA_IN : ALPHA_OUT);
        va.addUpdateListener(animation -> {
            float fraction = animation.getAnimatedFraction();
            final SurfaceControl.Transaction transaction = mTransactionPool.acquire();
            transaction.setAlpha(leash, start * (1.f - fraction) + end * fraction);
            transaction.apply();
            mTransactionPool.release(transaction);
        });
        va.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                final SurfaceControl.Transaction transaction = mTransactionPool.acquire();
                transaction.setAlpha(leash, end);
                transaction.apply();
                mTransactionPool.release(transaction);