Snap for 7566245 from be0b07001970eee18aeee96a99c6f7595c642a25 to sc-v2-release

Change-Id: I4eadeb6c33b4f5ec53ea3aaabb1e1fb117015b5b
diff --git a/lint-baseline-launcher3.xml b/lint-baseline-launcher3.xml
index e77c889..94345a6 100644
--- a/lint-baseline-launcher3.xml
+++ b/lint-baseline-launcher3.xml
@@ -584,4 +584,15 @@
             column="17"/>
     </issue>
 
+    <issue
+        id="NewApi"
+        message="Call requires API level 27 (current min is 26): `android.app.WallpaperManager#getWallpaperColors`"
+        errorLine1="                    : WallpaperManager.getInstance(context).getWallpaperColors(FLAG_SYSTEM);"
+        errorLine2="                                                            ~~~~~~~~~~~~~~~~~~">
+        <location
+            file="packages/apps/Launcher3/src/com/android/launcher3/graphics/LauncherPreviewRenderer.java"
+            line="288"
+            column="61"/>
+    </issue>
+
 </issues>
diff --git a/quickstep/src/com/android/launcher3/appprediction/PredictionRowView.java b/quickstep/src/com/android/launcher3/appprediction/PredictionRowView.java
index de04082..6afbf9a 100644
--- a/quickstep/src/com/android/launcher3/appprediction/PredictionRowView.java
+++ b/quickstep/src/com/android/launcher3/appprediction/PredictionRowView.java
@@ -96,6 +96,13 @@
 
     private void updateVisibility() {
         setVisibility(mPredictionsEnabled ? VISIBLE : GONE);
+        if (mLauncher.getAppsView() != null) {
+            if (mPredictionsEnabled) {
+                mLauncher.getAppsView().getAppsStore().registerIconContainer(this);
+            } else {
+                mLauncher.getAppsView().getAppsStore().unregisterIconContainer(this);
+            }
+        }
     }
 
     @Override
diff --git a/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java b/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java
index 8b11154..b5c834d 100644
--- a/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java
@@ -233,11 +233,6 @@
         }
     }
 
-    @Override
-    public boolean onLongPressToUnstashTaskbar() {
-        return mControllers.taskbarStashController.onLongPressToUnstashTaskbar();
-    }
-
     /**
      * @param ev MotionEvent in screen coordinates.
      * @return Whether any Taskbar item could handle the given MotionEvent if given the chance.
diff --git a/quickstep/src/com/android/launcher3/taskbar/StashedHandleViewController.java b/quickstep/src/com/android/launcher3/taskbar/StashedHandleViewController.java
index 8c14ff6..df37261 100644
--- a/quickstep/src/com/android/launcher3/taskbar/StashedHandleViewController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/StashedHandleViewController.java
@@ -40,6 +40,8 @@
     private final int mStashedHandleHeight;
     private final AnimatedFloat mTaskbarStashedHandleAlpha = new AnimatedFloat(
             this::updateStashedHandleAlpha);
+    private final AnimatedFloat mTaskbarStashedHandleHintScale = new AnimatedFloat(
+            this::updateStashedHandleHintScale);
 
     // Initialized in init.
     private TaskbarControllers mControllers;
@@ -64,6 +66,7 @@
         mStashedHandleView.getLayoutParams().height = mActivity.getDeviceProfile().taskbarSize;
 
         updateStashedHandleAlpha();
+        mTaskbarStashedHandleHintScale.updateValue(1f);
 
         final int stashedTaskbarHeight = mControllers.taskbarStashController.getStashedHeight();
         mStashedHandleView.setOutlineProvider(new ViewOutlineProvider() {
@@ -80,12 +83,24 @@
                 outline.setRoundRect(mStashedHandleBounds, mStashedHandleRadius);
             }
         });
+
+        mStashedHandleView.addOnLayoutChangeListener((view, i, i1, i2, i3, i4, i5, i6, i7) -> {
+            final int stashedCenterX = view.getWidth() / 2;
+            final int stashedCenterY = view.getHeight() - stashedTaskbarHeight / 2;
+
+            view.setPivotX(stashedCenterX);
+            view.setPivotY(stashedCenterY);
+        });
     }
 
     public AnimatedFloat getStashedHandleAlpha() {
         return mTaskbarStashedHandleAlpha;
     }
 
+    public AnimatedFloat getStashedHandleHintScale() {
+        return mTaskbarStashedHandleHintScale;
+    }
+
     /**
      * Creates and returns a {@link RevealOutlineAnimation} Animator that updates the stashed handle
      * shape and size. When stashed, the shape is a thin rounded pill. When unstashed, the shape
@@ -105,4 +120,9 @@
     protected void updateStashedHandleAlpha() {
         mStashedHandleView.setAlpha(mTaskbarStashedHandleAlpha.value);
     }
+
+    protected void updateStashedHandleHintScale() {
+        mStashedHandleView.setScaleX(mTaskbarStashedHandleHintScale.value);
+        mStashedHandleView.setScaleY(mTaskbarStashedHandleHintScale.value);
+    }
 }
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
index e11f4c1..dbe528f 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
@@ -332,4 +332,20 @@
 
         AbstractFloatingView.closeAllOpenViews(this);
     }
+
+    /**
+     * Called when we detect a long press in the nav region before passing the gesture slop.
+     * @return Whether taskbar handled the long press, and thus should cancel the gesture.
+     */
+    public boolean onLongPressToUnstashTaskbar() {
+        return mControllers.taskbarStashController.onLongPressToUnstashTaskbar();
+    }
+
+    /**
+     * Called when we detect a motion down or up/cancel in the nav region while stashed.
+     * @param animateForward Whether to animate towards the unstashed hint state or back to stashed.
+     */
+    public void startTaskbarUnstashHint(boolean animateForward) {
+        mControllers.taskbarStashController.startUnstashHint(animateForward);
+    }
 }
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java
index a226db9..45eabed 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java
@@ -27,6 +27,7 @@
 import android.view.Display;
 
 import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
 
 import com.android.launcher3.BaseQuickstepLauncher;
 import com.android.launcher3.DeviceProfile;
