Merge "Import translations. DO NOT MERGE ANYWHERE" into sc-v2-dev
diff --git a/quickstep/src/com/android/launcher3/LauncherAnimationRunner.java b/quickstep/src/com/android/launcher3/LauncherAnimationRunner.java
index be98157..1090099 100644
--- a/quickstep/src/com/android/launcher3/LauncherAnimationRunner.java
+++ b/quickstep/src/com/android/launcher3/LauncherAnimationRunner.java
@@ -152,16 +152,18 @@
 
         @UiThread
         public void setAnimation(AnimatorSet animation, Context context) {
-            setAnimation(animation, context, null);
+            setAnimation(animation, context, null, true);
 
         }
 
         /**
          * Sets the animation to play for this app launch
+         * @param skipFirstFrame Iff true, we skip the first frame of the animation.
+         *                       We set to false when skipping first frame causes jank.
          */
         @UiThread
         public void setAnimation(AnimatorSet animation, Context context,
-                @Nullable Runnable onCompleteCallback) {
+                @Nullable Runnable onCompleteCallback, boolean skipFirstFrame) {
             if (mInitialized) {
                 throw new IllegalStateException("Animation already initialized");
             }
@@ -187,10 +189,12 @@
                 });
                 mAnimator.start();
 
-                // Because t=0 has the app icon in its original spot, we can skip the
-                // first frame and have the same movement one frame earlier.
-                mAnimator.setCurrentPlayTime(
-                        Math.min(getSingleFrameMs(context), mAnimator.getTotalDuration()));
+                if (skipFirstFrame) {
+                    // Because t=0 has the app icon in its original spot, we can skip the
+                    // first frame and have the same movement one frame earlier.
+                    mAnimator.setCurrentPlayTime(
+                            Math.min(getSingleFrameMs(context), mAnimator.getTotalDuration()));
+                }
             }
         }
     }
diff --git a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java
index 537add5..dccc9e1 100644
--- a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java
+++ b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java
@@ -38,6 +38,8 @@
 import static com.android.launcher3.config.FeatureFlags.SEPARATE_RECENTS_ACTIVITY;
 import static com.android.launcher3.dragndrop.DragLayer.ALPHA_INDEX_TRANSITIONS;
 import static com.android.launcher3.statehandlers.DepthController.DEPTH;
+import static com.android.launcher3.util.DisplayController.getSingleFrameMs;
+import static com.android.quickstep.TaskUtils.taskIsATargetWithMode;
 import static com.android.quickstep.TaskViewUtils.findTaskViewToLaunch;
 import static com.android.systemui.shared.system.QuickStepContract.getWindowCornerRadius;
 import static com.android.systemui.shared.system.QuickStepContract.supportsRoundedCornersOnWindows;
@@ -339,12 +341,17 @@
 
         final int rotationChange = getRotationChange(appTargets);
         // Note: the targetBounds are relative to the launcher
+        int startDelay = getSingleFrameMs(mLauncher);
         Rect windowTargetBounds = getWindowTargetBounds(appTargets, rotationChange);
