Set default value of gridName to current grid name in GridOptionsProvider

With grid preview, a grid name is passed in when requesting preview under different grid setting. With wallpaper preview, no such grid name will be passed in, and it should be set to the current.

Bug: 145242344
Test: N/A
Change-Id: I282cb5341b7f3756d41c4abd8d97f986abaa6d27
diff --git a/src/com/android/launcher3/InvariantDeviceProfile.java b/src/com/android/launcher3/InvariantDeviceProfile.java
index 2ad84b9..7414a88 100644
--- a/src/com/android/launcher3/InvariantDeviceProfile.java
+++ b/src/com/android/launcher3/InvariantDeviceProfile.java
@@ -162,9 +162,7 @@
                     "PreviewContext is passed into this IDP constructor");
         }
 
-        String gridName = Utilities.getPrefs(context).getBoolean(GRID_OPTIONS_PREFERENCE_KEY, false)
-                ? Utilities.getPrefs(context).getString(KEY_IDP_GRID_NAME, null)
-                : null;
+        String gridName = getCurrentGridName(context);
         initGrid(context, gridName);
         mConfigMonitor = new ConfigMonitor(context,
                 APPLY_CONFIG_AT_RUNTIME.get() ? this::onConfigChanged : this::killProcess);
@@ -188,6 +186,12 @@
         initGrid(context, null, new Info(display));
     }
 
+    public static String getCurrentGridName(Context context) {
+        return Utilities.getPrefs(context).getBoolean(GRID_OPTIONS_PREFERENCE_KEY, false)
+                ? Utilities.getPrefs(context).getString(KEY_IDP_GRID_NAME, null)
+                : null;
+    }
+
     /**
      * Retrieve system defined or RRO overriden icon shape.
      */