@@ -188,4 +189,8 @@
         mDisplayController.removeChangeListener(this);
         mSysUINavigationMode.removeModeChangeListener(this);
     }
+
+    public @Nullable TaskbarActivityContext getCurrentActivityContext() {
+        return mTaskbarActivityContext;
+    }
 }
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java
index 4ebdbd8..0efec53 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java
@@ -23,6 +23,7 @@
 import android.annotation.Nullable;
 import android.content.SharedPreferences;
 import android.content.res.Resources;
+import android.view.ViewConfiguration;
 
 import com.android.launcher3.R;
 import com.android.launcher3.Utilities;
@@ -47,6 +48,22 @@
     private static final float STASHED_TASKBAR_SCALE = 0.5f;
 
     /**
+     * How long the hint animation plays, starting on motion down.
+     */
+    private static final long TASKBAR_HINT_STASH_DURATION =
+            ViewConfiguration.DEFAULT_LONG_PRESS_TIMEOUT;
+
+    /**
+     * The scale that TaskbarView animates to when hinting towards the stashed state.
+     */
+    private static final float STASHED_TASKBAR_HINT_SCALE = 0.9f;
+
+    /**
+     * The scale that the stashed handle animates to when hinting towards the unstashed state.
+     */
+    private static final float UNSTASHED_TASKBAR_HANDLE_HINT_SCALE = 1.1f;
+
+    /**
      * The SharedPreferences key for whether user has manually stashed the taskbar.
      */
     private static final String SHARED_PREFS_STASHED_KEY = "taskbar_is_stashed";
@@ -71,6 +88,7 @@
     private AnimatedFloat mIconTranslationYForStash;
     // Stashed handle properties.
     private AnimatedFloat mTaskbarStashedHandleAlpha;
+    private AnimatedFloat mTaskbarStashedHandleHintScale;
 
     /** Whether the user has manually invoked taskbar stashing, which we persist. */
     private boolean mIsStashedInApp;
@@ -102,6 +120,7 @@
         StashedHandleViewController stashedHandleController =
                 controllers.stashedHandleViewController;
         mTaskbarStashedHandleAlpha = stashedHandleController.getStashedHandleAlpha();
+        mTaskbarStashedHandleHintScale = stashedHandleController.getStashedHandleHintScale();
 
         mIsStashedInApp = supportsStashing()
                 && mPrefs.getBoolean(SHARED_PREFS_STASHED_KEY, DEFAULT_STASHED_PREF);
@@ -246,6 +265,9 @@
         if (stashedHandleRevealAnim != null) {
             fullLengthAnimatorSet.play(stashedHandleRevealAnim);
         }
+        // Return the stashed handle to its default scale in case it was changed as part of the
+        // feedforward hint. Note that the reveal animation above also visually scales it.
+        fullLengthAnimatorSet.play(mTaskbarStashedHandleHintScale.animateToValue(1f));
 
         fullLengthAnimatorSet.setDuration(duration);
         firstHalfAnimatorSet.setDuration((long) (duration * firstHalfDurationScale));
@@ -271,4 +293,36 @@
         });
         return mAnimator;
     }
