From 42be8fa0dbc8d3c1a78fcbcb08485b3416d9d159 Mon Sep 17 00:00:00 2001 From: Schneider Victor-tulias Date: Mon, 9 May 2022 16:23:30 -0700 Subject: [PATCH] Clear recents animation controllers and recents animation snapshots synchronously. Clearing the recents animation controller synchronously immediately after posting a screenshot cleanup was making it almost impossible to cleanup the screenshot when cancelling the recents animation. Moved the recents animation controller clearing to run synchronously with cleaning up the screenshot. Bug: 223498680 Test: manually with 3 button mode. Change-Id: I6af5bd4525976eb6956d0466dceae1787b3b84d8 --- quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java index f60b2253e4..1b1cb8566b 100644 --- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java +++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java @@ -151,6 +151,7 @@ public abstract class AbsSwipeUpHandler, // Null if the recents animation hasn't started yet or has been canceled or finished. protected @Nullable RecentsAnimationController mRecentsAnimationController; + protected @Nullable RecentsAnimationController mDeferredCleanupRecentsAnimationController; protected RecentsAnimationTargets mRecentsAnimationTargets; protected T mActivity; protected Q mRecentsView; @@ -435,6 +436,9 @@ public abstract class AbsSwipeUpHandler, mRecentsView.switchToScreenshot(snapshots, () -> { if (mRecentsAnimationController != null) { mRecentsAnimationController.cleanupScreenshot(); + } else if (mDeferredCleanupRecentsAnimationController != null) { + mDeferredCleanupRecentsAnimationController.cleanupScreenshot(); + mDeferredCleanupRecentsAnimationController = null; } }); mRecentsView.onRecentsAnimationComplete(); @@ -839,6 +843,9 @@ public abstract class AbsSwipeUpHandler, public void onRecentsAnimationCanceled(HashMap thumbnailDatas) { ActiveGestureLog.INSTANCE.addLog("cancelRecentsAnimation"); mActivityInitListener.unregister(); + // Cache the recents animation controller so we can defer its cleanup to after having + // properly cleaned up the screenshot without accidentally using it. + mDeferredCleanupRecentsAnimationController = mRecentsAnimationController; mStateCallback.setStateOnUiThread(STATE_GESTURE_CANCELLED | STATE_HANDLER_INVALIDATED); if (mRecentsAnimationTargets != null) {