Merge "[Bugfix][RemoteAnimation] Fix IndexOutOfBoundsException in onAnimationFinished of RemoteAnimationController"

This commit is contained in:
Chris Li
2022-07-11 06:55:00 +00:00
committed by Gerrit Code Review

View File

@@ -68,6 +68,7 @@ class RemoteAnimationController implements DeathRecipient {
final ArrayList<NonAppWindowAnimationAdapter> mPendingNonAppAnimations = new ArrayList<>(); final ArrayList<NonAppWindowAnimationAdapter> mPendingNonAppAnimations = new ArrayList<>();
private final Handler mHandler; private final Handler mHandler;
private final Runnable mTimeoutRunnable = () -> cancelAnimation("timeoutRunnable"); private final Runnable mTimeoutRunnable = () -> cancelAnimation("timeoutRunnable");
private boolean mIsFinishing;
private FinishedCallback mFinishedCallback; private FinishedCallback mFinishedCallback;
private boolean mCanceled; private boolean mCanceled;
@@ -246,6 +247,7 @@ class RemoteAnimationController implements DeathRecipient {
mPendingAnimations.size()); mPendingAnimations.size());
mHandler.removeCallbacks(mTimeoutRunnable); mHandler.removeCallbacks(mTimeoutRunnable);
synchronized (mService.mGlobalLock) { synchronized (mService.mGlobalLock) {
mIsFinishing = true;
unlinkToDeathOfRunner(); unlinkToDeathOfRunner();
releaseFinishedCallback(); releaseFinishedCallback();
mService.openSurfaceTransaction(); mService.openSurfaceTransaction();
@@ -290,6 +292,7 @@ class RemoteAnimationController implements DeathRecipient {
throw e; throw e;
} finally { } finally {
mService.closeSurfaceTransaction("RemoteAnimationController#finished"); mService.closeSurfaceTransaction("RemoteAnimationController#finished");
mIsFinishing = false;
} }
} }
setRunningRemoteAnimation(false); setRunningRemoteAnimation(false);
@@ -501,6 +504,9 @@ class RemoteAnimationController implements DeathRecipient {
@Override @Override
public void onAnimationCancelled(SurfaceControl animationLeash) { public void onAnimationCancelled(SurfaceControl animationLeash) {
if (mIsFinishing) {
return;
}
if (mRecord.mAdapter == this) { if (mRecord.mAdapter == this) {
mRecord.mAdapter = null; mRecord.mAdapter = null;
} else { } else {