+
+    /**
+     * Creates and starts a partial stash animation, hinting at the new state that will trigger when
+     * long press is detected.
+     * @param animateForward Whether we are going towards the new stashed state or returning to the
+     *                       unstashed state.
+     */
+    public void startStashHint(boolean animateForward) {
+        if (isStashed() || !supportsStashing()) {
+            // Already stashed, no need to hint in that direction.
+            return;
+        }
+        mIconScaleForStash.animateToValue(
+                animateForward ? STASHED_TASKBAR_HINT_SCALE : 1)
+                .setDuration(TASKBAR_HINT_STASH_DURATION).start();
+    }
+
+    /**
+     * Creates and starts a partial unstash animation, hinting at the new state that will trigger
+     * when long press is detected.
+     * @param animateForward Whether we are going towards the new unstashed state or returning to
+     *                       the stashed state.
+     */
+    public void startUnstashHint(boolean animateForward) {
+        if (!isStashed()) {
+            // Already unstashed, no need to hint in that direction.
+            return;
+        }
+        mTaskbarStashedHandleHintScale.animateToValue(
+                animateForward ? UNSTASHED_TASKBAR_HANDLE_HINT_SCALE : 1)
+                .setDuration(TASKBAR_HINT_STASH_DURATION).start();
+    }
 }
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java
index 6d0e3c6..260cedc 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java
@@ -33,8 +33,4 @@
     }
 
     protected void updateContentInsets(Rect outContentInsets) { }
-
-    protected boolean onLongPressToUnstashTaskbar() {
-        return false;
-    }
 }
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java
index 820d40a..6f53f2b 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java
@@ -222,6 +222,15 @@
         return super.dispatchTouchEvent(ev);
     }
 
+    @Override
+    public boolean onTouchEvent(MotionEvent event) {
+        if (!mTouchEnabled) {
+            return true;
+        }
+        mControllerCallbacks.onTouchEvent(event);
+        return super.onTouchEvent(event);
+    }
+
     public void setTouchesEnabled(boolean touchEnabled) {
         this.mTouchEnabled = touchEnabled;
     }
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java
index 94c0ebe..6b95f08 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java
@@ -17,14 +17,17 @@
 
 import static com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY;
 import static com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_X;
+import static com.android.launcher3.Utilities.squaredHypot;
 import static com.android.launcher3.anim.Interpolators.LINEAR;
 import static com.android.quickstep.AnimatedFloat.VALUE;
 
 import android.graphics.Rect;
+import android.view.MotionEvent;
 import android.view.View;
 
 import com.android.launcher3.DeviceProfile;
 import com.android.launcher3.LauncherAppState;
+import com.android.launcher3.Utilities;
 import com.android.launcher3.anim.AnimatorPlaybackController;
 import com.android.launcher3.anim.PendingAnimation;
 import com.android.launcher3.model.data.ItemInfo;
@@ -188,6 +191,11 @@
      * Callbacks for {@link TaskbarView} to interact with its controller.
      */
     public class TaskbarViewCallbacks {
+        private final float mSquaredTouchSlop = Utilities.squaredTouchSlop(mActivity);
+
+        private float mDownX, mDownY;
+        private boolean mCanceledStashHint;
+
         public View.OnClickListener getIconOnClickListener() {
             return mActivity::onTaskbarIconClicked;
         }
@@ -199,5 +207,33 @@
         public View.OnLongClickListener getBackgroundOnLongClickListener() {
             return view -> mControllers.taskbarStashController.updateAndAnimateIsStashedInApp(true);
         }
+
+        public void onTouchEvent(MotionEvent motionEvent) {
+            final float x = motionEvent.getRawX();
+            final float y = motionEvent.getRawY();
+            switch (motionEvent.getAction()) {
+                case MotionEvent.ACTION_DOWN:
+                    mDownX = x;
+                    mDownY = y;
+                    mControllers.taskbarStashController.startStashHint(/* animateForward = */ true);
+                    mCanceledStashHint = false;
+                    break;
+                case MotionEvent.ACTION_MOVE:
+                    if (!mCanceledStashHint
+                            && squaredHypot(mDownX - x, mDownY - y) > mSquaredTouchSlop) {
+                        mControllers.taskbarStashController.startStashHint(
+                                /* animateForward= */ false);
+                        mCanceledStashHint = true;
+                    }
+                    break;
+                case MotionEvent.ACTION_UP:
+                case MotionEvent.ACTION_CANCEL:
+                    if (!mCanceledStashHint) {
+                        mControllers.taskbarStashController.startStashHint(
+                                /* animateForward= */ false);
+                    }
+                    break;
+            }
+        }
     }
 }
diff --git a/quickstep/src/com/android/quickstep/BaseActivityInterface.java b/quickstep/src/com/android/quickstep/BaseActivityInterface.java
index 1412b1a..615a510 100644
--- a/quickstep/src/com/android/quickstep/BaseActivityInterface.java
+++ b/quickstep/src/com/android/quickstep/BaseActivityInterface.java
@@ -267,20 +267,32 @@
         Gravity.apply(Gravity.CENTER, outWidth, outHeight, potentialTaskRect, outRect);
     }
 
