diff --git a/services/core/java/com/android/server/wm/RemoteAnimationController.java b/services/core/java/com/android/server/wm/RemoteAnimationController.java index 871b4d8062c23..35cc5e30cacfc 100644 --- a/services/core/java/com/android/server/wm/RemoteAnimationController.java +++ b/services/core/java/com/android/server/wm/RemoteAnimationController.java @@ -70,6 +70,7 @@ class RemoteAnimationController implements DeathRecipient { final ArrayList mPendingNonAppAnimations = new ArrayList<>(); private final Handler mHandler; private final Runnable mTimeoutRunnable = () -> cancelAnimation("timeoutRunnable"); + private boolean mIsFinishing; private FinishedCallback mFinishedCallback; private boolean mCanceled; @@ -260,6 +261,7 @@ class RemoteAnimationController implements DeathRecipient { mPendingAnimations.size()); mHandler.removeCallbacks(mTimeoutRunnable); synchronized (mService.mGlobalLock) { + mIsFinishing = true; unlinkToDeathOfRunner(); releaseFinishedCallback(); mService.openSurfaceTransaction(); @@ -304,6 +306,7 @@ class RemoteAnimationController implements DeathRecipient { throw e; } finally { mService.closeSurfaceTransaction("RemoteAnimationController#finished"); + mIsFinishing = false; } } // Reset input for all activities when the remote animation is finished. @@ -523,6 +526,9 @@ class RemoteAnimationController implements DeathRecipient { @Override public void onAnimationCancelled(SurfaceControl animationLeash) { + if (mIsFinishing) { + return; + } if (mRecord.mAdapter == this) { mRecord.mAdapter = null; } else {