Merge "Add app start source info of apps launched from launcher" into ub-launcher3-master
diff --git a/quickstep/src/com/android/launcher3/appprediction/PredictionRowView.java b/quickstep/src/com/android/launcher3/appprediction/PredictionRowView.java
index 37336d1..f313d75 100644
--- a/quickstep/src/com/android/launcher3/appprediction/PredictionRowView.java
+++ b/quickstep/src/com/android/launcher3/appprediction/PredictionRowView.java
@@ -206,7 +206,7 @@
      * we can optimize by swapping them in place.
      */
     public void setPredictedApps(List<ItemInfo> items) {
-        if (isShown() && getWindowVisibility() == View.VISIBLE) {
+        if (!mLauncher.isWorkspaceLoading() && isShown() && getWindowVisibility() == View.VISIBLE) {
             mPendingPredictedItems = items;
             return;
         }
diff --git a/quickstep/src/com/android/launcher3/hybridhotseat/HotseatPredictionController.java b/quickstep/src/com/android/launcher3/hybridhotseat/HotseatPredictionController.java
index 76bab59..d3b7e22 100644
--- a/quickstep/src/com/android/launcher3/hybridhotseat/HotseatPredictionController.java
+++ b/quickstep/src/com/android/launcher3/hybridhotseat/HotseatPredictionController.java
@@ -251,7 +251,9 @@
      * Sets or updates the predicted items
      */
     public void setPredictedItems(FixedContainerItems items) {
-        if (mHotseat.isShown() && mHotseat.getWindowVisibility() == View.VISIBLE) {
+        if (!mLauncher.isWorkspaceLoading()
+                && mHotseat.isShown()
+                && mHotseat.getWindowVisibility() == View.VISIBLE) {
             mHotseat.setOnVisibilityAggregatedCallback((isVisible) -> {
                 if (isVisible) {
                     return;
diff --git a/quickstep/src/com/android/launcher3/model/WellbeingModel.java b/quickstep/src/com/android/launcher3/model/WellbeingModel.java
index a9fc1aa..995c4b0 100644
--- a/quickstep/src/com/android/launcher3/model/WellbeingModel.java
+++ b/quickstep/src/com/android/launcher3/model/WellbeingModel.java
@@ -148,6 +148,12 @@
             if (!FeatureFlags.ENABLE_MINIMAL_DEVICE.get()) {
                 return;
             }
+
+            // Temporary bug fix for b/169771796. Wellbeing provides the layout configuration when
+            // minimal device is enabled. We always want to reload the configuration from Wellbeing
+            // since the layout configuration might have changed.
+            mContext.deleteDatabase(DB_NAME_MINIMAL_DEVICE);
+
             final Bundle extras = new Bundle();
             String dbFile;
             if (isInMinimalDeviceMode()) {
diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
index 1154964..cc109f6 100644
--- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
+++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
@@ -1339,7 +1339,7 @@
                 if (taskView != null && !mCanceled) {
                     // Defer finishing the animation until the next launcher frame with the
                     // new thumbnail
-                    finishTransitionPosted = ViewUtils.postDraw(taskView,
+                    finishTransitionPosted = ViewUtils.postFrameDrawn(taskView,
                             () -> mStateCallback.setStateOnUiThread(STATE_SCREENSHOT_CAPTURED),
                             this::isCanceled);
                 }
diff --git a/quickstep/src/com/android/quickstep/SwipeUpAnimationLogic.java b/quickstep/src/com/android/quickstep/SwipeUpAnimationLogic.java
index a46de1f..7406dea 100644
--- a/quickstep/src/com/android/quickstep/SwipeUpAnimationLogic.java
+++ b/quickstep/src/com/android/quickstep/SwipeUpAnimationLogic.java
@@ -261,7 +261,7 @@
             mTransformParams
                     .setTargetAlpha(getWindowAlpha(progress))
                     .setCornerRadius(cornerRadius)
-                    .setShadowRadius(mMaxShadowRadius);
+                    .setShadowRadius(shadowRadius);
 
             mTransformParams.applySurfaceParams(mTransformParams.createSurfaceParams(this));
             mAnimationFactory.update(currentRect, progress, mMatrix.mapRadius(cornerRadius));
diff --git a/quickstep/src/com/android/quickstep/ViewUtils.java b/quickstep/src/com/android/quickstep/ViewUtils.java
index cbb6ad4..184ab17 100644
--- a/quickstep/src/com/android/quickstep/ViewUtils.java
+++ b/quickstep/src/com/android/quickstep/ViewUtils.java
@@ -15,21 +15,23 @@
  */
 package com.android.quickstep;
 
-import android.graphics.Canvas;
+import android.os.Handler;
 import android.view.View;
 
-import com.android.systemui.shared.system.WindowCallbacksCompat;
+import com.android.launcher3.Utilities;
+import com.android.systemui.shared.system.ViewRootImplCompat;
 
 import java.util.function.BooleanSupplier;
+import java.util.function.LongConsumer;
 
 /**
  * Utility class for helpful methods related to {@link View} objects.
  */
 public class ViewUtils {
 
-    /** See {@link #postDraw(View, Runnable, BooleanSupplier)}} */
-    public static boolean postDraw(View view, Runnable onFinishRunnable) {
-        return postDraw(view, onFinishRunnable, () -> false);
+    /** See {@link #postFrameDrawn(View, Runnable, BooleanSupplier)}} */
+    public static boolean postFrameDrawn(View view, Runnable onFinishRunnable) {
+        return postFrameDrawn(view, onFinishRunnable, () -> false);
     }
 
     /**
@@ -38,37 +40,55 @@
      *
      * @param onFinishRunnable runnable to be run right after the view finishes drawing.
      */
-    public static boolean postDraw(View view, Runnable onFinishRunnable, BooleanSupplier canceled) {
-        // Defer finishing the animation until the next launcher frame with the
-        // new thumbnail
-        return new WindowCallbacksCompat(view) {
-            // The number of frames to defer until we actually finish the animation
-            private int mDeferFrameCount = 2;
+    public static boolean postFrameDrawn(
+            View view, Runnable onFinishRunnable, BooleanSupplier canceled) {
+        return new FrameHandler(view, onFinishRunnable, canceled).schedule();
+    }
 
-            @Override
-            public void onPostDraw(Canvas canvas) {
-                // If we were cancelled after this was attached, do not update
-                // the state.
-                if (canceled.getAsBoolean()) {
-                    detach();
-                    return;
-                }
+    private static class FrameHandler implements LongConsumer {
 
-                if (mDeferFrameCount > 0) {
-                    mDeferFrameCount--;
-                    // Workaround, detach and reattach to invalidate the root node for
-                    // another draw
-                    detach();
-                    attach();
-                    view.invalidate();
-                    return;
-                }
+        final ViewRootImplCompat mViewRoot;
+        final Runnable mFinishCallback;
+        final BooleanSupplier mCancelled;
+        final Handler mHandler;
 
-                if (onFinishRunnable != null) {
-                    onFinishRunnable.run();
-                }
-                detach();
+        int mDeferFrameCount = 1;
+
+        FrameHandler(View view, Runnable finishCallback, BooleanSupplier cancelled) {
+            mViewRoot = new ViewRootImplCompat(view);
+            mFinishCallback = finishCallback;
+            mCancelled = cancelled;
+            mHandler = new Handler();
+        }
+
+        @Override
+        public void accept(long l) {
+            Utilities.postAsyncCallback(mHandler, this::onFrame);
+        }
+
+        private void onFrame() {
+            if (mCancelled.getAsBoolean()) {
+                return;
             }
-        }.attach();
+
+            if (mDeferFrameCount > 0) {
+                mDeferFrameCount--;
+                schedule();
+                return;
+            }
+
+            if (mFinishCallback != null) {
+                mFinishCallback.run();
+            }
+        }
+
+        private boolean schedule() {
+            if (mViewRoot.isValid()) {
+                mViewRoot.registerRtFrameCallback(this);
+                mViewRoot.getView().invalidate();
+                return true;
+            }
+            return false;
+        }
     }
 }
diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java
index 65a445b..2158e03 100644
--- a/quickstep/src/com/android/quickstep/views/RecentsView.java
+++ b/quickstep/src/com/android/quickstep/views/RecentsView.java
@@ -2452,7 +2452,7 @@
             } else {
                 taskView.getThumbnail().refresh();
             }
-            ViewUtils.postDraw(taskView, onFinishRunnable);
+            ViewUtils.postFrameDrawn(taskView, onFinishRunnable);
         } else {
             onFinishRunnable.run();
         }
diff --git a/res/layout/search_section_title.xml b/res/layout/search_section_title.xml
index c541631..b7ba83e 100644
--- a/res/layout/search_section_title.xml
+++ b/res/layout/search_section_title.xml
@@ -17,8 +17,9 @@
     android:id="@+id/section_title"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
-    android:fontFamily="@style/TextHeadline"
-    android:textStyle="bold"
-    android:padding="4dp"
+    style="@style/TextHeadline"
+    android:paddingStart="4dp"
+    android:paddingBottom="2dp"
+    android:paddingTop="12dp"
     android:textColor="?android:attr/textColorPrimary"
-    android:textSize="14sp" />
\ No newline at end of file
+    android:textSize="18sp" />
\ No newline at end of file