From a7d7f78c08b4a872fc505e8874bdf137d7843059 Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Wed, 30 Jun 2021 11:59:08 -0700 Subject: [PATCH] Defer cleaning up screenshot until after we actually switch to screenshot - In the case where we get a screenshot on cancel, we should wait to finish the recents animation until the view gets a chance to update Bug: 185643608 Test: Swipe up to overview in 2 button, hit home Change-Id: I2ac3567006f6fa7e6f473499f6862e5e408dfc3d --- .../src/com/android/quickstep/AbsSwipeUpHandler.java | 6 +++--- quickstep/src/com/android/quickstep/GestureState.java | 11 +++++++---- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java index 524cd53839..7727d5752f 100644 --- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java +++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java @@ -383,10 +383,10 @@ public abstract class AbsSwipeUpHandler, // Set up a entire animation lifecycle callback to notify the current recents view when // the animation is canceled mGestureState.runOnceAtState(STATE_RECENTS_ANIMATION_CANCELED, () -> { - ThumbnailData snapshot = mGestureState.getRecentsAnimationCanceledSnapshot(); + ThumbnailData snapshot = mGestureState.consumeRecentsAnimationCanceledSnapshot(); if (snapshot != null) { - RecentsModel.INSTANCE.get(mContext).onTaskSnapshotChanged( - mRecentsView.getRunningTaskId(), snapshot); + mRecentsView.switchToScreenshot(snapshot, + () -> mRecentsAnimationController.cleanupScreenshot()); mRecentsView.onRecentsAnimationComplete(); } }); diff --git a/quickstep/src/com/android/quickstep/GestureState.java b/quickstep/src/com/android/quickstep/GestureState.java index a302a07bca..015002f0e1 100644 --- a/quickstep/src/com/android/quickstep/GestureState.java +++ b/quickstep/src/com/android/quickstep/GestureState.java @@ -376,11 +376,14 @@ public class GestureState implements RecentsAnimationCallbacks.RecentsAnimationL } /** - * Returns the canceled animation thumbnail data. This call only returns a value while - * STATE_RECENTS_ANIMATION_CANCELED state is being set. + * Returns and clears the canceled animation thumbnail data. This call only returns a value + * while STATE_RECENTS_ANIMATION_CANCELED state is being set, and the caller is responsible for + * calling {@link RecentsAnimationController#cleanupScreenshot()}. */ - ThumbnailData getRecentsAnimationCanceledSnapshot() { - return mRecentsAnimationCanceledSnapshot; + ThumbnailData consumeRecentsAnimationCanceledSnapshot() { + ThumbnailData data = mRecentsAnimationCanceledSnapshot; + mRecentsAnimationCanceledSnapshot = null; + return data; } void setSwipeUpStartTimeMs(long uptimeMs) {