Fix widget foreground disappearing when swiping back

Test: Manual
Bug: 285914177
Change-Id: Ib080f59571b67a720b9d5440cbac17c02fc5c2d4
diff --git a/quickstep/src/com/android/launcher3/uioverrides/QuickstepWidgetHolder.java b/quickstep/src/com/android/launcher3/uioverrides/QuickstepWidgetHolder.java
index 39543b0..f7bef03 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/QuickstepWidgetHolder.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/QuickstepWidgetHolder.java
@@ -243,6 +243,7 @@
         } else {
             widgetView = new LauncherAppWidgetHostView(context);
         }
+        widgetView.setIsWidgetCachingDisabled(true);
         widgetView.setInteractionHandler(mInteractionHandler);
         widgetView.setAppWidget(appWidgetId, appWidget);
         mViews.put(appWidgetId, widgetView);
diff --git a/src/com/android/launcher3/widget/LauncherAppWidgetHostView.java b/src/com/android/launcher3/widget/LauncherAppWidgetHostView.java
index bc3889f..98d854e 100644
--- a/src/com/android/launcher3/widget/LauncherAppWidgetHostView.java
+++ b/src/com/android/launcher3/widget/LauncherAppWidgetHostView.java
@@ -95,6 +95,8 @@
 
     private boolean mTrackingWidgetUpdate = false;
 
+    private boolean mIsWidgetCachingDisabled = false;
+
     public LauncherAppWidgetHostView(Context context) {
         super(context);
         mLauncher = Launcher.getLauncher(context);
@@ -138,6 +140,10 @@
         }
     }
 
+    public void setIsWidgetCachingDisabled(boolean isWidgetCachingDisabled) {
+        mIsWidgetCachingDisabled = isWidgetCachingDisabled;
+    }
+
     @Override
     @TargetApi(Build.VERSION_CODES.Q)
     public void updateAppWidget(RemoteViews remoteViews) {
@@ -147,7 +153,8 @@
                     TRACE_METHOD_NAME + getAppWidgetInfo().provider, getAppWidgetId());
             mTrackingWidgetUpdate = false;
         }
-        if (FeatureFlags.ENABLE_CACHED_WIDGET.get()) {
+        if (FeatureFlags.ENABLE_CACHED_WIDGET.get()
+                && !mIsWidgetCachingDisabled) {
             mLastRemoteViews = remoteViews;
             if (isDeferringUpdates()) {
                 return;