Retains cached widget in launcher process

Currently cached widget are retained in LauncherWidgetHolder which is
released when Launcher activity is recreated. This CL moves the cached
widget into LauncherAppState to keep the cache alive.

Bug: 268189435
Test: steps below
1. Add multiple widgets (Calendar / Weather ... e.t.c) to Home Screen
2. Open Google Map, start navigation to any place
3. Google Map enters navigation mode and changes resolution
4. Swipe up to exit Google Map and go to Home Screen
5. Verify you don't see deferred widget host view.

Change-Id: I8b56167313780cd1be2a5da88517114acc6d44af
diff --git a/src/com/android/launcher3/LauncherAppState.java b/src/com/android/launcher3/LauncherAppState.java
index c81ad01..abf5866 100644
--- a/src/com/android/launcher3/LauncherAppState.java
+++ b/src/com/android/launcher3/LauncherAppState.java
@@ -31,7 +31,11 @@
 import android.content.pm.LauncherApps;
 import android.os.UserHandle;
 import android.util.Log;
+import android.util.SparseArray;
+import android.widget.RemoteViews;
 
+import androidx.annotation.GuardedBy;
+import androidx.annotation.NonNull;
 import androidx.annotation.Nullable;
 
 import com.android.launcher3.config.FeatureFlags;
@@ -70,6 +74,12 @@
     private final InvariantDeviceProfile mInvariantDeviceProfile;
     private final RunnableList mOnTerminateCallback = new RunnableList();
 
+    // WORKAROUND: b/269335387 remove this after widget background listener is enabled
+    /* Array of RemoteViews cached by Launcher process */
+    @GuardedBy("itself")
+    @NonNull
+    public final SparseArray<RemoteViews> mCachedRemoteViews = new SparseArray<>();
+
     public static LauncherAppState getInstance(final Context context) {
         return INSTANCE.get(context);
     }