Merge "Pass in fling velocity for gesture progress" into ub-launcher3-qt-dev
diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/RecentsUiFactory.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/RecentsUiFactory.java
index ebae1cd..336cdc9 100644
--- a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/RecentsUiFactory.java
+++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/RecentsUiFactory.java
@@ -76,8 +76,13 @@
 
         @Override
         public void mapInsets(Context context, Rect insets, Rect out) {
+            // If there is a display cutout, the top insets in portrait would also include the
+            // cutout, which we will get as the left inset in landscape. Using the max of left and
+            // top allows us to cover both cases (with or without cutout).
             if (SysUINavigationMode.getMode(context) == NO_BUTTON) {
-                out.set(insets);
+                out.top = Math.max(insets.top, insets.left);
+                out.bottom = Math.max(insets.right, insets.bottom);
+                out.left = out.right = 0;
             } else {
                 out.top = Math.max(insets.top, insets.left);
                 out.bottom = insets.right;
@@ -99,7 +104,9 @@
         @Override
         public void mapInsets(Context context, Rect insets, Rect out) {
             if (SysUINavigationMode.getMode(context) == NO_BUTTON) {
-                out.set(insets);
+                out.top = Math.max(insets.top, insets.right);
+                out.bottom = Math.max(insets.left, insets.bottom);
+                out.left = out.right = 0;
             } else {
                 out.top = Math.max(insets.top, insets.right);
                 out.bottom = insets.left;
diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/states/BackgroundAppState.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/states/BackgroundAppState.java
index f429ce5..a662d74 100644
--- a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/states/BackgroundAppState.java
+++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/states/BackgroundAppState.java
@@ -17,6 +17,7 @@
 
 import static com.android.launcher3.LauncherAnimUtils.OVERVIEW_TRANSITION_MS;
 
+import com.android.launcher3.AbstractFloatingView;
 import com.android.launcher3.Launcher;
 import com.android.launcher3.allapps.AllAppsTransitionController;
 import com.android.launcher3.userevent.nano.LauncherLogProto;
@@ -42,6 +43,13 @@
     }
 
     @Override
+    public void onStateEnabled(Launcher launcher) {
+        RecentsView rv = launcher.getOverviewPanel();
+        rv.setOverviewStateEnabled(true);
+        AbstractFloatingView.closeAllOpenViews(launcher, false);
+    }
+
+    @Override
     public float getVerticalProgress(Launcher launcher) {
         if (launcher.getDeviceProfile().isVerticalBarLayout()) {
             return super.getVerticalProgress(launcher);
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/TouchInteractionService.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/TouchInteractionService.java
index 0fd74bb..0c997dd 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/TouchInteractionService.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/TouchInteractionService.java
@@ -331,21 +331,29 @@
         defaultDisplay.getRealSize(realSize);
         mSwipeTouchRegion.set(0, 0, realSize.x, realSize.y);
         if (mMode == Mode.NO_BUTTON) {
-            mSwipeTouchRegion.top = mSwipeTouchRegion.bottom - getNavbarSize(
-                    ResourceUtils.NAVBAR_VERTICAL_SIZE);
+            switch (defaultDisplay.getRotation()) {
+                case Surface.ROTATION_90:
+                case Surface.ROTATION_270:
+                    mSwipeTouchRegion.top = mSwipeTouchRegion.bottom - getNavbarSize(
+                            ResourceUtils.NAVBAR_LANDSCAPE_BOTTOM_SIZE);
+                    break;
+                default:
+                    mSwipeTouchRegion.top = mSwipeTouchRegion.bottom - getNavbarSize(
+                            ResourceUtils.NAVBAR_PORTRAIT_BOTTOM_SIZE);
+            }
         } else {
             switch (defaultDisplay.getRotation()) {
                 case Surface.ROTATION_90:
                     mSwipeTouchRegion.left = mSwipeTouchRegion.right
-                            - getNavbarSize(ResourceUtils.NAVBAR_HORIZONTAL_SIZE);
+                            - getNavbarSize(ResourceUtils.NAVBAR_LANDSCAPE_LEFT_RIGHT_SIZE);
                     break;
                 case Surface.ROTATION_270:
                     mSwipeTouchRegion.right = mSwipeTouchRegion.left
-                            + getNavbarSize(ResourceUtils.NAVBAR_HORIZONTAL_SIZE);
+                            + getNavbarSize(ResourceUtils.NAVBAR_LANDSCAPE_LEFT_RIGHT_SIZE);
                     break;
                 default:
                     mSwipeTouchRegion.top = mSwipeTouchRegion.bottom
-                            - getNavbarSize(ResourceUtils.NAVBAR_VERTICAL_SIZE);
+                            - getNavbarSize(ResourceUtils.NAVBAR_PORTRAIT_BOTTOM_SIZE);
             }
         }
     }
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 c864307..2ff5e23 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
@@ -23,6 +23,7 @@
 import static android.view.MotionEvent.ACTION_POINTER_UP;
 import static android.view.MotionEvent.ACTION_UP;
 
+import static com.android.launcher3.Utilities.squaredHypot;
 import static com.android.launcher3.userevent.nano.LauncherLogProto.Action.Direction.UPLEFT;
 import static com.android.launcher3.userevent.nano.LauncherLogProto.Action.Direction.UPRIGHT;
 import static com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch.FLING;
@@ -81,7 +82,7 @@
     private final float mDistThreshold;
     private final long mTimeThreshold;
     private final int mAngleThreshold;
-    private final float mSlop;
+    private final float mSquaredSlop;
     private final ISystemUiProxy mSysUiProxy;
     private final Context mContext;
     private final SwipeDetector mSwipeDetector;
@@ -96,7 +97,8 @@
         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);
-        mSlop = QuickStepContract.getQuickStepDragSlopPx();
+        float slop = QuickStepContract.getQuickStepDragSlopPx();
+        mSquaredSlop = slop * slop;
         mActivityControlHelper = activityControlHelper;
         mSwipeDetector = new SwipeDetector(mContext, this, SwipeDetector.VERTICAL);
         mSwipeDetector.setDetectableScrollConditions(SwipeDetector.DIRECTION_POSITIVE, false);
@@ -155,7 +157,8 @@
 
                 if (!mPassedSlop) {
                     // Normal gesture, ensure we pass the slop before we start tracking the gesture
-                    if (Math.hypot(mLastPos.x - mDownPos.x, mLastPos.y - mDownPos.y) > mSlop) {
+                    if (squaredHypot(mLastPos.x - mDownPos.x, mLastPos.y - mDownPos.y)
+                            > mSquaredSlop) {
 
                         mPassedSlop = true;
                         mStartDragPos.set(mLastPos.x, mLastPos.y);
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/DeviceLockedInputConsumer.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/DeviceLockedInputConsumer.java
index b1d175d..d01b5ec 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/DeviceLockedInputConsumer.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/DeviceLockedInputConsumer.java
@@ -15,11 +15,13 @@
  */
 package com.android.quickstep.inputconsumers;
 
+import static com.android.launcher3.Utilities.squaredHypot;
+import static com.android.launcher3.Utilities.squaredTouchSlop;
+
 import android.content.Context;
 import android.content.Intent;
 import android.graphics.PointF;
 import android.view.MotionEvent;
-import android.view.ViewConfiguration;
 
 /**
  * A dummy input consumer used when the device is still locked, e.g. from secure camera.
@@ -32,8 +34,7 @@
 
     public DeviceLockedInputConsumer(Context context) {
         mContext = context;
-        float touchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
-        mTouchSlopSquared = touchSlop * touchSlop;
+        mTouchSlopSquared = squaredTouchSlop(context);
     }
 
     @Override
@@ -48,9 +49,7 @@
         if (ev.getAction() == MotionEvent.ACTION_DOWN) {
             mTouchDown.set(x, y);
         } else if (ev.getAction() == MotionEvent.ACTION_MOVE) {
-            float xSquared = (x - mTouchDown.x) * (x - mTouchDown.x);
-            float ySquared = (y - mTouchDown.y) * (y - mTouchDown.y);
-            if (xSquared + ySquared > mTouchSlopSquared) {
+            if (squaredHypot(x - mTouchDown.x, y - mTouchDown.y) > mTouchSlopSquared) {
                 // For now, just start the home intent so user is prompted to unlock the device.
                 mContext.startActivity(new Intent(Intent.ACTION_MAIN)
                         .addCategory(Intent.CATEGORY_HOME)
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/OtherActivityInputConsumer.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/OtherActivityInputConsumer.java
index eb5366c..b0acffa 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/OtherActivityInputConsumer.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/OtherActivityInputConsumer.java
@@ -23,6 +23,7 @@
 import static android.view.MotionEvent.ACTION_UP;
 import static android.view.MotionEvent.INVALID_POINTER_ID;
 import static com.android.launcher3.Utilities.EDGE_NAV_BAR;
+import static com.android.launcher3.Utilities.squaredHypot;
 import static com.android.launcher3.uioverrides.RecentsUiFactory.ROTATION_LANDSCAPE;
 import static com.android.launcher3.uioverrides.RecentsUiFactory.ROTATION_SEASCAPE;
 import static com.android.launcher3.util.RaceConditionTracker.ENTER;
@@ -109,7 +110,7 @@
     private int mActivePointerId = INVALID_POINTER_ID;
 
     private final float mDragSlop;
-    private final float mTouchSlop;
+    private final float mSquaredTouchSlop;
 
     // Slop used to check when we start moving window.
     private boolean mPassedDragSlop;
@@ -157,7 +158,8 @@
 
         mDisplayRotation = getSystemService(WindowManager.class).getDefaultDisplay().getRotation();
         mDragSlop = QuickStepContract.getQuickStepDragSlopPx();
-        mTouchSlop = QuickStepContract.getQuickStepTouchSlopPx();
+        float slop = QuickStepContract.getQuickStepTouchSlopPx();
+        mSquaredTouchSlop = slop * slop;
 
         mPassedTouchSlop = mPassedDragSlop = continuingPreviousGesture;
     }
@@ -256,7 +258,7 @@
                 }
 
                 if (!mPassedTouchSlop) {
-                    if (Math.hypot(displacementX, mLastPos.y - mDownPos.y) >= mTouchSlop) {
+                    if (squaredHypot(displacementX, mLastPos.y - mDownPos.y) >= mSquaredTouchSlop) {
                         mPassedTouchSlop = true;
 
                         if (mIsDeferredDownTarget) {
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 a835680..661468a 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
@@ -20,6 +20,8 @@
 import static com.android.launcher3.InvariantDeviceProfile.CHANGE_FLAG_ICON_PARAMS;
 import static com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY;
 import static com.android.launcher3.Utilities.EDGE_NAV_BAR;
+import static com.android.launcher3.Utilities.squaredHypot;
+import static com.android.launcher3.Utilities.squaredTouchSlop;
 import static com.android.launcher3.anim.Interpolators.ACCEL;
 import static com.android.launcher3.anim.Interpolators.ACCEL_2;
 import static com.android.launcher3.anim.Interpolators.FAST_OUT_SLOW_IN;
@@ -281,7 +283,7 @@
     private boolean mHandleTaskStackChanges;
     private boolean mSwipeDownShouldLaunchApp;
     private boolean mTouchDownToStartHome;
-    private final int mTouchSlop;
+    private final float mSquaredTouchSlop;
     private int mDownX;
     private int mDownY;
 
@@ -339,7 +341,7 @@
         setLayoutDirection(mIsRtl ? View.LAYOUT_DIRECTION_RTL : View.LAYOUT_DIRECTION_LTR);
         mTaskTopMargin = getResources()
                 .getDimensionPixelSize(R.dimen.task_thumbnail_top_margin);
-        mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
+        mSquaredTouchSlop = squaredTouchSlop(context);
 
         mEmptyIcon = context.getDrawable(R.drawable.ic_empty_recents);
         mEmptyIcon.setCallback(this);
@@ -496,7 +498,8 @@
             case MotionEvent.ACTION_MOVE:
                 // Passing the touch slop will not allow dismiss to home
                 if (mTouchDownToStartHome &&
-                        (isHandlingTouch() || Math.hypot(mDownX - x, mDownY - y) > mTouchSlop)) {
+                        (isHandlingTouch() ||
+                                squaredHypot(mDownX - x, mDownY - y) > mSquaredTouchSlop)) {
                     mTouchDownToStartHome = false;
                 }
                 break;
diff --git a/src/com/android/launcher3/ResourceUtils.java b/src/com/android/launcher3/ResourceUtils.java
index 8df3290..0c80d13 100644
--- a/src/com/android/launcher3/ResourceUtils.java
+++ b/src/com/android/launcher3/ResourceUtils.java
@@ -21,8 +21,10 @@
 import android.util.TypedValue;
 
 public class ResourceUtils {
-    public static final String NAVBAR_VERTICAL_SIZE = "navigation_bar_frame_height";
-    public static final String NAVBAR_HORIZONTAL_SIZE = "navigation_bar_width";
+    public static final String NAVBAR_PORTRAIT_BOTTOM_SIZE = "navigation_bar_frame_height";
+    public static final String NAVBAR_LANDSCAPE_LEFT_RIGHT_SIZE = "navigation_bar_width";
+    public static final String NAVBAR_LANDSCAPE_BOTTOM_SIZE
+            = "navigation_bar_frame_height_landscape";
 
     public static int getNavbarSize(String resName, Resources res) {
         return getDimenByName(resName, res, 48);
diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java
index 796fd25..cc9bda7 100644
--- a/src/com/android/launcher3/Utilities.java
+++ b/src/com/android/launcher3/Utilities.java
@@ -61,6 +61,7 @@
 import android.util.TypedValue;
 import android.view.MotionEvent;
 import android.view.View;
+import android.view.ViewConfiguration;
 import android.view.animation.Interpolator;
 
 import com.android.launcher3.compat.LauncherAppsCompat;
@@ -726,6 +727,15 @@
         return str.toString();
     }
 
+    public static float squaredHypot(float x, float y) {
+        return x * x + y * y;
+    }
+
+    public static float squaredTouchSlop(Context context) {
+        float slop = ViewConfiguration.get(context).getScaledTouchSlop();
+        return slop * slop;
+    }
+
     private static class FixedSizeEmptyDrawable extends ColorDrawable {
 
         private final int mSize;
diff --git a/src/com/android/launcher3/folder/Folder.java b/src/com/android/launcher3/folder/Folder.java
index 389e852..2ef6d70 100644
--- a/src/com/android/launcher3/folder/Folder.java
+++ b/src/com/android/launcher3/folder/Folder.java
@@ -593,6 +593,10 @@
     protected void handleClose(boolean animate) {
         mIsOpen = false;
 
+        if (!animate && mCurrentAnimator != null && mCurrentAnimator.isRunning()) {
+            mCurrentAnimator.cancel();
+        }
+
         if (isEditingName()) {
             mFolderName.dispatchBackKey();
         }
diff --git a/src/com/android/launcher3/folder/FolderIcon.java b/src/com/android/launcher3/folder/FolderIcon.java
index 8d9c520..0a9bc72 100644
--- a/src/com/android/launcher3/folder/FolderIcon.java
+++ b/src/com/android/launcher3/folder/FolderIcon.java
@@ -203,6 +203,10 @@
         mBackground.getBounds(outBounds);
     }
 
+    public float getBackgroundStrokeWidth() {
+        return mBackground.getStrokeWidth();
+    }
+
     public Folder getFolder() {
         return mFolder;
     }
diff --git a/src/com/android/launcher3/popup/PopupContainerWithArrow.java b/src/com/android/launcher3/popup/PopupContainerWithArrow.java
index 047f486..7b14fa2 100644
--- a/src/com/android/launcher3/popup/PopupContainerWithArrow.java
+++ b/src/com/android/launcher3/popup/PopupContainerWithArrow.java
@@ -16,6 +16,8 @@
 
 package com.android.launcher3.popup;
 
+import static com.android.launcher3.Utilities.squaredHypot;
+import static com.android.launcher3.Utilities.squaredTouchSlop;
 import static com.android.launcher3.notification.NotificationMainView.NOTIFICATION_ITEM_INFO;
 import static com.android.launcher3.popup.PopupPopulator.MAX_SHORTCUTS;
 import static com.android.launcher3.popup.PopupPopulator.MAX_SHORTCUTS_IF_NOTIFICATIONS;
@@ -37,7 +39,6 @@
 import android.util.Pair;
 import android.view.MotionEvent;
 import android.view.View;
-import android.view.ViewConfiguration;
 import android.view.ViewGroup;
 import android.widget.ImageView;
 
@@ -51,6 +52,7 @@
 import com.android.launcher3.Launcher;
 import com.android.launcher3.LauncherModel;
 import com.android.launcher3.R;
+import com.android.launcher3.Utilities;
 import com.android.launcher3.accessibility.LauncherAccessibilityDelegate;
 import com.android.launcher3.accessibility.ShortcutMenuAccessibilityDelegate;
 import com.android.launcher3.dot.DotInfo;
@@ -136,8 +138,8 @@
             return true;
         }
         // Stop sending touch events to deep shortcut views if user moved beyond touch slop.
-        return Math.hypot(mInterceptTouchDown.x - ev.getX(), mInterceptTouchDown.y - ev.getY())
-                > ViewConfiguration.get(getContext()).getScaledTouchSlop();
+        return squaredHypot(mInterceptTouchDown.x - ev.getX(), mInterceptTouchDown.y - ev.getY())
+                > squaredTouchSlop(getContext());
     }
 
     @Override
diff --git a/src/com/android/launcher3/views/FloatingIconView.java b/src/com/android/launcher3/views/FloatingIconView.java
index e5c75c3..a9e8f17 100644
--- a/src/com/android/launcher3/views/FloatingIconView.java
+++ b/src/com/android/launcher3/views/FloatingIconView.java
@@ -259,8 +259,6 @@
                 mFgSpringX.animateToFinalPosition(diffX);
                 mFgSpringY.animateToFinalPosition(diffY);
             }
-
-
         }
         invalidate();
         invalidateOutline();
@@ -368,10 +366,13 @@
                 drawable = v.getBackground();
             }
         } else {
+            boolean isFolderIcon = v instanceof FolderIcon;
+            int width = isFolderIcon ? v.getWidth() : lp.width;
+            int height = isFolderIcon ? v.getHeight() : lp.height;
             if (supportsAdaptiveIcons) {
-                drawable = Utilities.getFullDrawable(mLauncher, info, lp.width, lp.height,
-                        false, sTmpObjArray);
-                if ((drawable instanceof AdaptiveIconDrawable)) {
+                drawable = Utilities.getFullDrawable(mLauncher, info, width, height, false,
+                        sTmpObjArray);
+                if (drawable instanceof AdaptiveIconDrawable) {
                     mBadge = getBadge(mLauncher, info, sTmpObjArray[0]);
                 } else {
                     // The drawable we get back is not an adaptive icon, so we need to use the
@@ -383,8 +384,8 @@
                     // Similar to DragView, we simply use the BubbleTextView icon here.
                     drawable = btvIcon;
                 } else {
-                    drawable = Utilities.getFullDrawable(mLauncher, info, lp.width, lp.height,
-                            false, sTmpObjArray);
+                    drawable = Utilities.getFullDrawable(mLauncher, info, width, height, false,
+                            sTmpObjArray);
                 }
             }
         }
@@ -412,13 +413,6 @@
                 }
                 mForeground = foreground;
 
-                if (mForeground instanceof ShiftedBitmapDrawable && v instanceof FolderIcon) {
-                    ShiftedBitmapDrawable sbd = (ShiftedBitmapDrawable) mForeground;
-                    ((FolderIcon) v).getPreviewBounds(sTmpRect);
-                    sbd.setShiftX(sbd.getShiftX() - sTmpRect.left);
-                    sbd.setShiftY(sbd.getShiftY() - sTmpRect.top);
-                }
-
                 final int originalHeight = lp.height;
                 final int originalWidth = lp.width;
 
@@ -434,13 +428,25 @@
 
                 if (mBadge != null) {
                     mBadge.setBounds(mStartRevealRect);
-                    if (!isOpening) {
+                    if (!isOpening && !isFolderIcon) {
                         DRAWABLE_ALPHA.set(mBadge, 0);
                     }
-
                 }
 
-                if (!isFolderIcon) {
+                if (isFolderIcon) {
+                    ((FolderIcon) v).getPreviewBounds(sTmpRect);
+                    float bgStroke = ((FolderIcon) v).getBackgroundStrokeWidth();
+                    if (mForeground instanceof ShiftedBitmapDrawable) {
+                        ShiftedBitmapDrawable sbd = (ShiftedBitmapDrawable) mForeground;
+                        sbd.setShiftX(sbd.getShiftX() - sTmpRect.left - bgStroke);
+                        sbd.setShiftY(sbd.getShiftY() - sTmpRect.top - bgStroke);
+                    }
+                    if (mBadge instanceof ShiftedBitmapDrawable) {
+                        ShiftedBitmapDrawable sbd = (ShiftedBitmapDrawable) mBadge;
+                        sbd.setShiftX(sbd.getShiftX() - sTmpRect.left - bgStroke);
+                        sbd.setShiftY(sbd.getShiftY() - sTmpRect.top - bgStroke);
+                    }
+                } else {
                     Utilities.scaleRectAboutCenter(mStartRevealRect,
                             IconShape.getNormalizationScale());
                 }
@@ -665,7 +671,7 @@
             }
         });
 
-        if (mBadge != null) {
+        if (mBadge != null && !(mOriginalIcon instanceof FolderIcon)) {
             ObjectAnimator badgeFade = ObjectAnimator.ofInt(mBadge, DRAWABLE_ALPHA, 255);
             badgeFade.addUpdateListener(valueAnimator -> invalidate());
             fade.play(badgeFade);
@@ -691,7 +697,6 @@
                 @Override
                 public void onAnimationEnd(Animator animation) {
                     folderIcon.setBackgroundVisible(true);
-                    folderIcon.animateBgShadowAndStroke();
                     if (folderIcon.hasDot()) {
                         folderIcon.animateDotScale(0, 1f);
                     }
diff --git a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java
index ca6d968..74cece8 100644
--- a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java
+++ b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java
@@ -243,7 +243,7 @@
      */
     protected UiObject2 scrollAndFind(UiObject2 container, BySelector condition) {
         final int margin = ResourceUtils.getNavbarSize(
-                ResourceUtils.NAVBAR_VERTICAL_SIZE, mLauncher.getResources()) + 1;
+                ResourceUtils.NAVBAR_PORTRAIT_BOTTOM_SIZE, mLauncher.getResources()) + 1;
         container.setGestureMargins(0, 0, 0, margin);
 
         int i = 0;
diff --git a/tests/tapl/com/android/launcher3/tapl/AllApps.java b/tests/tapl/com/android/launcher3/tapl/AllApps.java
index a296975..70405fe 100644
--- a/tests/tapl/com/android/launcher3/tapl/AllApps.java
+++ b/tests/tapl/com/android/launcher3/tapl/AllApps.java
@@ -18,6 +18,7 @@
 
 import static com.android.launcher3.tapl.LauncherInstrumentation.NavigationModel.ZERO_BUTTON;
 
+import android.graphics.Point;
 import android.graphics.Rect;
 
 import androidx.annotation.NonNull;
@@ -48,12 +49,34 @@
         return LauncherInstrumentation.ContainerType.ALL_APPS;
     }
 
-    private boolean hasClickableIcon(UiObject2 allAppsContainer, BySelector appIconSelector) {
-        final UiObject2 icon = allAppsContainer.findObject(appIconSelector);
-        if (icon == null) return false;
-        if (mLauncher.getNavigationModel() == ZERO_BUTTON) return true;
-        final UiObject2 navBar = mLauncher.waitForSystemUiObject("navigation_bar_frame");
-        return icon.getVisibleBounds().bottom < navBar.getVisibleBounds().top;
+    private boolean hasClickableIcon(
+            UiObject2 allAppsContainer, UiObject2 appListRecycler, BySelector appIconSelector) {
+        final UiObject2 icon = appListRecycler.findObject(appIconSelector);
+        if (icon == null) {
+            LauncherInstrumentation.log("hasClickableIcon: icon not visible");
+            return false;
+        }
+        final Rect iconBounds = icon.getVisibleBounds();
+        LauncherInstrumentation.log("hasClickableIcon: icon bounds: " + iconBounds);
+        if (mLauncher.getNavigationModel() != ZERO_BUTTON) {
+            final UiObject2 navBar = mLauncher.waitForSystemUiObject("navigation_bar_frame");
+            if (iconBounds.bottom >= navBar.getVisibleBounds().top) {
+                LauncherInstrumentation.log("hasClickableIcon: icon intersects with nav bar");
+                return false;
+            }
+        }
+        if (iconCenterInSearchBox(allAppsContainer, icon)) {
+            LauncherInstrumentation.log("hasClickableIcon: icon center is under search box");
+            return false;
+        }
+        LauncherInstrumentation.log("hasClickableIcon: icon is clickable");
+        return true;
+    }
+
+    private boolean iconCenterInSearchBox(UiObject2 allAppsContainer, UiObject2 icon) {
+        final Point iconCenter = icon.getVisibleCenter();
+        return getSearchBox(allAppsContainer).getVisibleBounds().contains(
+                iconCenter.x, iconCenter.y);
     }
 
     /**
@@ -66,17 +89,22 @@
     @NonNull
     public AppIcon getAppIcon(String appName) {
         try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
-                "want to get app icon on all apps")) {
+                "want to get app icon " + appName + " on all apps")) {
             final UiObject2 allAppsContainer = verifyActiveContainer();
-            allAppsContainer.setGestureMargins(0, 0, 0,
-                    ResourceUtils.getNavbarSize(ResourceUtils.NAVBAR_VERTICAL_SIZE,
+            final UiObject2 appListRecycler = mLauncher.waitForObjectInContainer(allAppsContainer,
+                    "apps_list_view");
+            allAppsContainer.setGestureMargins(
+                    0,
+                    getSearchBox(allAppsContainer).getVisibleBounds().bottom + 1,
+                    0,
+                    ResourceUtils.getNavbarSize(ResourceUtils.NAVBAR_PORTRAIT_BOTTOM_SIZE,
                             mLauncher.getResources()) + 1);
             final BySelector appIconSelector = AppIcon.getAppIconSelector(appName, mLauncher);
-            if (!hasClickableIcon(allAppsContainer, appIconSelector)) {
+            if (!hasClickableIcon(allAppsContainer, appListRecycler, appIconSelector)) {
                 scrollBackToBeginning();
                 int attempts = 0;
                 try (LauncherInstrumentation.Closable c1 = mLauncher.addContextLayer("scrolled")) {
-                    while (!hasClickableIcon(allAppsContainer, appIconSelector) &&
+                    while (!hasClickableIcon(allAppsContainer, appListRecycler, appIconSelector) &&
                             allAppsContainer.scroll(Direction.DOWN, 0.8f)) {
                         mLauncher.assertTrue(
                                 "Exceeded max scroll attempts: " + MAX_SCROLL_ATTEMPTS,
@@ -89,7 +117,7 @@
 
             final UiObject2 appIcon = mLauncher.getObjectInContainer(allAppsContainer,
                     appIconSelector);
-            ensureIconVisible(appIcon, allAppsContainer);
+            ensureIconVisible(appIcon, allAppsContainer, appListRecycler);
             return new AppIcon(mLauncher, appIcon);
         }
     }
@@ -97,10 +125,9 @@
     private void scrollBackToBeginning() {
         try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
                 "want to scroll back in all apps")) {
+            LauncherInstrumentation.log("Scrolling to the beginning");
             final UiObject2 allAppsContainer = verifyActiveContainer();
-            final UiObject2 searchBox =
-                    mLauncher.waitForObjectInContainer(allAppsContainer,
-                            "search_container_all_apps");
+            final UiObject2 searchBox = getSearchBox(allAppsContainer);
 
             int attempts = 0;
             final Rect margins = new Rect(0, searchBox.getVisibleBounds().bottom + 1, 0, 5);
@@ -128,19 +155,26 @@
                 getInt(TestProtocol.SCROLL_Y_FIELD, -1);
     }
 
-    private void ensureIconVisible(UiObject2 appIcon, UiObject2 allAppsContainer) {
+    private void ensureIconVisible(
+            UiObject2 appIcon, UiObject2 allAppsContainer, UiObject2 appListRecycler) {
         final int appHeight = appIcon.getVisibleBounds().height();
         if (appHeight < MIN_INTERACT_SIZE) {
             // Try to figure out how much percentage of the container needs to be scrolled in order
             // to reveal the app icon to have the MIN_INTERACT_SIZE
             final float pct = Math.max(((float) (MIN_INTERACT_SIZE - appHeight)) / mHeight, 0.2f);
-            mLauncher.scroll(allAppsContainer, Direction.DOWN, pct, null, 10);
+            mLauncher.scroll(appListRecycler, Direction.DOWN, pct, null, 10);
             try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
                     "scrolled an icon in all apps to make it visible - and then")) {
                 mLauncher.waitForIdle();
                 verifyActiveContainer();
             }
         }
+        mLauncher.assertTrue("Couldn't scroll app icon to not intersect with the search box",
+                !iconCenterInSearchBox(allAppsContainer, appIcon));
+    }
+
+    private UiObject2 getSearchBox(UiObject2 allAppsContainer) {
+        return mLauncher.waitForObjectInContainer(allAppsContainer, "search_container_all_apps");
     }
 
     /**
diff --git a/tests/tapl/com/android/launcher3/tapl/Widgets.java b/tests/tapl/com/android/launcher3/tapl/Widgets.java
index f7e0b6c..b780df4 100644
--- a/tests/tapl/com/android/launcher3/tapl/Widgets.java
+++ b/tests/tapl/com/android/launcher3/tapl/Widgets.java
@@ -41,7 +41,7 @@
             LauncherInstrumentation.log("Widgets.flingForward enter");
             final UiObject2 widgetsContainer = verifyActiveContainer();
             widgetsContainer.setGestureMargins(0, 0, 0,
-                    ResourceUtils.getNavbarSize(ResourceUtils.NAVBAR_VERTICAL_SIZE,
+                    ResourceUtils.getNavbarSize(ResourceUtils.NAVBAR_PORTRAIT_BOTTOM_SIZE,
                             mLauncher.getResources()) + 1);
             widgetsContainer.fling(Direction.DOWN,
                     (int) (FLING_SPEED * mLauncher.getDisplayDensity()));