-    private PointF getTaskDimension(Context context, DeviceProfile dp) {
+    private static PointF getTaskDimension(Context context, DeviceProfile dp) {
         PointF dimension = new PointF();
+        getTaskDimension(context, dp, dimension);
+        return dimension;
+    }
+
+    /**
+     * Gets the dimension of the task in the current system state.
+     */
+    public static void getTaskDimension(Context context, DeviceProfile dp, PointF out) {
         if (dp.isMultiWindowMode) {
             WindowBounds bounds = SplitScreenBounds.INSTANCE.getSecondaryWindowBounds(context);
-            dimension.x = bounds.availableSize.x;
-            dimension.y = bounds.availableSize.y;
+            if (TaskView.CLIP_STATUS_AND_NAV_BARS) {
+                out.x = bounds.availableSize.x;
+                out.y = bounds.availableSize.y;
+            } else {
+                out.x = bounds.availableSize.x + bounds.insets.left + bounds.insets.right;
+                out.y = bounds.availableSize.y + bounds.insets.top + bounds.insets.bottom;
+            }
         } else if (TaskView.CLIP_STATUS_AND_NAV_BARS) {
-            dimension.x = dp.availableWidthPx;
-            dimension.y = dp.availableHeightPx;
+            out.x = dp.availableWidthPx;
+            out.y = dp.availableHeightPx;
         } else {
-            dimension.x = dp.widthPx;
-            dimension.y = dp.heightPx;
+            out.x = dp.widthPx;
+            out.y = dp.heightPx;
         }
-        return dimension;
     }
 
     /**
@@ -364,14 +376,6 @@
     }
 
     /**
-     * Called when we detect a long press in the nav region before passing the gesture slop.
-     * @return Whether taskbar handled the long press, and thus should cancel the gesture.
-     */
-    public boolean onLongPressToUnstashTaskbar() {
-        return false;
-    }
-
-    /**
      * Returns the color of the scrim behind overview when at rest in this state.
      * Return {@link Color#TRANSPARENT} for no scrim.
      */
diff --git a/quickstep/src/com/android/quickstep/LauncherActivityInterface.java b/quickstep/src/com/android/quickstep/LauncherActivityInterface.java
index 94a47e6..5deb75e 100644
--- a/quickstep/src/com/android/quickstep/LauncherActivityInterface.java
+++ b/quickstep/src/com/android/quickstep/LauncherActivityInterface.java
@@ -318,15 +318,6 @@
     }
 
     @Override
