Always update clip rect before applying surface params

Previously, we were only updating the clip rect when params.currentRect
== null, meaning the clip would be stale once the caller started
providing its own rect (e.g. when swiping to home).

Also fix some visual jumps when swiping home, all caused by running the
transform progress from 0 to 1 instead of starting at whatever the
progress was before ending the gesture, e.g.:
- When swiping to home without animating into an icon, the corner radius
  was set back to the window corner radius.
- Before this change, the clip didn't update throughout the animation,
  making the window slightly bigger than the floating icon view; after
  this change, the clip jumped to show the insets again before clipping
  back down during the home animation.

Bug: 149870691
Change-Id: Ie48f4b665a5bf3cbef76bdf7f043febe99fb84a0
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandler.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandler.java
index 0a79819..3601af2 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandler.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandler.java
@@ -428,6 +428,10 @@
         // rounding at the end of the animation.
         float startRadius = mAppWindowAnimationHelper.getCurrentCornerRadius();
         float endRadius = startRect.width() / 6f;
+
+        float startTransformProgress = mTransformParams.getProgress();
+        float endTransformProgress = 1;
+
         // We want the window alpha to be 0 once this threshold is met, so that the
         // FolderIconView can be seen morphing into the icon shape.
         final float windowAlphaThreshold = isFloatingIconView ? 1f - SHAPE_PROGRESS_DURATION : 1f;
@@ -437,7 +441,8 @@
             public void onUpdate(RectF currentRect, float progress) {
                 homeAnim.setPlayFraction(progress);
 
-                mTransformParams.setProgress(progress)
+                mTransformParams.setProgress(
+                        Utilities.mapRange(progress, startTransformProgress, endTransformProgress))
                         .setCurrentRect(currentRect)
                         .setTargetAlpha(getWindowAlpha(progress));
                 if (isFloatingIconView) {
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/util/AppWindowAnimationHelper.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/util/AppWindowAnimationHelper.java
index 25e18ae..b71fede 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/util/AppWindowAnimationHelper.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/util/AppWindowAnimationHelper.java
@@ -242,9 +242,10 @@
             Utilities.scaleRectFAboutCenter(mTmpRectF, params.mOffsetScale);
             mCurrentRect.set(mRectFEvaluator.evaluate(params.mProgress, mSourceRect, mTmpRectF));
             mCurrentRect.offset(params.mOffsetX, 0);
-
-            updateClipRect(params);
         }
+
+        updateClipRect(params);
+
         return mCurrentRect;
     }