From b53573d6514078c17a5a1c8a553cd243136aae6a Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Thu, 13 Feb 2020 16:04:11 -0800 Subject: [PATCH] Fix issue with out of order callbacks - If any call to finish the recents animation comes in before onRecentsAnimationStarted, we'll clear the callbacks but the listener registered in startRecentsAnimation will persist. Since the call to actually finish the animation with the system is posted on the main thread, if the animation started callback returns in that time, the controller will be set (via the listener) but the callbacks will be unset. Instead, we can clear all the listeners from the previous callbacks when cleaning up the animation. Bug: 145758818 Change-Id: I29dab94f5fb25f762a823d59ef318a361282b595 --- .../com/android/quickstep/RecentsAnimationCallbacks.java | 6 ++++++ .../src/com/android/quickstep/TaskAnimationManager.java | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/quickstep/src/com/android/quickstep/RecentsAnimationCallbacks.java b/quickstep/src/com/android/quickstep/RecentsAnimationCallbacks.java index acf61b4142..0f98b325fa 100644 --- a/quickstep/src/com/android/quickstep/RecentsAnimationCallbacks.java +++ b/quickstep/src/com/android/quickstep/RecentsAnimationCallbacks.java @@ -62,6 +62,12 @@ public class RecentsAnimationCallbacks implements mListeners.remove(listener); } + @UiThread + public void removeAllListeners() { + Preconditions.assertUIThread(); + mListeners.clear(); + } + public void notifyAnimationCanceled() { mCancelled = true; onAnimationCanceled(null); diff --git a/quickstep/src/com/android/quickstep/TaskAnimationManager.java b/quickstep/src/com/android/quickstep/TaskAnimationManager.java index e3e8ace96b..c362e52652 100644 --- a/quickstep/src/com/android/quickstep/TaskAnimationManager.java +++ b/quickstep/src/com/android/quickstep/TaskAnimationManager.java @@ -156,9 +156,9 @@ public class TaskAnimationManager implements RecentsAnimationCallbacks.RecentsAn mTargets.release(); } - // Remove gesture state from callbacks - if (mCallbacks != null && mLastGestureState != null) { - mCallbacks.removeListener(mLastGestureState); + // Clean up all listeners to ensure we don't get subsequent callbacks + if (mCallbacks != null) { + mCallbacks.removeAllListeners(); } mController = null;