Merge "Overview Actions - enable proactive actions flag." into ub-launcher3-rvc-qpr-dev
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandlerV2.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandlerV2.java
index ed33532..0aa1486 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandlerV2.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandlerV2.java
@@ -493,7 +493,11 @@
         // much the window is bound by overscroll (vs moving freely).
         if (animate) {
             ValueAnimator reapplyWindowTransformAnim = ValueAnimator.ofFloat(0, 1);
-            reapplyWindowTransformAnim.addUpdateListener(anim -> applyWindowTransform());
+            reapplyWindowTransformAnim.addUpdateListener(anim -> {
+                if (mRunningWindowAnim == null) {
+                    applyWindowTransform();
+                }
+            });
             reapplyWindowTransformAnim.setDuration(RECENTS_ATTACH_DURATION).start();
         } else {
             applyWindowTransform();
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java
index eeff422..677cd72 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java
@@ -24,6 +24,7 @@
 import static com.android.launcher3.InvariantDeviceProfile.CHANGE_FLAG_ICON_PARAMS;
 import static com.android.launcher3.LauncherAnimUtils.VIEW_ALPHA;
 import static com.android.launcher3.LauncherState.BACKGROUND_APP;
+import static com.android.launcher3.LauncherState.OVERVIEW_MODAL_TASK;
 import static com.android.launcher3.Utilities.EDGE_NAV_BAR;
 import static com.android.launcher3.Utilities.mapToRange;
 import static com.android.launcher3.Utilities.squaredHypot;
@@ -93,6 +94,7 @@
 import com.android.launcher3.DeviceProfile;
 import com.android.launcher3.Insettable;
 import com.android.launcher3.InvariantDeviceProfile;
+import com.android.launcher3.LauncherState;
 import com.android.launcher3.PagedView;
 import com.android.launcher3.R;
 import com.android.launcher3.Utilities;
@@ -1723,6 +1725,11 @@
         if (mOrientationState.setRecentsRotation(mActivity.getDisplay().getRotation())) {
             updateOrientationHandler();
         }
+        // If overview is in modal state when rotate, reset it to overview state without running
+        // animation.
+        if (mActivity.isInState(OVERVIEW_MODAL_TASK)) {
+            mActivity.getStateManager().goToState(LauncherState.OVERVIEW, false);
+        }
     }
 
     public void setLayoutRotation(int touchRotation, int displayRotation) {
diff --git a/quickstep/src/com/android/quickstep/util/MotionPauseDetector.java b/quickstep/src/com/android/quickstep/util/MotionPauseDetector.java
index 969fa50..f60f7ad 100644
--- a/quickstep/src/com/android/quickstep/util/MotionPauseDetector.java
+++ b/quickstep/src/com/android/quickstep/util/MotionPauseDetector.java
@@ -276,7 +276,7 @@
         private static final int HISTORY_SIZE = 20;
 
         // Position history are stored in a circular array
-        private final float[] mHistoricTimes = new float[HISTORY_SIZE];
+        private final long[] mHistoricTimes = new long[HISTORY_SIZE];
         private final float[] mHistoricPos = new float[HISTORY_SIZE];
         private int mHistoryCount = 0;
         private int mHistoryStart = 0;
@@ -292,7 +292,7 @@
             mHistoryCount = mHistoryStart = 0;
         }
 
-        private void addPositionAndTime(float eventTime, float eventPosition) {
+        private void addPositionAndTime(long eventTime, float eventPosition) {
             mHistoricTimes[mHistoryStart] = eventTime;
             mHistoricPos[mHistoryStart] = eventPosition;
             mHistoryStart++;
@@ -322,7 +322,7 @@
          * Based on solveUnweightedLeastSquaresDeg2 in VelocityTracker.cpp
          */
         private Float solveUnweightedLeastSquaresDeg2(final int pointPos) {
-            final float eventTime = mHistoricTimes[pointPos];
+            final long eventTime = mHistoricTimes[pointPos];
 
             float sxi = 0, sxiyi = 0, syi = 0, sxi2 = 0, sxi3 = 0, sxi2yi = 0, sxi4 = 0;
             int count = 0;
@@ -332,8 +332,8 @@
                     index += HISTORY_SIZE;
                 }
 
-                float time = mHistoricTimes[index];
-                float age = eventTime - time;
+                long time = mHistoricTimes[index];
+                long age = eventTime - time;
                 if (age > HORIZON_MS) {
                     break;
                 }
@@ -364,7 +364,7 @@
                         if (endPos < 0) {
                             endPos += HISTORY_SIZE;
                         }
-                        float denominator = eventTime - mHistoricTimes[endPos];
+                        long denominator = eventTime - mHistoricTimes[endPos];
                         if (denominator != 0) {
                             return (mHistoricPos[pointPos] - mHistoricPos[endPos]) / denominator;
                         }