Merge "Don't delete widgets that violate min size requirement" into sc-dev
diff --git a/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java b/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java
index c97ca32..cceb872 100644
--- a/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java
+++ b/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java
@@ -56,6 +56,7 @@
 
     private final Context mContext;
     private final BaseActivityInterface mSizeStrategy;
+    private final boolean mIsForLiveTile;
 
     @NonNull
     private RecentsOrientedState mOrientationState;
@@ -93,8 +94,14 @@
     private int mOrientationStateId;
 
     public TaskViewSimulator(Context context, BaseActivityInterface sizeStrategy) {
+        this(context, sizeStrategy, false);
+    }
+
+    public TaskViewSimulator(Context context, BaseActivityInterface sizeStrategy,
+            boolean isForLiveTile) {
         mContext = context;
         mSizeStrategy = sizeStrategy;
+        mIsForLiveTile = isForLiveTile;
 
         // TODO(b/187074722): Don't create this per-TaskViewSimulator
         mOrientationState = TraceHelper.allowIpcs("",
@@ -302,7 +309,8 @@
                 .withWindowCrop(mTmpCropRect)
                 .withCornerRadius(getCurrentCornerRadius());
 
-        if (ENABLE_QUICKSTEP_LIVE_TILE.get() && params.getRecentsSurface() != null) {
+        if (ENABLE_QUICKSTEP_LIVE_TILE.get() && mIsForLiveTile
+                && params.getRecentsSurface() != null) {
             // When relativeLayer = 0, it reverts the surfaces back to the original order.
             builder.withRelativeLayerTo(params.getRecentsSurface(),
                     mDrawsBelowRecents ? Integer.MIN_VALUE : 0);
diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java
index 4e1bcc9..ce79125 100644
--- a/quickstep/src/com/android/quickstep/views/RecentsView.java
+++ b/quickstep/src/com/android/quickstep/views/RecentsView.java
@@ -629,7 +629,8 @@
         // Initialize quickstep specific cache params here, as this is constructed only once
         mActivity.getViewCache().setCacheSize(R.layout.digital_wellbeing_toast, 5);
 
-        mLiveTileTaskViewSimulator = new TaskViewSimulator(getContext(), getSizeStrategy());
+        mLiveTileTaskViewSimulator = new TaskViewSimulator(getContext(), getSizeStrategy(),
+                true /* isForLiveTile */);
         mLiveTileTaskViewSimulator.recentsViewScale.value = 1;
         mLiveTileTaskViewSimulator.setOrientationState(mOrientationState);
         mLiveTileTaskViewSimulator.setDrawsBelowRecents(true);
@@ -1791,6 +1792,12 @@
         }
 
         mCurrentGestureEndTarget = null;
+
+        if (ENABLE_QUICKSTEP_LIVE_TILE.get() && mActivity.getDeviceProfile().isMultiWindowMode) {
+            switchToScreenshot(
+                    () -> finishRecentsAnimation(true /* toRecents */, false /* shouldPip */,
+                            null));
+        }
     }
 
     /**
diff --git a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java
index bf4eba0..dcb6dc1 100644
--- a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java
+++ b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java
@@ -153,6 +153,8 @@
     public static String dumpHprofData() {
         String result;
         if (sDumpWasGenerated) {
+            Log.d("b/195319692", "dump has already been generated by another test",
+                    new Exception());
             result = "dump has already been generated by another test";
         } else {
             try {
@@ -167,6 +169,7 @@
                             "am dumpheap " + device.getLauncherPackageName() + " " + fileName);
                 }
                 sDumpWasGenerated = true;
+                Log.d("b/195319692", "sDumpWasGenerated := true", new Exception());
                 result = "memory dump filename: " + fileName;
             } catch (Throwable e) {
                 Log.e(TAG, "dumpHprofData failed", e);