Merge "Fix testStressSwipeToOverview" into sc-dev am: aabead2db8 am: 5181163070

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/16471550

Change-Id: I60cfcce0e6b946967025fbbf7a66b0ea10c53a2b
diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
index 6887d7f..9748123 100644
--- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
+++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
@@ -428,6 +428,10 @@
                 mAnimationFactory = mActivityInterface.prepareRecentsUI(mDeviceState,
                         mWasLauncherAlreadyVisible, this::onAnimatorPlaybackControllerCreated);
                 maybeUpdateRecentsAttachedState(false /* animate */);
+                if (mGestureState.getEndTarget() != null) {
+                    // Update the end target in case the gesture ended before we init.
+                    mAnimationFactory.setEndTarget(mGestureState.getEndTarget());
+                }
             };
             if (mWasLauncherAlreadyVisible) {
                 // Launcher is visible, but might be about to stop. Thus, if we prepare recents
diff --git a/quickstep/tests/src/com/android/quickstep/AbstractQuickStepTest.java b/quickstep/tests/src/com/android/quickstep/AbstractQuickStepTest.java
index dc73a9a..7c463a7 100644
--- a/quickstep/tests/src/com/android/quickstep/AbstractQuickStepTest.java
+++ b/quickstep/tests/src/com/android/quickstep/AbstractQuickStepTest.java
@@ -44,7 +44,7 @@
     protected void onLauncherActivityClose(Launcher launcher) {
         RecentsView recentsView = launcher.getOverviewPanel();
         if (recentsView != null) {
-            recentsView.finishRecentsAnimation(true, null);
+            recentsView.finishRecentsAnimation(false /* toRecents */, null);
         }
     }