Adding content provider for exposing launcher grid settings

Bug: 122262084
Change-Id: I3e89e0a9400fb3e81f932af3606eb49c36d34894
diff --git a/src/com/android/launcher3/InvariantDeviceProfile.java b/src/com/android/launcher3/InvariantDeviceProfile.java
index 3c0ef79..45bdea8 100644
--- a/src/com/android/launcher3/InvariantDeviceProfile.java
+++ b/src/com/android/launcher3/InvariantDeviceProfile.java
@@ -139,6 +139,13 @@
                 APPLY_CONFIG_AT_RUNTIME.get() ? this::onConfigChanged : this::killProcess);
     }
 
+    public InvariantDeviceProfile(Context context, String gridName) {
+        String newName = initGrid(context, gridName);
+        if (newName == null || !newName.equals(gridName)) {
+            throw new IllegalArgumentException("Unknown grid name");
+        }
+    }
+
     /**
      * Retrieve system defined or RRO overriden icon shape.
      */
@@ -150,7 +157,7 @@
         return context.getResources().getString(CONFIG_ICON_MASK_RES_ID);
     }
 
-    private void initGrid(Context context, String gridName) {
+    private String initGrid(Context context, String gridName) {
         WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
         Display display = wm.getDefaultDisplay();
         DisplayMetrics dm = new DisplayMetrics();
@@ -218,6 +225,7 @@
         } else {
             defaultWallpaperSize = new Point(Math.max(smallSide * 2, largeSide), largeSide);
         }
+        return closestProfile.name;
     }
 
     @Nullable
@@ -441,11 +449,11 @@
     }
 
 
-    private static final class GridOption {
+    public static final class GridOption {
 
-        private final String name;
-        private final int numRows;
-        private final int numColumns;
+        public final String name;
+        public final int numRows;
+        public final int numColumns;
 
         private final int numFolderRows;
         private final int numFolderColumns;
@@ -457,7 +465,7 @@
 
         private final SparseArray<TypedValue> extraAttrs;
 
-        GridOption(Context context, AttributeSet attrs) {
+        public GridOption(Context context, AttributeSet attrs) {
             TypedArray a = context.obtainStyledAttributes(
                     attrs, R.styleable.GridDisplayOption);
             name = a.getString(R.styleable.GridDisplayOption_name);