Merge "Fix window x-axis movement after gesture ends." into tm-qpr-dev
diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
index 19ffd2a..3d8ffc4 100644
--- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
+++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
@@ -1204,7 +1204,6 @@
         final GestureEndTarget endTarget = calculateEndTarget(velocity, endVelocity,
                 isFling, isCancel);
 
-        setClampScrollOffset(false);
         // Set the state, but don't notify until the animation completes
         mGestureState.setEndTarget(endTarget, false /* isAtomic */);
         mAnimationFactory.setEndTarget(endTarget);
@@ -1282,13 +1281,16 @@
 
         // Let RecentsView handle the scrolling to the task, which we launch in startNewTask()
         // or resumeLastTask().
+        Runnable onPageTransitionEnd = () -> {
+            mGestureState.setState(STATE_RECENTS_SCROLLING_FINISHED);
+            setClampScrollOffset(false);
+        };
         if (mRecentsView != null) {
             ActiveGestureLog.INSTANCE.trackEvent(ActiveGestureErrorDetector.GestureEvent
                     .SET_ON_PAGE_TRANSITION_END_CALLBACK);
-            mRecentsView.setOnPageTransitionEndCallback(
-                    () -> mGestureState.setState(STATE_RECENTS_SCROLLING_FINISHED));
+            mRecentsView.setOnPageTransitionEndCallback(onPageTransitionEnd);
         } else {
-            mGestureState.setState(STATE_RECENTS_SCROLLING_FINISHED);
+            onPageTransitionEnd.run();
         }
 
         animateToProgress(startShift, endShift, duration, interpolator, endTarget, velocity);
diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java
index dc1b885..8b406ec 100644
--- a/quickstep/src/com/android/quickstep/views/RecentsView.java
+++ b/quickstep/src/com/android/quickstep/views/RecentsView.java
@@ -5072,15 +5072,15 @@
      * Returns how many pixels the page is offset on the currently laid out dominant axis.
      */
     public int getScrollOffset(int pageIndex) {
-        int unboundedOffset = getUnclampedScrollOffset(pageIndex);
+        int unclampedOffset = getUnclampedScrollOffset(pageIndex);
         if (!mShouldClampScrollOffset) {
-            return unboundedOffset;
+            return unclampedOffset;
         }
-        if (Math.abs(unboundedOffset) < mClampedScrollOffsetBound) {
+        if (Math.abs(unclampedOffset) < mClampedScrollOffsetBound) {
             return 0;
         }
-        return unboundedOffset
-                - Math.round(Math.signum(unboundedOffset) * mClampedScrollOffsetBound);
+        return unclampedOffset
+                - Math.round(Math.signum(unclampedOffset) * mClampedScrollOffsetBound);
     }
 
     /**