ExpandHelper and ExpandHelperTest now use AndroidX / AnimatorTestRule

WMShell.FlingAnimationUtils now supports the AndroidX Animator

Bug: 291636627
Test: atest ExpandHelperTest
Change-Id: I7637eeeb5f5a6b11b71683bd3bbe1fad1ca186c3
diff --git a/libs/WindowManager/Shell/Android.bp b/libs/WindowManager/Shell/Android.bp
index 7159893..603272e 100644
--- a/libs/WindowManager/Shell/Android.bp
+++ b/libs/WindowManager/Shell/Android.bp
@@ -151,6 +151,7 @@
     ],
     static_libs: [
         "androidx.appcompat_appcompat",
+        "androidx.core_core-animation",
         "androidx.arch.core_core-runtime",
         "androidx-constraintlayout_constraintlayout",
         "androidx.dynamicanimation_dynamicanimation",
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/animation/FlingAnimationUtils.java b/libs/WindowManager/Shell/src/com/android/wm/shell/animation/FlingAnimationUtils.java
index 798250d..26edd7d 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/animation/FlingAnimationUtils.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/animation/FlingAnimationUtils.java
@@ -117,6 +117,20 @@
      * @param endValue  the end value of the animator
      * @param velocity  the current velocity of the motion
      */
+    public void apply(androidx.core.animation.Animator animator,
+            float currValue, float endValue, float velocity) {
+        apply(animator, currValue, endValue, velocity, Math.abs(endValue - currValue));
+    }
+
+    /**
+     * Applies the interpolator and length to the animator, such that the fling animation is
+     * consistent with the finger motion.
+     *
+     * @param animator  the animator to apply
+     * @param currValue the current value
+     * @param endValue  the end value of the animator
+     * @param velocity  the current velocity of the motion
+     */
     public void apply(ViewPropertyAnimator animator, float currValue, float endValue,
             float velocity) {
         apply(animator, currValue, endValue, velocity, Math.abs(endValue - currValue));
@@ -152,6 +166,24 @@
      * @param maxDistance the maximum distance for this interaction; the maximum animation length
      *                    gets multiplied by the ratio between the actual distance and this value
      */
+    public void apply(androidx.core.animation.Animator animator,
+            float currValue, float endValue, float velocity, float maxDistance) {
+        AnimatorProperties properties = getProperties(currValue, endValue, velocity, maxDistance);
+        animator.setDuration(properties.mDuration);
+        animator.setInterpolator(properties.getInterpolator());
+    }
+
+    /**
+     * Applies the interpolator and length to the animator, such that the fling animation is
+     * consistent with the finger motion.
+     *
+     * @param animator    the animator to apply
+     * @param currValue   the current value
+     * @param endValue    the end value of the animator
+     * @param velocity    the current velocity of the motion
+     * @param maxDistance the maximum distance for this interaction; the maximum animation length
+     *                    gets multiplied by the ratio between the actual distance and this value
+     */
     public void apply(ViewPropertyAnimator animator, float currValue, float endValue,
             float velocity, float maxDistance) {
         AnimatorProperties properties = getProperties(currValue, endValue, velocity,
@@ -367,6 +399,11 @@
     private static class AnimatorProperties {
         Interpolator mInterpolator;
         long mDuration;
+
+        /** Get an AndroidX interpolator wrapper of the current mInterpolator */
+        public androidx.core.animation.Interpolator getInterpolator() {
+            return mInterpolator::getInterpolation;
+        }
     }
 
     /** Builder for {@link #FlingAnimationUtils}. */