-        anim.play(getOpeningWindowAnimators(v, appTargets, wallpaperTargets, nonAppTargets,
-                windowTargetBounds, areAllTargetsTranslucent(appTargets), rotationChange));
+        Animator windowAnimator = getOpeningWindowAnimators(v, appTargets, wallpaperTargets,
+                nonAppTargets, windowTargetBounds, areAllTargetsTranslucent(appTargets),
+                rotationChange);
+        windowAnimator.setStartDelay(startDelay);
+        anim.play(windowAnimator);
         if (launcherClosing) {
+            // Delay animation by a frame to avoid jank.
             Pair<AnimatorSet, Runnable> launcherContentAnimator =
-                    getLauncherContentAnimator(true /* isAppOpening */);
+                    getLauncherContentAnimator(true /* isAppOpening */, startDelay);
             anim.play(launcherContentAnimator.first);
             anim.addListener(new AnimatorListenerAdapter() {
                 @Override
@@ -435,8 +442,10 @@
      *
      * @param isAppOpening True when this is called when an app is opening.
      *                     False when this is called when an app is closing.
+     * @param startDelay Start delay duration.
      */
-    private Pair<AnimatorSet, Runnable> getLauncherContentAnimator(boolean isAppOpening) {
+    private Pair<AnimatorSet, Runnable> getLauncherContentAnimator(boolean isAppOpening,
+            int startDelay) {
         AnimatorSet launcherAnimator = new AnimatorSet();
         Runnable endListener;
 
@@ -527,6 +536,8 @@
                 mLauncher.getWorkspace().getPageIndicator().skipAnimationsToEnd();
             };
         }
+
+        launcherAnimator.setStartDelay(startDelay);
         return new Pair<>(launcherAnimator, endListener);
     }
 
@@ -632,7 +643,7 @@
                 ? 0 : getWindowCornerRadius(mLauncher.getResources());
         final float finalShadowRadius = appTargetsAreTranslucent ? 0 : mMaxShadowRadius;
 
-        appAnimator.addUpdateListener(new MultiValueUpdateListener() {
+        MultiValueUpdateListener listener = new MultiValueUpdateListener() {
             FloatProp mDx = new FloatProp(0, prop.dX, 0, prop.xDuration, AGGRESSIVE_EASE);
             FloatProp mDy = new FloatProp(0, prop.dY, 0, prop.yDuration, AGGRESSIVE_EASE);
 
@@ -661,7 +672,7 @@
                     ANIMATION_NAV_FADE_IN_DURATION, NAV_FADE_IN_INTERPOLATOR);
 
             @Override
-            public void onUpdate(float percent) {
+            public void onUpdate(float percent, boolean initOnly) {
                 // Calculate the size of the scaled icon.
                 float iconWidth = launcherIconBounds.width() * mIconScaleToFitScreen.value;
                 float iconHeight = launcherIconBounds.height() * mIconScaleToFitScreen.value;
@@ -706,6 +717,12 @@
                 floatingIconBounds.right += offsetX;
                 floatingIconBounds.bottom += offsetY;
 
+                if (initOnly) {
+                    floatingView.update(mIconAlpha.value, 255, floatingIconBounds, percent, 0f,
+                            mWindowRadius.value * scale, true /* isOpening */);
+                    return;
+                }
+
                 ArrayList<SurfaceParams> params = new ArrayList<>();
                 for (int i = appTargets.length - 1; i >= 0; i--) {
                     RemoteAnimationTargetCompat target = appTargets[i];
@@ -778,7 +795,10 @@
 
                 surfaceApplier.scheduleApply(params.toArray(new SurfaceParams[params.size()]));
             }
-        });
+        };
+        appAnimator.addUpdateListener(listener);
+        // Since we added a start delay, call update here to init the FloatingIconView properly.
+        listener.onUpdate(0, true /* initOnly */);
 
         animatorSet.playTogether(appAnimator, getBackgroundAnimator(appTargets));
         return animatorSet;
@@ -868,7 +888,7 @@
                     ANIMATION_NAV_FADE_IN_DURATION, NAV_FADE_IN_INTERPOLATOR);
 
             @Override
-            public void onUpdate(float percent) {
+            public void onUpdate(float percent, boolean initOnly) {
                 widgetBackgroundBounds.set(mDx.value - mWidth.value / 2f,
                         mDy.value - mHeight.value / 2f, mDx.value + mWidth.value / 2f,
                         mDy.value + mHeight.value / 2f);
@@ -1135,7 +1155,7 @@
                     DEACCEL_1_7);
 
             @Override
-            public void onUpdate(float percent) {
+            public void onUpdate(float percent, boolean initOnly) {
                 SurfaceParams[] params = new SurfaceParams[appTargets.length];
                 for (int i = appTargets.length - 1; i >= 0; i--) {
                     RemoteAnimationTargetCompat target = appTargets[i];
@@ -1285,8 +1305,7 @@
 
                     if (mLauncher.isInState(LauncherState.ALL_APPS)) {
                         Pair<AnimatorSet, Runnable> contentAnimator =
-                                getLauncherContentAnimator(false /* isAppOpening */);
-                        contentAnimator.first.setStartDelay(LAUNCHER_RESUME_START_DELAY);
+                                getLauncherContentAnimator(false, LAUNCHER_RESUME_START_DELAY);
                         anim.play(contentAnimator.first);
                         anim.addListener(new AnimatorListenerAdapter() {
                             @Override
@@ -1335,27 +1354,32 @@
 
             final boolean launchingFromWidget = mV instanceof LauncherAppWidgetHostView;
             final boolean launchingFromRecents = isLaunchingFromRecents(mV, appTargets);
+            final boolean skipFirstFrame;
             if (launchingFromWidget) {
                 composeWidgetLaunchAnimator(anim, (LauncherAppWidgetHostView) mV, appTargets,
                         wallpaperTargets, nonAppTargets);
                 addCujInstrumentation(
                         anim, InteractionJankMonitorWrapper.CUJ_APP_LAUNCH_FROM_WIDGET);
+                skipFirstFrame = true;
             } else if (launchingFromRecents) {
                 composeRecentsLaunchAnimator(anim, mV, appTargets, wallpaperTargets, nonAppTargets,
                         launcherClosing);
                 addCujInstrumentation(
                         anim, InteractionJankMonitorWrapper.CUJ_APP_LAUNCH_FROM_RECENTS);
+                skipFirstFrame = true;
             } else {
                 composeIconLaunchAnimator(anim, mV, appTargets, wallpaperTargets, nonAppTargets,
                         launcherClosing);
                 addCujInstrumentation(anim, InteractionJankMonitorWrapper.CUJ_APP_LAUNCH_FROM_ICON);
+                skipFirstFrame = false;
             }
 
             if (launcherClosing) {
                 anim.addListener(mForceInvisibleListener);
             }
 
-            result.setAnimation(anim, mLauncher, mOnEndCallback::executeAllAndDestroy);
+            result.setAnimation(anim, mLauncher, mOnEndCallback::executeAllAndDestroy,
+                    skipFirstFrame);
         }
     }
 
diff --git a/quickstep/src/com/android/launcher3/hybridhotseat/HotseatEduActivity.java b/quickstep/src/com/android/launcher3/hybridhotseat/HotseatEduActivity.java
index 3a1a2f7..3a7d821 100644
--- a/quickstep/src/com/android/launcher3/hybridhotseat/HotseatEduActivity.java
+++ b/quickstep/src/com/android/launcher3/hybridhotseat/HotseatEduActivity.java
@@ -21,6 +21,7 @@
 import android.os.Bundle;
 
 import com.android.launcher3.BaseActivity;
+import com.android.launcher3.Launcher;
 import com.android.launcher3.uioverrides.QuickstepLauncher;
 import com.android.launcher3.util.ActivityTracker;
 
@@ -37,7 +38,8 @@
                 .addCategory(Intent.CATEGORY_HOME)
                 .setPackage(getPackageName())
                 .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
-        new HotseatActivityTracker<>().addToIntent(homeIntent);
+
+        Launcher.ACTIVITY_TRACKER.registerCallback(new HotseatActivityTracker());
         startActivity(homeIntent);
         finish();
     }
diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
index 8f42993..a9dacee 100644
--- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
+++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
@@ -349,6 +349,13 @@
         }
 
         if (mActivity != null) {
+            if (mStateCallback.hasStates(STATE_GESTURE_COMPLETED)) {
+                // If the activity has restarted between setting the page scroll settling callback
+                // and actually receiving the callback, just mark the gesture completed
+                mGestureState.setState(STATE_RECENTS_SCROLLING_FINISHED);
+                return true;
+            }
+
             // The launcher may have been recreated as a result of device rotation.
             int oldState = mStateCallback.getState() & ~LAUNCHER_UI_STATES;
             initStateCallbacks();
@@ -1717,13 +1724,12 @@
 
     /**
      * Registers a callback to run when the activity is ready.
-     * @param intent The intent that will be used to start the activity if it doesn't exist already.
      */
-    public void initWhenReady(Intent intent) {
+    public void initWhenReady() {
         // Preload the plan
         RecentsModel.INSTANCE.get(mContext).getTasks(null);
 
-        mActivityInitListener.register(intent);
+        mActivityInitListener.register();
     }
 
     /**
diff --git a/quickstep/src/com/android/quickstep/LauncherSwipeHandlerV2.java b/quickstep/src/com/android/quickstep/LauncherSwipeHandlerV2.java
index 47d94ba..19cad53 100644
--- a/quickstep/src/com/android/quickstep/LauncherSwipeHandlerV2.java
+++ b/quickstep/src/com/android/quickstep/LauncherSwipeHandlerV2.java
@@ -191,6 +191,12 @@
         return new FloatingViewHomeAnimationFactory(floatingWidgetView) {
 
             @Override
+            @Nullable
+            protected View getViewIgnoredInWorkspaceRevealAnimation() {
+                return hostView;
+            }
+
+            @Override
             public RectF getWindowTargetRect() {
                 super.getWindowTargetRect();
                 return backgroundLocation;
@@ -387,6 +393,16 @@
     }
 
     private class LauncherHomeAnimationFactory extends HomeAnimationFactory {
+
+        /**
+         * Returns a view which should be excluded from the Workspace animation, or null if there
+         * is no view to exclude.
+         */
+        @Nullable
+        protected View getViewIgnoredInWorkspaceRevealAnimation() {
+            return null;
+        }
+
         @NonNull
         @Override
         public AnimatorPlaybackController createActivityAnimationToHome() {
@@ -400,7 +416,8 @@
         @Override
         public void playAtomicAnimation(float velocity) {
             if (!PROTOTYPE_APP_CLOSE.get()) {
-                new StaggeredWorkspaceAnim(mActivity, velocity, true /* animateOverviewScrim */)
+                new StaggeredWorkspaceAnim(mActivity, velocity, true /* animateOverviewScrim */,
+                        getViewIgnoredInWorkspaceRevealAnimation())
                         .start();
             } else if (shouldPlayAtomicWorkspaceReveal()) {
                 new WorkspaceRevealAnim(mActivity, true).start();
diff --git a/quickstep/src/com/android/quickstep/OverviewCommandHelper.java b/quickstep/src/com/android/quickstep/OverviewCommandHelper.java
index dbdd75f..2beef0a 100644
--- a/quickstep/src/com/android/quickstep/OverviewCommandHelper.java
+++ b/quickstep/src/com/android/quickstep/OverviewCommandHelper.java
@@ -184,9 +184,7 @@
                 .newHandler(gestureState, cmd.createTime);
         interactionHandler.setGestureEndCallback(
                 () -> onTransitionComplete(cmd, interactionHandler));
-
-        Intent intent = new Intent(interactionHandler.getLaunchIntent());
-        interactionHandler.initWhenReady(intent);
+        interactionHandler.initWhenReady();
 
         RecentsAnimationListener recentAnimListener = new RecentsAnimationListener() {
             @Override
@@ -212,6 +210,7 @@
             cmd.mActiveCallbacks.addListener(recentAnimListener);
             mTaskAnimationManager.notifyRecentsAnimationState(recentAnimListener);
         } else {
+            Intent intent = new Intent(interactionHandler.getLaunchIntent());
             intent.putExtra(INTENT_EXTRA_LOG_TRACE_ID, gestureState.getGestureId());
             cmd.mActiveCallbacks = mTaskAnimationManager.startRecentsAnimation(
                     gestureState, intent, interactionHandler);
diff --git a/quickstep/src/com/android/quickstep/RecentsActivity.java b/quickstep/src/com/android/quickstep/RecentsActivity.java
index 0e85ec3..3d66823 100644
--- a/quickstep/src/com/android/quickstep/RecentsActivity.java
+++ b/quickstep/src/com/android/quickstep/RecentsActivity.java
@@ -141,7 +141,7 @@
     @Override
     protected void onNewIntent(Intent intent) {
         super.onNewIntent(intent);
-        ACTIVITY_TRACKER.handleNewIntent(this, intent);
+        ACTIVITY_TRACKER.handleNewIntent(this);
     }
 
     /**
@@ -214,7 +214,8 @@
             AnimatorSet anim = composeRecentsLaunchAnimator(taskView, appTargets,
                     wallpaperTargets, nonAppTargets);
             anim.addListener(resetStateListener());
-            result.setAnimation(anim, RecentsActivity.this, onEndCallback::executeAllAndDestroy);
+            result.setAnimation(anim, RecentsActivity.this, onEndCallback::executeAllAndDestroy,
+                    true /* skipFirstFrame */);
         };
 
         final LauncherAnimationRunner wrapper = new WrappedLauncherAnimationRunner<>(
@@ -386,7 +387,8 @@
         anim.play(controller.getAnimationPlayer());
         anim.setDuration(HOME_APPEAR_DURATION);
         result.setAnimation(anim, this,
-                () -> getStateManager().goToState(RecentsState.HOME, false));
+                () -> getStateManager().goToState(RecentsState.HOME, false),
+                true /* skipFirstFrame */);
     }
 
     @Override
diff --git a/quickstep/src/com/android/quickstep/TaskViewUtils.java b/quickstep/src/com/android/quickstep/TaskViewUtils.java
index 59bd1ed..3293810 100644
--- a/quickstep/src/com/android/quickstep/TaskViewUtils.java
+++ b/quickstep/src/com/android/quickstep/TaskViewUtils.java
@@ -249,7 +249,7 @@
                             ANIMATION_NAV_FADE_IN_DURATION, NAV_FADE_IN_INTERPOLATOR);
 
                     @Override
-                    public void onUpdate(float percent) {
+                    public void onUpdate(float percent, boolean initOnly) {
                         final SurfaceParams.Builder navBuilder =
                                 new SurfaceParams.Builder(navBarTarget.leash);
                         if (mNavFadeIn.value > mNavFadeIn.getStartValue()) {
diff --git a/quickstep/src/com/android/quickstep/inputconsumers/OtherActivityInputConsumer.java b/quickstep/src/com/android/quickstep/inputconsumers/OtherActivityInputConsumer.java
index 9878d45..725c7c4 100644
--- a/quickstep/src/com/android/quickstep/inputconsumers/OtherActivityInputConsumer.java
+++ b/quickstep/src/com/android/quickstep/inputconsumers/OtherActivityInputConsumer.java
@@ -389,8 +389,7 @@
         mInteractionHandler = mHandlerFactory.newHandler(mGestureState, touchTimeMs);
         mInteractionHandler.setGestureEndCallback(this::onInteractionGestureFinished);
         mMotionPauseDetector.setOnMotionPauseListener(mInteractionHandler.getMotionPauseListener());
-        Intent intent = new Intent(mInteractionHandler.getLaunchIntent());
-        mInteractionHandler.initWhenReady(intent);
+        mInteractionHandler.initWhenReady();
 
         if (mTaskAnimationManager.isRecentsAnimationRunning()) {
             mActiveCallbacks = mTaskAnimationManager.continueRecentsAnimation(mGestureState);
@@ -398,6 +397,7 @@
             mTaskAnimationManager.notifyRecentsAnimationState(mInteractionHandler);
             notifyGestureStarted(true /*isLikelyToStartNewTask*/);
         } else {
+            Intent intent = new Intent(mInteractionHandler.getLaunchIntent());
             intent.putExtra(INTENT_EXTRA_LOG_TRACE_ID, mGestureState.getGestureId());
             mActiveCallbacks = mTaskAnimationManager.startRecentsAnimation(mGestureState, intent,
                     mInteractionHandler);
diff --git a/quickstep/src/com/android/quickstep/util/ActivityInitListener.java b/quickstep/src/com/android/quickstep/util/ActivityInitListener.java
index dfb8c1d..b9879ab 100644
--- a/quickstep/src/com/android/quickstep/util/ActivityInitListener.java
+++ b/quickstep/src/com/android/quickstep/util/ActivityInitListener.java
@@ -26,7 +26,8 @@
 
 import java.util.function.BiPredicate;
 
-public class ActivityInitListener<T extends BaseActivity> implements SchedulerCallback<T> {
+public class ActivityInitListener<T extends BaseActivity> implements
+        SchedulerCallback<T> {
 
     private BiPredicate<T, Boolean> mOnInitListener;
     private final ActivityTracker<T> mActivityTracker;
@@ -47,6 +48,7 @@
     @Override
     public final boolean init(T activity, boolean alreadyOnHome) {
         if (!mIsRegistered) {
+            // Don't receive any more updates
             return false;
         }
         return handleInit(activity, alreadyOnHome);
@@ -59,18 +61,17 @@
     /**
      * Registers the activity-created listener. If the activity is already created, then the
      * callback provided in the constructor will be called synchronously.
-     * @param intent The intent that will be used to initialize the activity, if the activity
-     *               doesn't already exist. We add the callback as an extra on this intent.
      */
-    public void register(Intent intent) {
+    public void register() {
         mIsRegistered = true;
-        mActivityTracker.runCallbackWhenActivityExists(this, intent);
+        mActivityTracker.registerCallback(this);
     }
 
     /**
      * After calling this, we won't {@link #init} even when the activity is ready.
      */
     public void unregister() {
+        mActivityTracker.unregisterCallback(this);
         mIsRegistered = false;
         mOnInitListener = null;
     }
@@ -82,9 +83,9 @@
      */
     public void registerAndStartActivity(Intent intent, RemoteAnimationProvider animProvider,
             Context context, Handler handler, long duration) {
-        mIsRegistered = true;
+        register();
 
         Bundle options = animProvider.toActivityOptions(handler, duration, context).toBundle();
-        context.startActivity(addToIntent(new Intent(intent)), options);
+        context.startActivity(new Intent(intent), options);
     }
 }
diff --git a/quickstep/src/com/android/quickstep/util/MultiValueUpdateListener.java b/quickstep/src/com/android/quickstep/util/MultiValueUpdateListener.java
index b4ae1ca..1c3c9c2 100644
--- a/quickstep/src/com/android/quickstep/util/MultiValueUpdateListener.java
+++ b/quickstep/src/com/android/quickstep/util/MultiValueUpdateListener.java
@@ -40,10 +40,14 @@
             newPercent = prop.mInterpolator.getInterpolation(newPercent);
             prop.value = prop.mEnd * newPercent + prop.mStart * (1 - newPercent);
         }
-        onUpdate(percent);
+        onUpdate(percent, false /* initOnly */);
     }
 
-    public abstract void onUpdate(float percent);
+    /**
+     * @param percent The total animation progress.
+     * @param initOnly When true, only does enough work to initialize the animation.
+     */
+    public abstract void onUpdate(float percent, boolean initOnly);
 
     public final class FloatProp {
 
diff --git a/quickstep/src/com/android/quickstep/util/RectFSpringAnim2.java b/quickstep/src/com/android/quickstep/util/RectFSpringAnim2.java
index 93b3482..c331a13 100644
--- a/quickstep/src/com/android/quickstep/util/RectFSpringAnim2.java
+++ b/quickstep/src/com/android/quickstep/util/RectFSpringAnim2.java
@@ -280,7 +280,7 @@
             }
 
             @Override
-            public void onUpdate(float percent) {}
+            public void onUpdate(float percent, boolean initOnly) {}
         };
     }
 
diff --git a/quickstep/src/com/android/quickstep/util/StaggeredWorkspaceAnim.java b/quickstep/src/com/android/quickstep/util/StaggeredWorkspaceAnim.java
index 49aec93..ccc587c 100644
--- a/quickstep/src/com/android/quickstep/util/StaggeredWorkspaceAnim.java
+++ b/quickstep/src/com/android/quickstep/util/StaggeredWorkspaceAnim.java
@@ -32,6 +32,8 @@
 import android.view.View;
 import android.view.ViewGroup;
 
+import androidx.annotation.Nullable;
+
 import com.android.launcher3.BaseQuickstepLauncher;
 import com.android.launcher3.CellLayout;
 import com.android.launcher3.DeviceProfile;
@@ -68,15 +70,18 @@
     private final float mSpringTransY;
 
     private final AnimatorSet mAnimators = new AnimatorSet();
+    private final @Nullable View mIgnoredView;
 
-    public StaggeredWorkspaceAnim(Launcher launcher, float velocity, boolean animateOverviewScrim) {
-        this(launcher, velocity, animateOverviewScrim, true);
+    public StaggeredWorkspaceAnim(Launcher launcher, float velocity, boolean animateOverviewScrim,
+            @Nullable View ignoredView) {
+        this(launcher, velocity, animateOverviewScrim, ignoredView, true);
     }
 
     public StaggeredWorkspaceAnim(Launcher launcher, float velocity, boolean animateOverviewScrim,
-            boolean staggerWorkspace) {
+            @Nullable View ignoredView, boolean staggerWorkspace) {
         prepareToAnimate(launcher, animateOverviewScrim);
 
+        mIgnoredView = ignoredView;
         mVelocity = velocity;
 
         // Scale the translationY based on the initial velocity to better sync the workspace items
@@ -224,6 +229,7 @@
      * @param totalRows Total number of rows.
      */
     private void addStaggeredAnimationForView(View v, int row, int totalRows) {
+        if (mIgnoredView != null && mIgnoredView == v) return;
         // Invert the rows, because we stagger starting from the bottom of the screen.
         int invertedRow = totalRows - row;
         // Add 1 to the inverted row so that the bottom most row has a start delay.
diff --git a/quickstep/src/com/android/quickstep/util/SwipePipToHomeAnimator.java b/quickstep/src/com/android/quickstep/util/SwipePipToHomeAnimator.java
index 1062652..61a2eaf 100644
--- a/quickstep/src/com/android/quickstep/util/SwipePipToHomeAnimator.java
+++ b/quickstep/src/com/android/quickstep/util/SwipePipToHomeAnimator.java
@@ -298,16 +298,16 @@
         final float degree, positionX, positionY;
         if (mFromRotation == Surface.ROTATION_90) {
             degree = -90 * fraction;
-            positionX = fraction * (mDestinationBoundsTransformed.left - mAppBounds.left)
-                    + mAppBounds.left;
-            positionY = fraction * (mDestinationBoundsTransformed.bottom - mAppBounds.top)
-                    + mAppBounds.top;
+            positionX = fraction * (mDestinationBoundsTransformed.left - mStartBounds.left)
+                    + mStartBounds.left;
+            positionY = fraction * (mDestinationBoundsTransformed.bottom - mStartBounds.top)
+                    + mStartBounds.top;
         } else {
             degree = 90 * fraction;
-            positionX = fraction * (mDestinationBoundsTransformed.right - mAppBounds.left)
-                    + mAppBounds.left;
-            positionY = fraction * (mDestinationBoundsTransformed.top - mAppBounds.top)
-                    + mAppBounds.top;
+            positionX = fraction * (mDestinationBoundsTransformed.right - mStartBounds.left)
+                    + mStartBounds.left;
+            positionY = fraction * (mDestinationBoundsTransformed.top - mStartBounds.top)
+                    + mStartBounds.top;
         }
         return new RotatedPosition(degree, positionX, positionY);
     }
diff --git a/quickstep/src/com/android/quickstep/views/AllAppsEduView.java b/quickstep/src/com/android/quickstep/views/AllAppsEduView.java
index 00993e3..f67940a 100644
--- a/quickstep/src/com/android/quickstep/views/AllAppsEduView.java
+++ b/quickstep/src/com/android/quickstep/views/AllAppsEduView.java
@@ -173,7 +173,7 @@
             FloatProp mGradientAlpha = new FloatProp(0, 255, firstPart, secondPart * 0.3f, LINEAR);
 
             @Override
-            public void onUpdate(float progress) {
+            public void onUpdate(float progress, boolean initOnly) {
                 temp.set(circleBoundsOg);
                 temp.offset(0, (int) -mDeltaY.value);
                 Utilities.scaleRectAboutCenter(temp, mCircleScale.value);
diff --git a/res/drawable/work_apps_toggle_background.xml b/res/drawable/work_apps_toggle_background.xml
index cb8b8e2..b7115f8 100644
--- a/res/drawable/work_apps_toggle_background.xml
+++ b/res/drawable/work_apps_toggle_background.xml
@@ -24,7 +24,7 @@
     <item>
         <shape android:shape="rectangle">
             <corners android:radius="@dimen/work_fab_radius" />
-            <solid android:color="@color/all_apps_tab_bg" />
+            <solid android:color="@color/all_apps_tab_background_selected" />
             <padding android:left="@dimen/work_fab_radius" android:right="@dimen/work_fab_radius" />
         </shape>
     </item>
diff --git a/res/layout/add_item_confirmation_activity.xml b/res/layout/add_item_confirmation_activity.xml
index 9439baf..1aeda50 100644
--- a/res/layout/add_item_confirmation_activity.xml
+++ b/res/layout/add_item_confirmation_activity.xml
@@ -26,79 +26,82 @@
     android:importantForAccessibility="no">
 
     <com.android.launcher3.widget.AddItemWidgetsBottomSheet
-        xmlns:android="http://schemas.android.com/apk/res/android"
         android:id="@+id/add_item_bottom_sheet"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
-        android:background="@drawable/add_item_dialog_background"
-        android:paddingTop="24dp"
         android:theme="?attr/widgetsTheme"
         android:layout_gravity="bottom"
         android:orientation="vertical">
 
-        <TextView
-            style="@style/TextHeadline"
-            android:id="@+id/widget_appName"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:gravity="center_horizontal"
-            android:paddingHorizontal="24dp"
-            android:textColor="?android:attr/textColorPrimary"
-            android:textSize="24sp"
-            android:ellipsize="end"
-            android:fadingEdge="horizontal"
-            android:singleLine="true"
-            android:maxLines="1" />
-
-        <TextView
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:gravity="center_horizontal"
-            android:paddingHorizontal="24dp"
-            android:paddingTop="8dp"
-            android:text="@string/add_item_request_drag_hint"
-            android:textSize="14sp"
-            android:textColor="?android:attr/textColorSecondary"
-            android:alpha="0.7"
-            android:importantForAccessibility="no"/>
-
-        <include layout="@layout/widget_cell"
-            android:id="@+id/widget_cell"
-            android:layout_width="match_parent"
-            android:layout_height="0dp"
-            android:layout_weight="1"
-            android:layout_marginVertical="16dp" />
-
         <LinearLayout
+            android:id="@+id/add_item_bottom_sheet_content"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
-            android:gravity="center_vertical|end"
-            android:paddingHorizontal="24dp"
-            android:paddingVertical="8dp"
-            android:orientation="horizontal">
-            <Button
-                style="@style/Button.FullRounded.Colored"
-                android:layout_width="wrap_content"
-                android:layout_height="36dp"
-                android:paddingHorizontal="16dp"
-                android:textSize="14sp"
-                android:textColor="@color/button_text"
-                android:text="@android:string/cancel"
-                android:onClick="onCancelClick"/>
+            android:padding="24dp"
+            android:background="@drawable/add_item_dialog_background"
+            android:orientation="vertical" >
 
-            <Space
-                android:layout_width="8dp"
-                android:layout_height="wrap_content" />
+            <TextView
+                style="@style/TextHeadline"
+                android:id="@+id/widget_appName"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:gravity="center_horizontal"
+                android:textColor="?android:attr/textColorPrimary"
+                android:textSize="24sp"
+                android:ellipsize="end"
+                android:fadingEdge="horizontal"
+                android:singleLine="true"
+                android:maxLines="1" />
 
-            <Button
-                style="@style/Button.FullRounded.Colored"
-                android:layout_width="wrap_content"
-                android:layout_height="36dp"
-                android:paddingHorizontal="16dp"
+            <TextView
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:gravity="center_horizontal"
+                android:paddingTop="8dp"
+                android:text="@string/add_item_request_drag_hint"
                 android:textSize="14sp"
-                android:textColor="@color/button_text"
-                android:text="@string/add_to_home_screen"
-                android:onClick="onPlaceAutomaticallyClick"/>
+                android:textColor="?android:attr/textColorSecondary"
+                android:alpha="0.7"
+                android:importantForAccessibility="no"/>
+
+            <include layout="@layout/widget_cell"
+                android:id="@+id/widget_cell"
+                android:layout_width="match_parent"
+                android:layout_height="0dp"
+                android:layout_weight="1"
+                android:layout_marginVertical="16dp" />
+
+            <LinearLayout
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:gravity="center_vertical|end"
+                android:paddingVertical="8dp"
+                android:orientation="horizontal">
+                <Button
+                    style="@style/Button.FullRounded.Colored"
+                    android:layout_width="wrap_content"
+                    android:layout_height="36dp"
+                    android:paddingHorizontal="16dp"
+                    android:textSize="14sp"
+                    android:textColor="@color/button_text"
+                    android:text="@android:string/cancel"
+                    android:onClick="onCancelClick"/>
+
+                <Space
+                    android:layout_width="8dp"
+                    android:layout_height="wrap_content" />
+
+                <Button
+                    style="@style/Button.FullRounded.Colored"
+                    android:layout_width="wrap_content"
+                    android:layout_height="36dp"
+                    android:paddingHorizontal="16dp"
+                    android:textSize="14sp"
+                    android:textColor="@color/button_text"
+                    android:text="@string/add_to_home_screen"
+                    android:onClick="onPlaceAutomaticallyClick"/>
+            </LinearLayout>
         </LinearLayout>
     </com.android.launcher3.widget.AddItemWidgetsBottomSheet>
 
diff --git a/res/layout/widgets_bottom_sheet.xml b/res/layout/widgets_bottom_sheet.xml
index 1859bd8..bbb08fa 100644
--- a/res/layout/widgets_bottom_sheet.xml
+++ b/res/layout/widgets_bottom_sheet.xml
@@ -19,8 +19,6 @@
     android:orientation="vertical"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
-    android:paddingTop="16dp"
-    android:background="@drawable/widgets_bottom_sheet_background"
     android:layout_gravity="bottom"
     android:theme="?attr/widgetsTheme">
 
diff --git a/res/layout/widgets_bottom_sheet_content.xml b/res/layout/widgets_bottom_sheet_content.xml
index 85c6488..3b3ff8b 100644
--- a/res/layout/widgets_bottom_sheet_content.xml
+++ b/res/layout/widgets_bottom_sheet_content.xml
@@ -14,32 +14,40 @@
      limitations under the License.
 -->
 <merge xmlns:android="http://schemas.android.com/apk/res/android">
-    <View
-        android:id="@+id/collapse_handle"
-        android:layout_width="48dp"
-        android:layout_height="2dp"
-        android:layout_gravity="center_horizontal"
-        android:layout_marginBottom="16dp"
-        android:visibility="gone"
-        android:background="?android:attr/textColorSecondary"/>
-    <TextView
-        style="@style/TextHeadline"
-        android:id="@+id/title"
+    <LinearLayout
+        android:id="@+id/widgets_bottom_sheet"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
-        android:gravity="center_horizontal"
-        android:textColor="?android:attr/textColorPrimary"
-        android:textSize="24sp"/>
-
-    <ScrollView
-        android:id="@+id/widgets_table_scroll_view"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:fadeScrollbars="false"
-        android:layout_marginVertical="16dp">
-        <include layout="@layout/widgets_table_container"
+        android:background="@drawable/widgets_bottom_sheet_background"
+        android:paddingTop="16dp"
+        android:orientation="vertical">
+        <View
+            android:id="@+id/collapse_handle"
+            android:layout_width="48dp"
+            android:layout_height="2dp"
+            android:layout_gravity="center_horizontal"
+            android:layout_marginBottom="16dp"
+            android:visibility="gone"
+            android:background="?android:attr/textColorSecondary"/>
+        <TextView
+            style="@style/TextHeadline"
+            android:id="@+id/title"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
-            android:layout_gravity="center_horizontal" />
-    </ScrollView>
+            android:gravity="center_horizontal"
+            android:textColor="?android:attr/textColorPrimary"
+            android:textSize="24sp"/>
+
+        <ScrollView
+            android:id="@+id/widgets_table_scroll_view"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:fadeScrollbars="false"
+            android:layout_marginVertical="16dp">
+            <include layout="@layout/widgets_table_container"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_gravity="center_horizontal" />
+        </ScrollView>
+    </LinearLayout>
 </merge>
diff --git a/res/values-night/styles.xml b/res/values-night/styles.xml
index 427525b..d41eb7e 100644
--- a/res/values-night/styles.xml
+++ b/res/values-night/styles.xml
@@ -20,5 +20,6 @@
 <resources>
     <style name="AddItemActivityTheme" parent="@android:style/Theme.Translucent.NoTitleBar">
         <item name="widgetsTheme">@style/WidgetContainerTheme.Dark</item>
+        <item name="android:windowTranslucentStatus">true</item>
     </style>
 </resources>
diff --git a/res/values-v31/colors.xml b/res/values-v31/colors.xml
index fb1e8ef..dc0c7a0 100644
--- a/res/values-v31/colors.xml
+++ b/res/values-v31/colors.xml
@@ -16,7 +16,7 @@
 ** limitations under the License.
 */
 -->
-<resources>
+<resources  xmlns:android="http://schemas.android.com/apk/res/android">
     <color name="popup_color_primary_light">@android:color/system_accent2_50</color>
     <color name="popup_color_secondary_light">@android:color/system_neutral2_100</color>
     <color name="popup_color_tertiary_light">@android:color/system_neutral2_300</color>
@@ -36,9 +36,12 @@
     <color name="text_color_tertiary_dark">@android:color/system_neutral2_400</color>
 
     <color name="wallpaper_popup_scrim">@android:color/system_neutral1_900</color>
-
+    <color name="folder_background_light" android:lstar="98">@android:color/system_neutral1_50</color>
+    <color name="folder_background_dark" android:lstar="30">@android:color/system_neutral2_800</color>
+  
     <color name="folder_dot_color">@android:color/system_accent2_50</color>
 
+
     <color name="home_settings_header_accent">@android:color/system_accent1_600</color>
     <color name="home_settings_header_collapsed">@android:color/system_neutral1_100</color>
     <color name="home_settings_header_expanded">@android:color/system_neutral1_50</color>
@@ -48,4 +51,5 @@
     <color name="home_settings_thumb_off_color">@android:color/system_neutral2_100</color>
     <color name="home_settings_track_on_color">@android:color/system_accent1_600</color>
     <color name="home_settings_track_off_color">@android:color/system_neutral2_600</color>
+
 </resources>
diff --git a/res/values/colors.xml b/res/values/colors.xml
index 7aab4fa..dac12ed 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -59,6 +59,9 @@
     <color name="folder_hint_text_color_light">#FFF</color>
     <color name="folder_hint_text_color_dark">#FF000000</color>
 
+    <color name="folder_background_light">#FFFFFF</color>
+    <color name="folder_background_dark">#FF3C4043</color>
+
     <color name="folder_dot_color">?attr/colorPrimary</color>
 
     <color name="text_color_primary_dark">#FFFFFFFF</color>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index d341fb7..38bc272 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -48,9 +48,9 @@
         <item name="workspaceStatusBarScrim">@drawable/workspace_bg</item>
         <item name="widgetsTheme">@style/WidgetContainerTheme</item>
         <item name="folderDotColor">@color/folder_dot_color</item>
-        <item name="folderFillColor">?android:attr/colorBackgroundFloating</item>
+        <item name="folderFillColor">@color/folder_background_light</item>
         <item name="folderIconBorderColor">?android:attr/colorPrimary</item>
-        <item name="folderTextColor">?android:attr/textColorPrimary</item>
+        <item name="folderTextColor">@color/workspace_text_color_dark</item>
         <item name="isFolderDarkText">true</item>
         <item name="folderHintColor">@color/folder_hint_text_color_dark</item>
         <item name="loadingIconColor">#CCFFFFFF</item>
@@ -71,10 +71,10 @@
     </style>
 
     <style name="LauncherTheme.DarkMainColor" parent="@style/LauncherTheme">
-        <item name="folderFillColor">?android:attr/colorBackgroundFloating</item>
-        <item name="folderTextColor">?attr/workspaceTextColor</item>
-        <item name="isFolderDarkText">?attr/isWorkspaceDarkText</item>
-        <item name="folderHintColor">@color/folder_hint_text_color_dark</item>
+        <item name="folderFillColor">@color/folder_background_dark</item>
+        <item name="folderTextColor">@color/workspace_text_color_light</item>
+        <item name="isFolderDarkText">false</item>
+        <item name="folderHintColor">@color/folder_hint_text_color_light</item>
         <item name="disabledIconAlpha">.254</item>
 
     </style>
@@ -87,9 +87,9 @@
         <item name="isWorkspaceDarkText">true</item>
         <item name="workspaceStatusBarScrim">@null</item>
         <item name="folderDotColor">@color/folder_dot_color</item>
-        <item name="folderFillColor">?android:attr/colorBackgroundFloating</item>
+        <item name="folderFillColor">@color/folder_background_light</item>
         <item name="folderIconBorderColor">#FF80868B</item>
-        <item name="folderTextColor">?attr/workspaceTextColor</item>
+        <item name="folderTextColor">@color/workspace_text_color_dark</item>
         <item name="isFolderDarkText">true</item>
         <item name="folderHintColor">@color/folder_hint_text_color_dark</item>
     </style>
@@ -109,9 +109,9 @@
         <item name="popupColorTertiary">@color/popup_color_tertiary_dark</item>
         <item name="widgetsTheme">@style/WidgetContainerTheme.Dark</item>
         <item name="folderDotColor">@color/folder_dot_color</item>
-        <item name="folderFillColor">?android:attr/colorBackgroundFloating</item>
+        <item name="folderFillColor">@color/folder_background_dark</item>
         <item name="folderIconBorderColor">?android:attr/colorPrimary</item>
-        <item name="folderTextColor">?android:attr/textColorPrimary</item>
+        <item name="folderTextColor">@color/workspace_text_color_light</item>
         <item name="isFolderDarkText">false</item>
         <item name="folderHintColor">@color/folder_hint_text_color_light</item>
         <item name="isMainColorDark">true</item>
@@ -123,8 +123,8 @@
     </style>
 
     <style name="LauncherTheme.Dark.DarkMainColor" parent="@style/LauncherTheme.Dark">
-        <item name="folderFillColor">?android:attr/colorBackgroundFloating</item>
-        <item name="folderTextColor">@android:color/white</item>
+        <item name="folderFillColor">@color/folder_background_dark</item>
+        <item name="folderTextColor">@color/workspace_text_color_light</item>
         <item name="isFolderDarkText">false</item>
         <item name="folderHintColor">@color/folder_hint_text_color_light</item>
         <item name="disabledIconAlpha">.54</item>
@@ -132,16 +132,16 @@
 
     <style name="LauncherTheme.Dark.DarkText" parent="@style/LauncherTheme.Dark">
         <item name="android:colorControlHighlight">#19212121</item>
-        <item name="folderFillColor">?android:attr/colorBackgroundFloating</item>
-        <item name="folderTextColor">?attr/workspaceTextColor</item>
-        <item name="isFolderDarkText">?attr/isWorkspaceDarkText</item>
-        <item name="folderHintColor">@color/folder_hint_text_color_dark</item>
+        <item name="folderFillColor">@color/folder_background_light</item>
         <item name="workspaceTextColor">@color/workspace_text_color_dark</item>
         <item name="workspaceShadowColor">@android:color/transparent</item>
         <item name="workspaceAmbientShadowColor">@android:color/transparent</item>
         <item name="workspaceKeyShadowColor">@android:color/transparent</item>
         <item name="isWorkspaceDarkText">true</item>
         <item name="workspaceStatusBarScrim">@null</item>
+        <item name="folderTextColor">@color/workspace_text_color_dark</item>
+        <item name="isFolderDarkText">true</item>
+        <item name="folderHintColor">@color/folder_hint_text_color_dark</item>
     </style>
 
     <!-- A derivative project can extend these themes to customize the application theme without
@@ -316,5 +316,6 @@
     <style name="AddItemActivityTheme" parent="@android:style/Theme.Translucent.NoTitleBar">
         <item name="widgetsTheme">@style/WidgetContainerTheme</item>
         <item name="android:windowLightStatusBar">true</item>
+        <item name="android:windowTranslucentStatus">true</item>
     </style>
 </resources>
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index a0d15da..5a9257d 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -1079,7 +1079,13 @@
                 // Making sure mAllAppsSessionLogId is not null to avoid double logging.
                 && mAllAppsSessionLogId != null) {
             getAppsView().getSearchUiManager().resetSearch();
-            getStatsLogManager().logger().log(LAUNCHER_ALLAPPS_EXIT);
+            getStatsLogManager().logger()
+                    .withContainerInfo(LauncherAtom.ContainerInfo.newBuilder()
+                            .setWorkspace(
+                                    LauncherAtom.WorkspaceContainer.newBuilder()
+                                            .setPageIndex(getWorkspace().getCurrentPage()))
+                            .build())
+                    .log(LAUNCHER_ALLAPPS_EXIT);
             mAllAppsSessionLogId = null;
         }
     }
@@ -1473,7 +1479,7 @@
         boolean shouldMoveToDefaultScreen = alreadyOnHome && isInState(NORMAL)
                 && AbstractFloatingView.getTopOpenView(this) == null;
         boolean isActionMain = Intent.ACTION_MAIN.equals(intent.getAction());
-        boolean internalStateHandled = ACTIVITY_TRACKER.handleNewIntent(this, intent);
+        boolean internalStateHandled = ACTIVITY_TRACKER.handleNewIntent(this);
         hideKeyboard();
         if (isActionMain) {
             if (!internalStateHandled) {
diff --git a/src/com/android/launcher3/config/FeatureFlags.java b/src/com/android/launcher3/config/FeatureFlags.java
index e911b8f..5e3177a 100644
--- a/src/com/android/launcher3/config/FeatureFlags.java
+++ b/src/com/android/launcher3/config/FeatureFlags.java
@@ -240,6 +240,10 @@
             "ENABLE_WALLPAPER_SCRIM", false,
             "Enables scrim over wallpaper for text protection.");
 
+    public static final BooleanFlag WIDGETS_IN_LAUNCHER_PREVIEW = getDebugFlag(
+            "WIDGETS_IN_LAUNCHER_PREVIEW", false,
+            "Enables widgets in Launcher preview for the Wallpaper app.");
+
     public static void initialize(Context context) {
         synchronized (sDebugFlags) {
             for (DebugFlag flag : sDebugFlags) {
diff --git a/src/com/android/launcher3/dragndrop/AddItemActivity.java b/src/com/android/launcher3/dragndrop/AddItemActivity.java
index b4288ce..1503167 100644
--- a/src/com/android/launcher3/dragndrop/AddItemActivity.java
+++ b/src/com/android/launcher3/dragndrop/AddItemActivity.java
@@ -125,7 +125,6 @@
                 WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
         mDragLayer = findViewById(R.id.add_item_drag_layer);
         mDragLayer.recreateControllers();
-        mDragLayer.setInsets(mDeviceProfile.getInsets());
         mWidgetCell = findViewById(R.id.widget_cell);
 
         if (mRequest.getRequestType() == PinItemRequest.REQUEST_TYPE_SHORTCUT) {
@@ -213,7 +212,7 @@
                         .addCategory(Intent.CATEGORY_HOME)
                         .setPackage(getPackageName())
                         .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
-        Launcher.ACTIVITY_TRACKER.runCallbackWhenActivityExists(listener, homeIntent);
+        Launcher.ACTIVITY_TRACKER.registerCallback(listener);
         startActivity(homeIntent,
                 ActivityOptions.makeCustomAnimation(this, 0, android.R.anim.fade_out)
                         .toBundle());
@@ -322,7 +321,7 @@
     @Override
     public void onBackPressed() {
         logCommand(LAUNCHER_ADD_EXTERNAL_ITEM_BACK);
-        super.onBackPressed();
+        mSlideInView.close(/* animate= */ true);
     }
 
     @Override
diff --git a/src/com/android/launcher3/folder/Folder.java b/src/com/android/launcher3/folder/Folder.java
index dc188f2..5dcd75a 100644
--- a/src/com/android/launcher3/folder/Folder.java
+++ b/src/com/android/launcher3/folder/Folder.java
@@ -30,17 +30,13 @@
 import android.animation.Animator;
 import android.animation.AnimatorListenerAdapter;
 import android.animation.AnimatorSet;
-import android.animation.ObjectAnimator;
 import android.annotation.SuppressLint;
-import android.annotation.TargetApi;
 import android.appwidget.AppWidgetHostView;
 import android.content.Context;
-import android.content.res.ColorStateList;
 import android.graphics.Canvas;
 import android.graphics.Insets;
 import android.graphics.Path;
 import android.graphics.Rect;
-import android.graphics.RectF;
 import android.graphics.drawable.Drawable;
 import android.graphics.drawable.GradientDrawable;
 import android.os.Build;
@@ -50,7 +46,6 @@
 import android.util.AttributeSet;
 import android.util.Log;
 import android.util.Pair;
-import android.util.SparseIntArray;
 import android.util.TypedValue;
 import android.view.FocusFinder;
 import android.view.KeyEvent;
@@ -69,7 +64,6 @@
 import androidx.annotation.Nullable;
 import androidx.annotation.RequiresApi;
 import androidx.core.content.res.ResourcesCompat;
-import androidx.core.graphics.ColorUtils;
 
 import com.android.launcher3.AbstractFloatingView;
 import com.android.launcher3.Alarm;
@@ -104,12 +98,10 @@
 import com.android.launcher3.model.data.WorkspaceItemInfo;
 import com.android.launcher3.pageindicators.PageIndicatorDots;
 import com.android.launcher3.util.Executors;
-import com.android.launcher3.util.Themes;
 import com.android.launcher3.util.Thunk;
 import com.android.launcher3.views.ActivityContext;
 import com.android.launcher3.views.BaseDragLayer;
 import com.android.launcher3.views.ClipPathView;
-import com.android.launcher3.widget.LocalColorExtractor;
 import com.android.launcher3.widget.PendingAddShortcutInfo;
 
 import java.util.ArrayList;
@@ -169,11 +161,6 @@
     private static final Rect sTempRect = new Rect();
     private static final int MIN_FOLDERS_FOR_HARDWARE_OPTIMIZATION = 10;
 
-    // Index used to get background color when using local wallpaper color extraction,
-    private static final int DARK_COLOR_EXTRACTION_INDEX = android.R.color.system_neutral1_900;
-    private static final int LIGHT_COLOR_EXTRACTION_INDEX = android.R.color.system_neutral2_500;
-    private static final int LIGHT_COLOR_L_STAR = 98;
-
     private final Alarm mReorderAlarm = new Alarm();
     private final Alarm mOnExitAlarm = new Alarm();
     private final Alarm mOnScrollHintAlarm = new Alarm();
@@ -241,17 +228,6 @@
 
     @Nullable private FolderWindowInsetsAnimationCallback mFolderWindowInsetsAnimationCallback;
 
-    // Wallpaper local color extraction
-    @Nullable private LocalColorExtractor mColorExtractor;
-    @Nullable private LocalColorExtractor.Listener mColorListener;
-
-    // For simplicity, we start the color change only after the open animation has started.
-    private Runnable mColorChangeRunnable;
-    private Animator mColorChangeAnimator;
-    // The background color animator used in the folder open animation. We keep a reference to this,
-    // so that we can cancel it when starting mColorChangeAnimator.
-    private ObjectAnimator mOpenAnimationColorChangeAnimator;
-
     private GradientDrawable mBackground;
 
     /**
@@ -315,64 +291,6 @@
 
             setWindowInsetsAnimationCallback(mFolderWindowInsetsAnimationCallback);
         }
-
-        if (Utilities.ATLEAST_S) {
-            boolean isFolderDarkText = Themes.getAttrBoolean(getContext(), R.attr.isFolderDarkText);
-            mColorExtractor = LocalColorExtractor.newInstance(getContext());
-            mColorListener = (RectF rect, SparseIntArray extractedColors) -> {
-                mColorChangeRunnable = () -> {
-                    mColorChangeRunnable = null;
-                    int duration = FOLDER_COLOR_ANIMATION_DURATION;
-
-                    // Cancel the open animation color change animator.
-                    ObjectAnimator existingAnim = mOpenAnimationColorChangeAnimator;
-                    if (existingAnim != null && existingAnim.isRunning()) {
-                        duration = (int) Math.max(FOLDER_COLOR_ANIMATION_DURATION,
-                                existingAnim.getDuration() * (1f - existingAnim.getDuration()));
-                        existingAnim.cancel();
-                        mOpenAnimationColorChangeAnimator = null;
-                    }
-
-                    // Start a new animator to the extracted color. Clamp down on the alpha
-                    // to prevent folder from being transparent for too long.
-                    GradientDrawable bg = (GradientDrawable) getBackground();
-                    int currentColor = ColorUtils.setAlphaComponent(bg.getColor().getDefaultColor(),
-                            255);
-                    int newColor = getExtractedColor(extractedColors, isFolderDarkText);
-                    mColorChangeAnimator = ObjectAnimator.ofArgb(bg, "color", currentColor,
-                            newColor).setDuration(duration);
-                    mColorChangeAnimator.addListener(new AnimatorListenerAdapter() {
-                        @Override
-                        public void onAnimationEnd(Animator animation) {
-                            mColorChangeAnimator = null;
-                        }
-                    });
-                    mColorChangeAnimator.start();
-                };
-
-                // If the folder open animation has started, we can start the color change now.
-                // Otherwise we wait for it to start.
-                if (mOpenAnimationColorChangeAnimator != null
-                        && mOpenAnimationColorChangeAnimator.isStarted()) {
-                    post(mColorChangeRunnable);
-                }
-            };
-        }
-    }
-
-    /**
-     * Returns an index used to query the color of interest from the list of extracted colors.
-     * @param hasDarkText True when dark index is wanted, False when light index is wanted.
-     */
-    @TargetApi(Build.VERSION_CODES.S)
-    private int getExtractedColor(SparseIntArray colors, boolean hasDarkText) {
-        int color = colors.get(hasDarkText
-                ? LIGHT_COLOR_EXTRACTION_INDEX
-                : DARK_COLOR_EXTRACTION_INDEX);
-        if (hasDarkText) {
-            color = ColorStateList.valueOf(color).withLStar(LIGHT_COLOR_L_STAR).getDefaultColor();
-        }
-        return color;
     }
 
     public boolean onLongClick(View v) {
@@ -753,15 +671,11 @@
         cancelRunningAnimations();
         FolderAnimationManager fam = new FolderAnimationManager(this, true /* isOpening */);
         AnimatorSet anim = fam.getAnimator();
-        mOpenAnimationColorChangeAnimator = fam.getBgColorAnimator();
         anim.addListener(new AnimatorListenerAdapter() {
             @Override
             public void onAnimationStart(Animator animation) {
                 mFolderIcon.setIconVisible(false);
                 mFolderIcon.drawLeaveBehindIfExists();
-                if (mColorChangeRunnable != null) {
-                    mColorChangeRunnable.run();
-                }
             }
             @Override
             public void onAnimationEnd(Animator animation) {
@@ -857,9 +771,6 @@
         if (mCurrentAnimator != null && mCurrentAnimator.isRunning()) {
             mCurrentAnimator.cancel();
         }
-        if (mColorChangeAnimator != null && mColorChangeAnimator.isRunning()) {
-            mColorChangeAnimator.cancel();
-        }
     }
 
     private void animateClosed() {
@@ -945,19 +856,6 @@
         clearDragInfo();
         mState = STATE_SMALL;
         mContent.setCurrentPage(0);
-
-        mOpenAnimationColorChangeAnimator = null;
-        mColorChangeRunnable = null;
-        if (mColorChangeAnimator != null) {
-            mColorChangeAnimator.cancel();
-            mColorChangeAnimator = null;
-        }
-        if (mColorExtractor != null) {
-            mColorExtractor.removeLocations();
-            mColorExtractor.setListener(null);
-        }
-        GradientDrawable bg = (GradientDrawable) getBackground();
-        bg.setColor(Themes.getAttrColor(getContext(), R.attr.folderFillColor));
     }
 
     @Override
@@ -1227,12 +1125,6 @@
         lp.y = top;
 
         mBackground.setBounds(0, 0, width, height);
-
-        if (mColorExtractor != null) {
-            mColorExtractor.removeLocations();
-            mColorExtractor.setListener(mColorListener);
-            mLauncherDelegate.addRectForColorExtraction(lp, mColorExtractor);
-        }
     }
 
     protected int getContentAreaHeight() {
diff --git a/src/com/android/launcher3/folder/FolderAnimationManager.java b/src/com/android/launcher3/folder/FolderAnimationManager.java
index e66e2f6..57b289e 100644
--- a/src/com/android/launcher3/folder/FolderAnimationManager.java
+++ b/src/com/android/launcher3/folder/FolderAnimationManager.java
@@ -239,13 +239,13 @@
                 mFolder, startRect, endRect, finalRadius, !mIsOpening));
 
         // Create reveal animator for the folder content (capture the top 4 icons 2x2)
-        int width = mContent.getPaddingLeft() + mDeviceProfile.folderCellLayoutBorderSpacingPx
+        int width = mDeviceProfile.folderCellLayoutBorderSpacingPx
                 + mDeviceProfile.folderCellWidthPx * 2;
-        int height = mContent.getPaddingTop() + mDeviceProfile.folderCellLayoutBorderSpacingPx
+        int height = mDeviceProfile.folderCellLayoutBorderSpacingPx
                 + mDeviceProfile.folderCellHeightPx * 2;
         int page = mIsOpening ? mContent.getCurrentPage() : mContent.getDestinationPage();
-        int left = mContent.getPaddingLeft() + page * mContent.getWidth();
-        Rect contentStart = new Rect(left, 0, left + width, height);
+        int left = mContent.getPaddingLeft() + page * lp.width;
+        Rect contentStart = new Rect(0, 0, width, height);
         Rect contentEnd = new Rect(endRect.left + left, endRect.top, endRect.right + left,
                 endRect.bottom);
         play(a, getShape().createRevealAnimator(
diff --git a/src/com/android/launcher3/states/RotationHelper.java b/src/com/android/launcher3/states/RotationHelper.java
index 5832711..87871b1 100644
--- a/src/com/android/launcher3/states/RotationHelper.java
+++ b/src/com/android/launcher3/states/RotationHelper.java
@@ -25,6 +25,7 @@
 import com.android.launcher3.BaseActivity;
 import com.android.launcher3.DeviceProfile;
 import com.android.launcher3.Utilities;
+import com.android.launcher3.util.ActivityTracker;
 import com.android.launcher3.util.UiThreadHelper;
 
 /**
@@ -50,7 +51,7 @@
 
     /**
      * Rotation request made by
-     * {@link com.android.launcher3.util.ActivityTracker.SchedulerCallback}.
+     * {@link ActivityTracker.SchedulerCallback}.
      * This supersedes any other request.
      */
     private int mStateHandlerRequest = REQUEST_NONE;
diff --git a/src/com/android/launcher3/util/ActivityTracker.java b/src/com/android/launcher3/util/ActivityTracker.java
index b5b9c2f..7af1a13 100644
--- a/src/com/android/launcher3/util/ActivityTracker.java
+++ b/src/com/android/launcher3/util/ActivityTracker.java
@@ -15,15 +15,14 @@
  */
 package com.android.launcher3.util;
 
-import android.content.Intent;
-import android.os.Bundle;
-import android.os.IBinder;
-
 import androidx.annotation.Nullable;
 
 import com.android.launcher3.BaseActivity;
 
 import java.lang.ref.WeakReference;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.concurrent.CopyOnWriteArrayList;
 
 /**
  * Helper class to statically track activity creation
@@ -32,8 +31,7 @@
 public final class ActivityTracker<T extends BaseActivity> {
 
     private WeakReference<T> mCurrentActivity = new WeakReference<>(null);
-
-    private static final String EXTRA_SCHEDULER_CALLBACK = "launcher.scheduler_callback";
+    private CopyOnWriteArrayList<SchedulerCallback<T>> mCallbacks = new CopyOnWriteArrayList<>();
 
     @Nullable
     public <R extends T> R getCreatedActivity() {
@@ -47,43 +45,50 @@
     }
 
     /**
-     * Call {@link SchedulerCallback#init(BaseActivity, boolean)} when the activity is ready.
-     * If the activity is already created, this is called immediately, otherwise we add the
-     * callback as an extra on the intent, and will call init() when we get handleIntent().
+     * Call {@link SchedulerCallback#init(BaseActivity, boolean)} when the
+     * activity is ready. If the activity is already created, this is called immediately.
+     *
+     * The tracker maintains a strong ref to the callback, so it is up to the caller to return
+     * {@code false} in the callback OR to unregister the callback explicitly.
+     *
      * @param callback The callback to call init() on when the activity is ready.
-     * @param intent The intent that will be used to initialize the activity, if the activity
-     *               doesn't already exist. We add the callback as an extra on this intent.
      */
-    public void runCallbackWhenActivityExists(SchedulerCallback<T> callback, Intent intent) {
+    public void registerCallback(SchedulerCallback<T> callback) {
         T activity = mCurrentActivity.get();
+        mCallbacks.add(callback);
         if (activity != null) {
-            callback.init(activity, activity.isStarted());
-        } else {
-            callback.addToIntent(intent);
+            if (!callback.init(activity, activity.isStarted())) {
+                unregisterCallback(callback);
+            }
         }
     }
 
+    /**
+     * Unregisters a registered callback.
+     */
+    public void unregisterCallback(SchedulerCallback<T> callback) {
+        mCallbacks.remove(callback);
+    }
+
     public boolean handleCreate(T activity) {
         mCurrentActivity = new WeakReference<>(activity);
-        return handleIntent(activity, activity.getIntent(), false);
+        return handleIntent(activity, false /* alreadyOnHome */);
     }
 
-    public boolean handleNewIntent(T activity, Intent intent) {
-        return handleIntent(activity, intent, activity.isStarted());
+    public boolean handleNewIntent(T activity) {
+        return handleIntent(activity, activity.isStarted());
     }
 
-    private boolean handleIntent(T activity, Intent intent, boolean alreadyOnHome) {
-        if (intent != null && intent.getExtras() != null) {
-            IBinder stateBinder = intent.getExtras().getBinder(EXTRA_SCHEDULER_CALLBACK);
-            SchedulerCallback<T> handler = ObjectWrapper.unwrap(stateBinder);
-            if (handler != null) {
-                if (!handler.init(activity, alreadyOnHome)) {
-                    intent.getExtras().remove(EXTRA_SCHEDULER_CALLBACK);
-                }
-                return true;
+    private boolean handleIntent(T activity, boolean alreadyOnHome) {
+        boolean handled = false;
+        for (SchedulerCallback<T> cb : mCallbacks) {
+            if (!cb.init(activity, alreadyOnHome)) {
+                // Callback doesn't want any more updates
+                unregisterCallback(cb);
             }
+            handled = true;
         }
-        return false;
+        return handled;
     }
 
     public interface SchedulerCallback<T extends BaseActivity> {
@@ -94,17 +99,5 @@
          * @return Whether to continue receiving callbacks (i.e. if the activity is recreated).
          */
         boolean init(T activity, boolean alreadyOnHome);
-
-        /**
-         * Adds this callback as an extra on the intent, so we can retrieve it in handleIntent() and
-         * call {@link #init}. The intent should be used to start the activity after calling this
-         * method in order for us to get handleIntent().
-         */
-        default Intent addToIntent(Intent intent) {
-            Bundle extras = new Bundle();
-            extras.putBinder(EXTRA_SCHEDULER_CALLBACK, ObjectWrapper.wrap(this));
-            intent.putExtras(extras);
-            return intent;
-        }
     }
 }
diff --git a/src/com/android/launcher3/util/UiThreadHelper.java b/src/com/android/launcher3/util/UiThreadHelper.java
index b9387a8..cb721e6 100644
--- a/src/com/android/launcher3/util/UiThreadHelper.java
+++ b/src/com/android/launcher3/util/UiThreadHelper.java
@@ -25,11 +25,9 @@
 import android.os.IBinder;
 import android.os.Message;
 import android.view.View;
-import android.view.WindowInsets;
 import android.view.inputmethod.InputMethodManager;
 
 import com.android.launcher3.Launcher;
-import com.android.launcher3.Utilities;
 import com.android.launcher3.views.ActivityContext;
 
 /**
@@ -48,14 +46,6 @@
     @SuppressLint("NewApi")
     public static void hideKeyboardAsync(ActivityContext activityContext, IBinder token) {
         View root = activityContext.getDragLayer();
-        if (Utilities.ATLEAST_R) {
-            WindowInsets rootInsets = root.getRootWindowInsets();
-            boolean isImeShown = rootInsets != null && rootInsets.isVisible(
-                    WindowInsets.Type.ime());
-            if (!isImeShown) {
-                return;
-            }
-        }
 
         Message.obtain(HANDLER.get(root.getContext()),
                 MSG_HIDE_KEYBOARD, token).sendToTarget();
diff --git a/src/com/android/launcher3/views/FloatingIconView.java b/src/com/android/launcher3/views/FloatingIconView.java
index 25cce69..3027db6 100644
--- a/src/com/android/launcher3/views/FloatingIconView.java
+++ b/src/com/android/launcher3/views/FloatingIconView.java
@@ -376,6 +376,7 @@
             if (mIconLoadResult.isIconLoaded) {
                 setIcon(mIconLoadResult.drawable, mIconLoadResult.badge,
                         mIconLoadResult.btvDrawable, mIconLoadResult.iconOffset);
+                setVisibility(VISIBLE);
                 setIconAndDotVisible(originalView, false);
             } else {
                 mIconLoadResult.onIconLoaded = () -> {
diff --git a/src/com/android/launcher3/views/RecyclerViewFastScroller.java b/src/com/android/launcher3/views/RecyclerViewFastScroller.java
index f49d1b5..78916ac 100644
--- a/src/com/android/launcher3/views/RecyclerViewFastScroller.java
+++ b/src/com/android/launcher3/views/RecyclerViewFastScroller.java
@@ -344,7 +344,7 @@
             // swiping very close to the thumb area (not just within it's bound)
             // will also prevent back gesture
             SYSTEM_GESTURE_EXCLUSION_RECT.get(0).offset(mThumbDrawOffset.x, mThumbDrawOffset.y);
-            if (Utilities.ATLEAST_Q) {
+            if (Utilities.ATLEAST_Q && mSystemGestureInsets != null) {
                 SYSTEM_GESTURE_EXCLUSION_RECT.get(0).left =
                         SYSTEM_GESTURE_EXCLUSION_RECT.get(0).right - mSystemGestureInsets.right;
             }
diff --git a/src/com/android/launcher3/widget/AddItemWidgetsBottomSheet.java b/src/com/android/launcher3/widget/AddItemWidgetsBottomSheet.java
index 804973f..1cc7f53 100644
--- a/src/com/android/launcher3/widget/AddItemWidgetsBottomSheet.java
+++ b/src/com/android/launcher3/widget/AddItemWidgetsBottomSheet.java
@@ -16,17 +16,21 @@
 
 package com.android.launcher3.widget;
 
+import static com.android.launcher3.Utilities.ATLEAST_R;
 import static com.android.launcher3.anim.Interpolators.FAST_OUT_SLOW_IN;
 
 import android.animation.PropertyValuesHolder;
+import android.annotation.SuppressLint;
 import android.content.Context;
-import android.content.res.Configuration;
+import android.graphics.Insets;
 import android.graphics.Rect;
 import android.util.AttributeSet;
+import android.view.View;
 import android.view.ViewGroup;
 import android.view.ViewParent;
+import android.view.WindowInsets;
 
-import com.android.launcher3.Insettable;
+import com.android.launcher3.DeviceProfile;
 import com.android.launcher3.R;
 import com.android.launcher3.dragndrop.AddItemActivity;
 import com.android.launcher3.views.AbstractSlideInView;
@@ -34,13 +38,12 @@
 /**
  * Bottom sheet for the pin widget.
  */
-public class AddItemWidgetsBottomSheet extends AbstractSlideInView<AddItemActivity>
-        implements Insettable {
+public class AddItemWidgetsBottomSheet extends AbstractSlideInView<AddItemActivity> implements
+        View.OnApplyWindowInsetsListener {
 
     private static final int DEFAULT_CLOSE_DURATION = 200;
 
-    private Rect mInsets;
-    private Configuration mCurrentConfiguration;
+    private final Rect mInsets;
 
     public AddItemWidgetsBottomSheet(Context context, AttributeSet attrs) {
         this(context, attrs, 0);
@@ -48,9 +51,7 @@
 
     public AddItemWidgetsBottomSheet(Context context, AttributeSet attrs, int defStyleAttr) {
         super(context, attrs, defStyleAttr);
-        mContent = this;
         mInsets = new Rect();
-        mCurrentConfiguration = new Configuration(getResources().getConfiguration());
     }
 
     /**
@@ -62,15 +63,49 @@
             ((ViewGroup) parent).removeView(this);
         }
         attachToContainer();
+        setOnApplyWindowInsetsListener(this);
         animateOpen();
     }
 
     @Override
     protected void onLayout(boolean changed, int l, int t, int r, int b) {
-        super.onLayout(changed, l, t, r, b);
+        int width = r - l;
+        int height = b - t;
+
+        // Lay out content as center bottom aligned.
+        int contentWidth = mContent.getMeasuredWidth();
+        int contentLeft = (width - contentWidth - mInsets.left - mInsets.right) / 2 + mInsets.left;
+        mContent.layout(contentLeft, height - mContent.getMeasuredHeight(),
+                contentLeft + contentWidth, height);
+
         setTranslationShift(mTranslationShift);
     }
 
+    @Override
+    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+        DeviceProfile deviceProfile = mActivityContext.getDeviceProfile();
+        int widthUsed;
+        if (mInsets.bottom > 0) {
+            widthUsed = mInsets.left + mInsets.right;
+        } else {
+            Rect padding = deviceProfile.workspacePadding;
+            widthUsed = Math.max(padding.left + padding.right,
+                    2 * (mInsets.left + mInsets.right));
+        }
+
+        int heightUsed = mInsets.top + deviceProfile.edgeMarginPx;
+        measureChildWithMargins(mContent, widthMeasureSpec,
+                widthUsed, heightMeasureSpec, heightUsed);
+        setMeasuredDimension(MeasureSpec.getSize(widthMeasureSpec),
+                MeasureSpec.getSize(heightMeasureSpec));
+    }
+
+    @Override
+    protected void onFinishInflate() {
+        super.onFinishInflate();
+        mContent = findViewById(R.id.add_item_bottom_sheet_content);
+    }
+
     private void animateOpen() {
         if (mIsOpen || mOpenCloseAnimator.isRunning()) {
             return;
@@ -93,25 +128,24 @@
     }
 
     @Override
-    public void setInsets(Rect insets) {
-        // Extend behind left, right, and bottom insets.
-        int leftInset = insets.left - mInsets.left;
-        int rightInset = insets.right - mInsets.right;
-        int bottomInset = insets.bottom - mInsets.bottom;
-        mInsets.set(insets);
-        setPadding(leftInset, getPaddingTop(), rightInset, bottomInset);
-    }
-
-    @Override
-    protected void onConfigurationChanged(Configuration newConfig) {
-        if (mCurrentConfiguration.orientation != newConfig.orientation) {
-            mInsets.setEmpty();
-        }
-        mCurrentConfiguration.updateFrom(newConfig);
-    }
-
-    @Override
     protected int getScrimColor(Context context) {
         return context.getResources().getColor(R.color.widgets_picker_scrim);
     }
+
+    @SuppressLint("NewApi") // Already added API check.
+    @Override
+    public WindowInsets onApplyWindowInsets(View view, WindowInsets windowInsets) {
+        if (ATLEAST_R) {
+            Insets insets = windowInsets.getInsets(WindowInsets.Type.systemBars());
+            mInsets.set(insets.left, insets.top, insets.right, insets.bottom);
+        } else {
+            mInsets.set(windowInsets.getSystemWindowInsetLeft(),
+                    windowInsets.getSystemWindowInsetTop(),
+                    windowInsets.getSystemWindowInsetRight(),
+                    windowInsets.getSystemWindowInsetBottom());
+        }
+        mContent.setPadding(mContent.getPaddingStart(),
+                mContent.getPaddingTop(), mContent.getPaddingEnd(), mInsets.bottom);
+        return windowInsets;
+    }
 }
diff --git a/src/com/android/launcher3/widget/WidgetsBottomSheet.java b/src/com/android/launcher3/widget/WidgetsBottomSheet.java
index 81df100..d0e69fa 100644
--- a/src/com/android/launcher3/widget/WidgetsBottomSheet.java
+++ b/src/com/android/launcher3/widget/WidgetsBottomSheet.java
@@ -20,7 +20,6 @@
 
 import android.animation.PropertyValuesHolder;
 import android.content.Context;
-import android.content.res.Configuration;
 import android.graphics.Rect;
 import android.util.AttributeSet;
 import android.util.IntProperty;
@@ -71,10 +70,9 @@
     private static final long EDUCATION_TIP_DELAY_MS = 300;
 
     private ItemInfo mOriginalItemInfo;
-    private Rect mInsets;
+    private final Rect mInsets;
     private final int mMaxTableHeight;
     private int mMaxHorizontalSpan = 4;
-    private Configuration mCurrentConfiguration;
 
     private final OnLayoutChangeListener mLayoutChangeListenerToShowTips =
             new OnLayoutChangeListener() {
@@ -113,20 +111,38 @@
         super(context, attrs, defStyleAttr);
         setWillNotDraw(false);
         mInsets = new Rect();
-        mContent = this;
         DeviceProfile deviceProfile = mActivityContext.getDeviceProfile();
         // Set the max table height to 2 / 3 of the grid height so that the bottom picker won't
         // take over the entire view vertically.
         mMaxTableHeight = deviceProfile.inv.numRows * 2 / 3  * deviceProfile.cellHeightPx;
-        mCurrentConfiguration = new Configuration(getResources().getConfiguration());
         if (!hasSeenEducationTip()) {
             addOnLayoutChangeListener(mLayoutChangeListenerToShowTips);
         }
     }
 
     @Override
+    protected void onFinishInflate() {
+        super.onFinishInflate();
+        mContent = findViewById(R.id.widgets_bottom_sheet);
+    }
+
+    @Override
     protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
-        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+        DeviceProfile deviceProfile = mActivityContext.getDeviceProfile();
+        int widthUsed;
+        if (mInsets.bottom > 0) {
+            widthUsed = mInsets.left + mInsets.right;
+        } else {
+            Rect padding = deviceProfile.workspacePadding;
+            widthUsed = Math.max(padding.left + padding.right,
+                    2 * (mInsets.left + mInsets.right));
+        }
+
+        int heightUsed = mInsets.top + deviceProfile.edgeMarginPx;
+        measureChildWithMargins(mContent, widthMeasureSpec,
+                widthUsed, heightMeasureSpec, heightUsed);
+        setMeasuredDimension(MeasureSpec.getSize(widthMeasureSpec),
+                MeasureSpec.getSize(heightMeasureSpec));
 
         int paddingPx = 2 * getResources().getDimensionPixelOffset(
                 R.dimen.widget_cell_horizontal_padding);
@@ -142,7 +158,15 @@
 
     @Override
     protected void onLayout(boolean changed, int l, int t, int r, int b) {
-        super.onLayout(changed, l, t, r, b);
+        int width = r - l;
+        int height = b - t;
+
+        // Content is laid out as center bottom aligned.
+        int contentWidth = mContent.getMeasuredWidth();
+        int contentLeft = (width - contentWidth - mInsets.left - mInsets.right) / 2 + mInsets.left;
+        mContent.layout(contentLeft, height - mContent.getMeasuredHeight(),
+                contentLeft + contentWidth, height);
+
         setTranslationShift(mTranslationShift);
 
         // Ensure the scroll view height is not larger than mMaxTableHeight, which is a value
@@ -241,20 +265,14 @@
 
     @Override
     public void setInsets(Rect insets) {
-        // Extend behind left, right, and bottom insets.
-        int leftInset = insets.left - mInsets.left;
-        int rightInset = insets.right - mInsets.right;
-        int bottomInset = insets.bottom - mInsets.bottom;
         mInsets.set(insets);
-        setPadding(leftInset, getPaddingTop(), rightInset, bottomInset);
-    }
-
-    @Override
-    protected void onConfigurationChanged(Configuration newConfig) {
-        if (mCurrentConfiguration.orientation != newConfig.orientation) {
-            mInsets.setEmpty();
+        mContent.setPadding(mContent.getPaddingStart(),
+                mContent.getPaddingTop(), mContent.getPaddingEnd(), insets.bottom);
+        if (insets.bottom > 0) {
+            setupNavBarColor();
+        } else {
+            clearNavBarColor();
         }
-        mCurrentConfiguration.updateFrom(newConfig);
     }
 
     @Override
diff --git a/tests/Android.mk b/tests/Android.mk
index 19b9656..6adc685 100644
--- a/tests/Android.mk
+++ b/tests/Android.mk
@@ -16,34 +16,6 @@
 LOCAL_PATH := $(call my-dir)
 
 #
-# Build rule for Tapl library.
-#
-include $(CLEAR_VARS)
-LOCAL_STATIC_JAVA_LIBRARIES := \
-	androidx.annotation_annotation \
-	androidx.test.runner \
-	androidx.test.rules \
-	androidx.preference_preference \
-	androidx.test.uiautomator_uiautomator
-
-ifneq (,$(wildcard frameworks/base))
-else
-    LOCAL_STATIC_JAVA_LIBRARIES += SystemUISharedLib
-
-    LOCAL_SRC_FILES := $(call all-java-files-under, tapl) \
-        ../src/com/android/launcher3/ResourceUtils.java \
-        ../src/com/android/launcher3/testing/TestProtocol.java
-endif
-
-LOCAL_MODULE := ub-launcher-aosp-tapl
-LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0
-LOCAL_LICENSE_CONDITIONS := notice
-LOCAL_NOTICE_FILE := $(LOCAL_PATH)/../NOTICE
-LOCAL_SDK_VERSION := system_current
-
-include $(BUILD_STATIC_JAVA_LIBRARY)
-
-#
 # Build rule for Launcher3Tests
 #
 include $(CLEAR_VARS)
@@ -56,14 +28,8 @@
     mockito-target-minus-junit4 \
     launcher_log_protos_lite
 
-ifneq (,$(wildcard frameworks/base))
-    LOCAL_PRIVATE_PLATFORM_APIS := true
-    LOCAL_STATIC_JAVA_LIBRARIES += launcher-aosp-tapl
-else
-    LOCAL_SDK_VERSION := system_28
-    LOCAL_MIN_SDK_VERSION := 21
-    LOCAL_STATIC_JAVA_LIBRARIES += ub-launcher-aosp-tapl
-endif
+LOCAL_PRIVATE_PLATFORM_APIS := true
+LOCAL_STATIC_JAVA_LIBRARIES += launcher-aosp-tapl
 
 LOCAL_SRC_FILES := \
 	$(call all-java-files-under, src) \
diff --git a/tests/tapl/com/android/launcher3/tapl/Background.java b/tests/tapl/com/android/launcher3/tapl/Background.java
index 4a666b1..e86be2a 100644
--- a/tests/tapl/com/android/launcher3/tapl/Background.java
+++ b/tests/tapl/com/android/launcher3/tapl/Background.java
@@ -163,8 +163,8 @@
     @NonNull
     private void quickSwitch(boolean toRight) {
         try (LauncherInstrumentation.Closable e = mLauncher.eventsCheck();
-            LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
-                    "want to quick switch to the previous app")) {
+             LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
+                     "want to quick switch to the previous app")) {
             verifyActiveContainer();
             final boolean launcherWasVisible = mLauncher.isLauncherVisible();
             boolean transposeInLandscape = false;
@@ -177,33 +177,34 @@
                     final int startY;
                     final int endX;
                     final int endY;
+                    final int cornerRadius = (int) Math.ceil(mLauncher.getWindowCornerRadius());
                     if (toRight) {
                         if (mLauncher.getDevice().isNaturalOrientation() || !transposeInLandscape) {
                             // Swipe from the bottom left to the bottom right of the screen.
-                            startX = 0;
+                            startX = cornerRadius;
                             startY = getSwipeStartY();
-                            endX = mLauncher.getDevice().getDisplayWidth();
+                            endX = mLauncher.getDevice().getDisplayWidth() - cornerRadius;
                             endY = startY;
                         } else {
                             // Swipe from the bottom right to the top right of the screen.
                             startX = getSwipeStartX();
-                            startY = mLauncher.getRealDisplaySize().y - 1;
+                            startY = mLauncher.getRealDisplaySize().y - 1 - cornerRadius;
                             endX = startX;
-                            endY = 0;
+                            endY = cornerRadius;
                         }
                     } else {
                         if (mLauncher.getDevice().isNaturalOrientation() || !transposeInLandscape) {
                             // Swipe from the bottom right to the bottom left of the screen.
-                            startX = mLauncher.getDevice().getDisplayWidth();
+                            startX = mLauncher.getDevice().getDisplayWidth() - cornerRadius;
                             startY = getSwipeStartY();
-                            endX = 0;
+                            endX = cornerRadius;
                             endY = startY;
                         } else {
                             // Swipe from the bottom left to the top left of the screen.
                             startX = getSwipeStartX();
-                            startY = 0;
+                            startY = cornerRadius;
                             endX = startX;
-                            endY = mLauncher.getRealDisplaySize().y - 1;
+                            endY = mLauncher.getRealDisplaySize().y - 1 - cornerRadius;
                         }
                     }
 
diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
index bf7984e..f5c1efa 100644
--- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
+++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
@@ -1248,6 +1248,13 @@
         }
 
         final MotionEvent event = getMotionEvent(downTime, currentTime, action, point.x, point.y);
+        // b/190748682
+        switch (action) {
+            case MotionEvent.ACTION_DOWN:
+            case MotionEvent.ACTION_UP:
+                log("b/190748682: injecting " + event);
+                break;
+        }
         assertTrue("injectInputEvent failed",
                 mInstrumentation.getUiAutomation().injectInputEvent(event, true, false));
         event.recycle();
@@ -1443,4 +1450,33 @@
             return null;
         }
     }
+
+    float getWindowCornerRadius() {
+        final Resources resources = getResources();
+        if (!supportsRoundedCornersOnWindows(resources)) {
+            return 0f;
+        }
+
+        // Radius that should be used in case top or bottom aren't defined.
+        float defaultRadius = ResourceUtils.getDimenByName("rounded_corner_radius", resources, 0);
+
+        float topRadius = ResourceUtils.getDimenByName("rounded_corner_radius_top", resources, 0);
+        if (topRadius == 0f) {
+            topRadius = defaultRadius;
+        }
+        float bottomRadius = ResourceUtils.getDimenByName(
+                "rounded_corner_radius_bottom", resources, 0);
+        if (bottomRadius == 0f) {
+            bottomRadius = defaultRadius;
+        }
+
+        // Always use the smallest radius to make sure the rounded corners will
+        // completely cover the display.
+        return Math.min(topRadius, bottomRadius);
+    }
+
+    private static boolean supportsRoundedCornersOnWindows(Resources resources) {
+        return ResourceUtils.getBoolByName(
+                "config_supportsRoundedCornersOnWindows", resources, false);
+    }
 }
\ No newline at end of file
diff --git a/tests/tapl/com/android/launcher3/tapl/Workspace.java b/tests/tapl/com/android/launcher3/tapl/Workspace.java
index 3624624..1ea0922 100644
--- a/tests/tapl/com/android/launcher3/tapl/Workspace.java
+++ b/tests/tapl/com/android/launcher3/tapl/Workspace.java
@@ -22,7 +22,6 @@
 
 import static junit.framework.TestCase.assertTrue;
 
-import android.content.res.Resources;
 import android.graphics.Point;
 import android.graphics.Rect;
 import android.os.SystemClock;
@@ -61,34 +60,6 @@
         mHotseat = launcher.waitForLauncherObject("hotseat");
     }
 
-    private static boolean supportsRoundedCornersOnWindows(Resources resources) {
-        return ResourceUtils.getBoolByName(
-                "config_supportsRoundedCornersOnWindows", resources, false);
-    }
-
-    private static float getWindowCornerRadius(Resources resources) {
-        if (!supportsRoundedCornersOnWindows(resources)) {
-            return 0f;
-        }
-
-        // Radius that should be used in case top or bottom aren't defined.
-        float defaultRadius = ResourceUtils.getDimenByName("rounded_corner_radius", resources, 0);
-
-        float topRadius = ResourceUtils.getDimenByName("rounded_corner_radius_top", resources, 0);
-        if (topRadius == 0f) {
-            topRadius = defaultRadius;
-        }
-        float bottomRadius = ResourceUtils.getDimenByName(
-                "rounded_corner_radius_bottom", resources, 0);
-        if (bottomRadius == 0f) {
-            bottomRadius = defaultRadius;
-        }
-
-        // Always use the smallest radius to make sure the rounded corners will
-        // completely cover the display.
-        return Math.min(topRadius, bottomRadius);
-    }
-
     /**
      * Swipes up to All Apps.
      *
@@ -103,8 +74,7 @@
             final int deviceHeight = mLauncher.getDevice().getDisplayHeight();
             final int bottomGestureMargin = ResourceUtils.getNavbarSize(
                     ResourceUtils.NAVBAR_BOTTOM_GESTURE_SIZE, mLauncher.getResources());
-            final int windowCornerRadius = (int) Math.ceil(getWindowCornerRadius(
-                    mLauncher.getResources()));
+            final int windowCornerRadius = (int) Math.ceil(mLauncher.getWindowCornerRadius());
             final int startY = deviceHeight - Math.max(bottomGestureMargin, windowCornerRadius) - 1;
             final int swipeHeight = mLauncher.getTestInfo(
                     TestProtocol.REQUEST_HOME_TO_ALL_APPS_SWIPE_HEIGHT).