-    public boolean onLongPressToUnstashTaskbar() {
-        LauncherTaskbarUIController taskbarController = getTaskbarController();
-        if (taskbarController == null) {
-            return super.onLongPressToUnstashTaskbar();
-        }
-        return taskbarController.onLongPressToUnstashTaskbar();
-    }
-
-    @Override
     protected int getOverviewScrimColorForState(BaseQuickstepLauncher launcher,
             LauncherState state) {
         return state.getWorkspaceScrimColor(launcher);
diff --git a/quickstep/src/com/android/quickstep/TouchInteractionService.java b/quickstep/src/com/android/quickstep/TouchInteractionService.java
index af1a01a..20d7eb1 100644
--- a/quickstep/src/com/android/quickstep/TouchInteractionService.java
+++ b/quickstep/src/com/android/quickstep/TouchInteractionService.java
@@ -680,7 +680,7 @@
             StatefulActivity activity = activityInterface.getCreatedActivity();
             if (activity != null && activity.getDeviceProfile().isTaskbarPresent) {
                 base = new TaskbarStashInputConsumer(this, base, mInputMonitorCompat,
-                        activityInterface);
+                        mTaskbarManager.getCurrentActivityContext());
             }
 
             if (FeatureFlags.ENABLE_QUICK_CAPTURE_GESTURE.get()) {
diff --git a/quickstep/src/com/android/quickstep/inputconsumers/TaskbarStashInputConsumer.java b/quickstep/src/com/android/quickstep/inputconsumers/TaskbarStashInputConsumer.java
index 83f689f..dbe260a 100644
--- a/quickstep/src/com/android/quickstep/inputconsumers/TaskbarStashInputConsumer.java
+++ b/quickstep/src/com/android/quickstep/inputconsumers/TaskbarStashInputConsumer.java
@@ -15,12 +15,15 @@
  */
 package com.android.quickstep.inputconsumers;
 
+import static com.android.launcher3.Utilities.squaredHypot;
+
 import android.content.Context;
 import android.view.GestureDetector;
 import android.view.GestureDetector.SimpleOnGestureListener;
 import android.view.MotionEvent;
 
-import com.android.quickstep.BaseActivityInterface;
+import com.android.launcher3.Utilities;
+import com.android.launcher3.taskbar.TaskbarActivityContext;
 import com.android.quickstep.InputConsumer;
 import com.android.systemui.shared.system.InputMonitorCompat;
 
@@ -29,13 +32,18 @@
  */
 public class TaskbarStashInputConsumer extends DelegateInputConsumer {
 
-    private final BaseActivityInterface mActivityInterface;
+    private final TaskbarActivityContext mTaskbarActivityContext;
     private final GestureDetector mLongPressDetector;
+    private final float mSquaredTouchSlop;
+
+    private float mDownX, mDownY;
+    private boolean mCanceledUnstashHint;
 
     public TaskbarStashInputConsumer(Context context, InputConsumer delegate,
-            InputMonitorCompat inputMonitor, BaseActivityInterface activityInterface) {
+            InputMonitorCompat inputMonitor, TaskbarActivityContext taskbarActivityContext) {
         super(delegate, inputMonitor);
-        mActivityInterface = activityInterface;
+        mTaskbarActivityContext = taskbarActivityContext;
+        mSquaredTouchSlop = Utilities.squaredTouchSlop(context);
 
         mLongPressDetector = new GestureDetector(context, new SimpleOnGestureListener() {
             @Override
@@ -55,11 +63,41 @@
         mLongPressDetector.onTouchEvent(ev);
         if (mState != STATE_ACTIVE) {
             mDelegate.onMotionEvent(ev);
+
+            if (mTaskbarActivityContext != null) {
+                final float x = ev.getRawX();
+                final float y = ev.getRawY();
+                switch (ev.getAction()) {
+                    case MotionEvent.ACTION_DOWN:
+                        mDownX = x;
+                        mDownY = y;
+                        mTaskbarActivityContext.startTaskbarUnstashHint(
+                                /* animateForward = */ true);
+                        mCanceledUnstashHint = false;
+                        break;
+                    case MotionEvent.ACTION_MOVE:
+                        if (!mCanceledUnstashHint
+                                && squaredHypot(mDownX - x, mDownY - y) > mSquaredTouchSlop) {
+                            mTaskbarActivityContext.startTaskbarUnstashHint(
+                                    /* animateForward = */ false);
+                            mCanceledUnstashHint = true;
+                        }
+                        break;
+                    case MotionEvent.ACTION_UP:
+                    case MotionEvent.ACTION_CANCEL:
+                        if (!mCanceledUnstashHint) {
+                            mTaskbarActivityContext.startTaskbarUnstashHint(
+                                    /* animateForward = */ false);
+                        }
+                        break;
+                }
+            }
         }
     }
 
     private void onLongPressDetected(MotionEvent motionEvent) {
-        if (mActivityInterface.onLongPressToUnstashTaskbar()) {
+        if (mTaskbarActivityContext != null
+                && mTaskbarActivityContext.onLongPressToUnstashTaskbar()) {
             setActive(motionEvent);
         }
     }
diff --git a/quickstep/src/com/android/quickstep/util/RecentsOrientedState.java b/quickstep/src/com/android/quickstep/util/RecentsOrientedState.java
index c515bdf..7cfd151 100644
--- a/quickstep/src/com/android/quickstep/util/RecentsOrientedState.java
+++ b/quickstep/src/com/android/quickstep/util/RecentsOrientedState.java
@@ -25,6 +25,7 @@
 import static com.android.launcher3.states.RotationHelper.ALLOW_ROTATION_PREFERENCE_KEY;
 import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR;
 import static com.android.launcher3.util.SettingsCache.ROTATION_SETTING_URI;
+import static com.android.quickstep.BaseActivityInterface.getTaskDimension;
 
 import static java.lang.annotation.RetentionPolicy.SOURCE;
 
@@ -49,7 +50,6 @@
 import com.android.launcher3.touch.PagedOrientationHandler;
 import com.android.launcher3.util.DisplayController;
 import com.android.launcher3.util.SettingsCache;
-import com.android.launcher3.util.WindowBounds;
 import com.android.quickstep.BaseActivityInterface;
 import com.android.quickstep.SystemUiProxy;
 import com.android.quickstep.views.TaskView;
@@ -401,12 +401,7 @@
             fullHeight -= insets.top + insets.bottom;
         }
 
-        if (dp.isMultiWindowMode) {
-            WindowBounds bounds = SplitScreenBounds.INSTANCE.getSecondaryWindowBounds(mContext);
-            outPivot.set(bounds.availableSize.x, bounds.availableSize.y);
-        } else {
-            outPivot.set(fullWidth, fullHeight);
-        }
+        getTaskDimension(mContext, dp, outPivot);
         float scale = Math.min(outPivot.x / taskView.width(), outPivot.y / taskView.height());
         // We also scale the preview as part of fullScreenParams, so account for that as well.
         if (fullWidth > 0) {
diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java
index 6844f9f..b8a38ad 100644
--- a/quickstep/src/com/android/quickstep/views/RecentsView.java
+++ b/quickstep/src/com/android/quickstep/views/RecentsView.java
@@ -1542,7 +1542,8 @@
      * and unloads the associated task data for tasks that are no longer visible.
      */
     public void loadVisibleTaskData(@TaskView.TaskDataChanges int dataChanges) {
-        if (!mOverviewStateEnabled || mTaskListChangeId == -1) {
+        boolean hasLeftOverview = !mOverviewStateEnabled && mScroller.isFinished();
+        if (hasLeftOverview || mTaskListChangeId == -1) {
             // Skip loading visible task data if we've already left the overview state, or if the
             // task list hasn't been loaded yet (the task views will not reflect the task list)
             return;
@@ -2599,6 +2600,7 @@
     }
 
     protected void onDismissAnimationEnds() {
+        AccessibilityManagerCompat.sendDismissAnimationEndsEventToTest(getContext());
     }
 
     public PendingAnimation createAllTasksDismissAnimation(long duration) {
diff --git a/src/com/android/launcher3/allapps/AllAppsStore.java b/src/com/android/launcher3/allapps/AllAppsStore.java
index 2443b83..7bc3eec 100644
--- a/src/com/android/launcher3/allapps/AllAppsStore.java
+++ b/src/com/android/launcher3/allapps/AllAppsStore.java
@@ -132,7 +132,7 @@
     }
 
     public void registerIconContainer(ViewGroup container) {
-        if (container != null) {
+        if (container != null && !mIconContainers.contains(container)) {
             mIconContainers.add(container);
         }
     }
diff --git a/src/com/android/launcher3/allapps/DiscoveryBounce.java b/src/com/android/launcher3/allapps/DiscoveryBounce.java
index d8ef18e..be261f7 100644
--- a/src/com/android/launcher3/allapps/DiscoveryBounce.java
+++ b/src/com/android/launcher3/allapps/DiscoveryBounce.java
@@ -20,16 +20,17 @@
 
 import android.animation.Animator;
 import android.animation.AnimatorInflater;
-import android.animation.AnimatorListenerAdapter;
 import android.os.Handler;
 import android.os.UserManager;
 import android.view.MotionEvent;
+import android.view.View;
 
 import com.android.launcher3.AbstractFloatingView;
 import com.android.launcher3.Launcher;
 import com.android.launcher3.LauncherState;
 import com.android.launcher3.R;
 import com.android.launcher3.Utilities;
+import com.android.launcher3.anim.AnimatorListeners;
 import com.android.launcher3.statemanager.StateManager.StateListener;
 import com.android.launcher3.util.OnboardingPrefs;
 
@@ -53,21 +54,15 @@
         public void onStateTransitionComplete(LauncherState finalState) {}
     };
 
-    public DiscoveryBounce(Launcher launcher, float delta) {
+    public DiscoveryBounce(Launcher launcher) {
         super(launcher, null);
         mLauncher = launcher;
-        AllAppsTransitionController controller = mLauncher.getAllAppsController();
 
         mDiscoBounceAnimation =
                 AnimatorInflater.loadAnimator(launcher, R.animator.discovery_bounce);
-        mDiscoBounceAnimation.setTarget(new VerticalProgressWrapper(controller, delta));
-        mDiscoBounceAnimation.addListener(new AnimatorListenerAdapter() {
-            @Override
-            public void onAnimationEnd(Animator animation) {
-                handleClose(false);
-            }
-        });
-        mDiscoBounceAnimation.addListener(controller.getProgressAnimatorListener());
+        mDiscoBounceAnimation.setTarget(new VerticalProgressWrapper(
+                launcher.getHotseat(), mLauncher.getDragLayer().getHeight()));
+        mDiscoBounceAnimation.addListener(AnimatorListeners.forEndCallback(this::handleClose));
         launcher.getStateManager().addStateListener(mStateListener);
     }
 
@@ -104,9 +99,9 @@
         if (mIsOpen) {
             mIsOpen = false;
             mLauncher.getDragLayer().removeView(this);
-            // Reset the all-apps progress to what ever it was previously.
-            mLauncher.getAllAppsController().setProgress(mLauncher.getStateManager()
-                    .getState().getVerticalProgress(mLauncher));
+            // Reset the translation to what ever it was previously.
+            mLauncher.getHotseat().setTranslationY(mLauncher.getStateManager().getState()
+                    .getHotseatScaleAndTranslation(mLauncher).translationY);
             mLauncher.getStateManager().removeStateListener(mStateListener);
         }
     }
@@ -141,29 +136,28 @@
             return;
         }
         onboardingPrefs.incrementEventCount(OnboardingPrefs.HOME_BOUNCE_COUNT);
-
-        new DiscoveryBounce(launcher, 0).show();
+        new DiscoveryBounce(launcher).show();
     }
 
     /**
-     * A wrapper around {@link AllAppsTransitionController} allowing a fixed shift in the value.
+     * A wrapper around hotseat animator allowing a fixed shift in the value.
      */
     public static class VerticalProgressWrapper {
 
-        private final float mDelta;
-        private final AllAppsTransitionController mController;
+        private final View mView;
+        private final float mLimit;
 
-        private VerticalProgressWrapper(AllAppsTransitionController controller, float delta) {
-            mController = controller;
-            mDelta = delta;
+        private VerticalProgressWrapper(View view, float limit) {
+            mView = view;
+            mLimit = limit;
         }
 
         public float getProgress() {
-            return mController.getProgress() + mDelta;
+            return 1 + mView.getTranslationY() / mLimit;
         }
 
         public void setProgress(float progress) {
-            mController.setProgress(progress - mDelta);
+            mView.setTranslationY(mLimit * (progress - 1));
         }
     }
 }
diff --git a/src/com/android/launcher3/compat/AccessibilityManagerCompat.java b/src/com/android/launcher3/compat/AccessibilityManagerCompat.java
index 92bc19a..97052b2 100644
--- a/src/com/android/launcher3/compat/AccessibilityManagerCompat.java
+++ b/src/com/android/launcher3/compat/AccessibilityManagerCompat.java
@@ -87,7 +87,14 @@
         if (accessibilityManager == null) return;
 
         sendEventToTest(accessibilityManager, context, TestProtocol.PAUSE_DETECTED_MESSAGE, null);
-        Log.d(TestProtocol.HOME_TO_OVERVIEW_FLAKY, "sendPauseDetectedEventToTest");
+    }
+
+    public static void sendDismissAnimationEndsEventToTest(Context context) {
+        final AccessibilityManager accessibilityManager = getAccessibilityManagerForTest(context);
+        if (accessibilityManager == null) return;
+
+        sendEventToTest(accessibilityManager, context, TestProtocol.DISMISS_ANIMATION_ENDS_MESSAGE,
+                null);
     }
 
     private static void sendEventToTest(
diff --git a/src/com/android/launcher3/graphics/LauncherPreviewRenderer.java b/src/com/android/launcher3/graphics/LauncherPreviewRenderer.java
index 1da8028..94778a2 100644
--- a/src/com/android/launcher3/graphics/LauncherPreviewRenderer.java
+++ b/src/com/android/launcher3/graphics/LauncherPreviewRenderer.java
@@ -15,6 +15,7 @@
  */
 package com.android.launcher3.graphics;
 
+import static android.app.WallpaperManager.FLAG_SYSTEM;
 import static android.view.View.MeasureSpec.EXACTLY;
 import static android.view.View.MeasureSpec.makeMeasureSpec;
 import static android.view.View.VISIBLE;
@@ -27,6 +28,7 @@
 import android.annotation.TargetApi;
 import android.app.Fragment;
 import android.app.WallpaperColors;
+import android.app.WallpaperManager;
 import android.appwidget.AppWidgetHost;
 import android.appwidget.AppWidgetHostView;
 import android.appwidget.AppWidgetProviderInfo;
@@ -214,7 +216,7 @@
 
     public LauncherPreviewRenderer(Context context,
             InvariantDeviceProfile idp,
-            WallpaperColors wallpaperColors) {
+            WallpaperColors wallpaperColorsOverride) {
 
         super(context);
         mUiHandler = new Handler(Looper.getMainLooper());
@@ -280,16 +282,18 @@
                 mDp.workspacePadding.bottom);
         mWorkspaceScreens.put(FIRST_SCREEN_ID, firstScreen);
 
-        if (FeatureFlags.WIDGETS_IN_LAUNCHER_PREVIEW.get()) {
-            mAppWidgetHost = new LauncherPreviewAppWidgetHost(context);
-            mWallpaperColorResources =  wallpaperColors != null
-                    ? LocalColorExtractor.newInstance(context)
-                            .generateColorsOverride(wallpaperColors)
-                    : null;
+        if (Utilities.ATLEAST_S) {
+            WallpaperColors wallpaperColors = wallpaperColorsOverride != null
+                    ? wallpaperColorsOverride
+                    : WallpaperManager.getInstance(context).getWallpaperColors(FLAG_SYSTEM);
+            mWallpaperColorResources = LocalColorExtractor.newInstance(context)
+                    .generateColorsOverride(wallpaperColors);
         } else {
-            mAppWidgetHost = null;
             mWallpaperColorResources = null;
         }
+        mAppWidgetHost = FeatureFlags.WIDGETS_IN_LAUNCHER_PREVIEW.get()
+                ? new LauncherPreviewAppWidgetHost(context)
+                : null;
     }
 
     /** Populate preview and render it. */
@@ -405,6 +409,10 @@
             view.updateAppWidget(null);
         }
 
+        if (mWallpaperColorResources != null) {
+            view.setColorResources(mWallpaperColorResources);
+        }
+
         view.setTag(info);
         addInScreenFromBind(view, info);
     }
@@ -537,12 +545,9 @@
         }
     }
 
-    private class LauncherPreviewAppWidgetHostView extends BaseLauncherAppWidgetHostView {
+    private static class LauncherPreviewAppWidgetHostView extends BaseLauncherAppWidgetHostView {
         private LauncherPreviewAppWidgetHostView(Context context) {
             super(context);
-            if (Utilities.ATLEAST_S && mWallpaperColorResources != null) {
-                setColorResources(mWallpaperColorResources);
-            }
         }
 
         @Override
diff --git a/src/com/android/launcher3/testing/TestProtocol.java b/src/com/android/launcher3/testing/TestProtocol.java
index a9d3998..65bec25 100644
--- a/src/com/android/launcher3/testing/TestProtocol.java
+++ b/src/com/android/launcher3/testing/TestProtocol.java
@@ -24,6 +24,7 @@
     public static final String SWITCHED_TO_STATE_MESSAGE = "TAPL_SWITCHED_TO_STATE";
     public static final String SCROLL_FINISHED_MESSAGE = "TAPL_SCROLL_FINISHED";
     public static final String PAUSE_DETECTED_MESSAGE = "TAPL_PAUSE_DETECTED";
+    public static final String DISMISS_ANIMATION_ENDS_MESSAGE = "TAPL_DISMISS_ANIMATION_ENDS";
     public static final int NORMAL_STATE_ORDINAL = 0;
     public static final int SPRING_LOADED_STATE_ORDINAL = 1;
     public static final int OVERVIEW_STATE_ORDINAL = 2;
@@ -111,5 +112,4 @@
     public static final String PERMANENT_DIAG_TAG = "TaplTarget";
     public static final String WORK_PROFILE_REMOVED = "b/159671700";
     public static final String FALLBACK_ACTIVITY_NO_SET = "b/181019015";
-    public static final String HOME_TO_OVERVIEW_FLAKY = "b/193440212";
 }
diff --git a/src/com/android/launcher3/views/FloatingIconView.java b/src/com/android/launcher3/views/FloatingIconView.java
index 3027db6..872adec 100644
--- a/src/com/android/launcher3/views/FloatingIconView.java
+++ b/src/com/android/launcher3/views/FloatingIconView.java
@@ -580,11 +580,6 @@
                     if (originalView instanceof IconLabelDotView) {
                         setIconAndDotVisible(originalView, true);
                     }
-                    if (originalView instanceof BubbleTextView) {
-                        BubbleTextView btv = (BubbleTextView) originalView;
-                        btv.setIconVisible(true);
-                        btv.setForceHideDot(true);
-                    }
                     view.finish(dragLayer);
                 }
             } else {
diff --git a/src/com/android/launcher3/widget/PendingAppWidgetHostView.java b/src/com/android/launcher3/widget/PendingAppWidgetHostView.java
index 47f30be..d3a0190 100644
--- a/src/com/android/launcher3/widget/PendingAppWidgetHostView.java
+++ b/src/com/android/launcher3/widget/PendingAppWidgetHostView.java
@@ -85,7 +85,6 @@
         setBackgroundResource(R.drawable.pending_widget_bg);
         setWillNotDraw(false);
 
-        setElevation(getResources().getDimension(R.dimen.pending_widget_elevation));
         updateAppWidget(null);
         setOnClickListener(ItemClickHandler.INSTANCE);
 
diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
index ef809d5..1e7f8a5 100644
--- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
+++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
@@ -207,6 +207,11 @@
     public LauncherInstrumentation(Instrumentation instrumentation) {
         mInstrumentation = instrumentation;
         mDevice = UiDevice.getInstance(instrumentation);
+        try {
+            mDevice.executeShellCommand("am wait-for-broadcast-idle");
+        } catch (IOException e) {
+            log("Failed to wait for broadcast idle");
+        }
 
         // Launcher should run in test harness so that custom accessibility protocol between
         // Launcher and TAPL is enabled. In-process tests enable this protocol with a direct call
diff --git a/tests/tapl/com/android/launcher3/tapl/OverviewTask.java b/tests/tapl/com/android/launcher3/tapl/OverviewTask.java
index 657b74d..71c0abb 100644
--- a/tests/tapl/com/android/launcher3/tapl/OverviewTask.java
+++ b/tests/tapl/com/android/launcher3/tapl/OverviewTask.java
@@ -59,9 +59,14 @@
             final Rect taskBounds = mLauncher.getVisibleBounds(mTask);
             final int centerX = taskBounds.centerX();
             final int centerY = taskBounds.centerY();
-            mLauncher.linearGesture(centerX, centerY, centerX, 0, 10, false,
-                    LauncherInstrumentation.GestureScope.INSIDE);
-            mLauncher.waitForIdle();
+            mLauncher.executeAndWaitForLauncherEvent(
+                    () -> mLauncher.linearGesture(centerX, centerY, centerX, 0, 10, false,
+                            LauncherInstrumentation.GestureScope.INSIDE),
+                    event -> TestProtocol.DISMISS_ANIMATION_ENDS_MESSAGE.equals(
+                            event.getClassName()),
+                    () -> "Didn't receive a dismiss animation ends message: " + centerX + ", "
+                            + centerY,
+                    "swiping to dismiss");
         }
     }