Merge "Fix some issues with shelf jumping/duration" into ub-launcher3-qt-dev
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/AssistantTouchConsumer.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/AssistantTouchConsumer.java
index 2ff5e23..bf276e1 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/AssistantTouchConsumer.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/AssistantTouchConsumer.java
@@ -41,6 +41,7 @@
 import android.util.Log;
 import android.view.HapticFeedbackConstants;
 import android.view.MotionEvent;
+import android.view.ViewConfiguration;
 
 import com.android.launcher3.BaseDraggingActivity;
 import com.android.launcher3.R;
@@ -97,7 +98,9 @@
         mDistThreshold = res.getDimension(R.dimen.gestures_assistant_drag_threshold);
         mTimeThreshold = res.getInteger(R.integer.assistant_gesture_min_time_threshold);
         mAngleThreshold = res.getInteger(R.integer.assistant_gesture_corner_deg_threshold);
-        float slop = QuickStepContract.getQuickStepDragSlopPx();
+
+        float slop = ViewConfiguration.get(context).getScaledTouchSlop();
+
         mSquaredSlop = slop * slop;
         mActivityControlHelper = activityControlHelper;
         mSwipeDetector = new SwipeDetector(mContext, this, SwipeDetector.VERTICAL);
@@ -273,7 +276,7 @@
 
     @Override
     public void onDragEnd(float velocity, boolean fling) {
-        if (fling && !mLaunchedAssistant) {
+        if (fling && !mLaunchedAssistant && mState != STATE_DELEGATE_ACTIVE) {
             mLastProgress = 1;
             try {
                 mSysUiProxy.onAssistantGestureCompletion(velocity);
diff --git a/src/com/android/launcher3/views/FloatingIconView.java b/src/com/android/launcher3/views/FloatingIconView.java
index a9e8f17..3d5877a 100644
--- a/src/com/android/launcher3/views/FloatingIconView.java
+++ b/src/com/android/launcher3/views/FloatingIconView.java
@@ -481,6 +481,7 @@
                 setClipToOutline(true);
             } else {
                 setBackground(finalDrawable);
+                setClipToOutline(false);
             }
 
             if (!loadIconSignal.isCanceled()) {
@@ -751,5 +752,6 @@
         mFgTransX = 0;
         mFgSpringY.cancel();
         mBadge = null;
+        sTmpObjArray[0] = null;
     }
 }
diff --git a/tests/tapl/com/android/launcher3/tapl/AllAppsFromOverview.java b/tests/tapl/com/android/launcher3/tapl/AllAppsFromOverview.java
index c3b671b..a472d31 100644
--- a/tests/tapl/com/android/launcher3/tapl/AllAppsFromOverview.java
+++ b/tests/tapl/com/android/launcher3/tapl/AllAppsFromOverview.java
@@ -53,9 +53,9 @@
                     TestProtocol.REQUEST_ALL_APPS_TO_OVERVIEW_SWIPE_HEIGHT).
                     getInt(TestProtocol.TEST_INFO_RESPONSE_FIELD);
 
-            final int endY = start.y + swipeHeight + mLauncher.getTouchSlop();
+            final int endY = start.y + swipeHeight;
             LauncherInstrumentation.log("AllAppsFromOverview.switchBackToOverview before swipe");
-            mLauncher.swipe(start.x, start.y, start.x, endY, OVERVIEW_STATE_ORDINAL);
+            mLauncher.swipeToState(start.x, start.y, start.x, endY, 60, OVERVIEW_STATE_ORDINAL);
 
             try (LauncherInstrumentation.Closable c1 = mLauncher.addContextLayer("swiped down")) {
                 return new Overview(mLauncher);
diff --git a/tests/tapl/com/android/launcher3/tapl/Background.java b/tests/tapl/com/android/launcher3/tapl/Background.java
index 8f5e7fe..55e14cc 100644
--- a/tests/tapl/com/android/launcher3/tapl/Background.java
+++ b/tests/tapl/com/android/launcher3/tapl/Background.java
@@ -86,9 +86,10 @@
                 final int swipeHeight = mLauncher.getTestInfo(getSwipeHeightRequestName()).
                         getInt(TestProtocol.TEST_INFO_RESPONSE_FIELD);
 
-                mLauncher.swipe(
+                mLauncher.swipeToState(
                         centerX, startY, centerX,
                         startY - swipeHeight - mLauncher.getTouchSlop(),
+                        60,
                         expectedState);
                 break;
             }
diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
index 57fd4b9..a4711f5 100644
--- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
+++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
@@ -584,18 +584,15 @@
         return mDevice;
     }
 
-    void swipe(int startX, int startY, int endX, int endY, int expectedState) {
-        swipe(startX, startY, endX, endY, expectedState, 60);
-    }
-
-    void swipe(int startX, int startY, int endX, int endY, int expectedState, int steps) {
-        changeStateViaGesture(startX, startY, endX, endY, expectedState,
-                () -> mDevice.swipe(startX, startY, endX, endY, steps));
-    }
-
     void swipeToState(int startX, int startY, int endX, int endY, int steps, int expectedState) {
-        changeStateViaGesture(startX, startY, endX, endY, expectedState,
-                () -> linearGesture(startX, startY, endX, endY, steps));
+        final Bundle parcel = (Bundle) executeAndWaitForEvent(
+                () -> linearGesture(startX, startY, endX, endY, steps),
+                event -> TestProtocol.SWITCHED_TO_STATE_MESSAGE.equals(event.getClassName()),
+                "Swipe failed to receive an event for the swipe end: " + startX + ", " + startY
+                        + ", " + endX + ", " + endY);
+        assertEquals("Swipe switched launcher to a wrong state;",
+                TestProtocol.stateOrdinalToString(expectedState),
+                TestProtocol.stateOrdinalToString(parcel.getInt(TestProtocol.STATE_FIELD)));
     }
 
     void scroll(UiObject2 container, Direction direction, float percent, Rect margins, int steps) {
@@ -652,18 +649,6 @@
         sendPointer(downTime, endTime, MotionEvent.ACTION_UP, end);
     }
 
-    private void changeStateViaGesture(int startX, int startY, int endX, int endY,
-            int expectedState, Runnable gesture) {
-        final Bundle parcel = (Bundle) executeAndWaitForEvent(
-                gesture,
-                event -> TestProtocol.SWITCHED_TO_STATE_MESSAGE.equals(event.getClassName()),
-                "Swipe failed to receive an event for the swipe end: " + startX + ", " + startY
-                        + ", " + endX + ", " + endY);
-        assertEquals("Swipe switched launcher to a wrong state;",
-                TestProtocol.stateOrdinalToString(expectedState),
-                TestProtocol.stateOrdinalToString(parcel.getInt(TestProtocol.STATE_FIELD)));
-    }
-
     void waitForIdle() {
         mDevice.waitForIdle();
     }