Fix flag guarding for oneGridRotationHandling

Bug: 364711064
Flag: com.android.launcher3.one_grid_rotation_handling
Test: n/a
Change-Id: Ic0027bf82912bf56470a8abc29880599820b3352
diff --git a/src/com/android/launcher3/InvariantDeviceProfile.java b/src/com/android/launcher3/InvariantDeviceProfile.java
index 7acba75..3a29727 100644
--- a/src/com/android/launcher3/InvariantDeviceProfile.java
+++ b/src/com/android/launcher3/InvariantDeviceProfile.java
@@ -540,7 +540,7 @@
         }
     }
 
-    private List<DisplayOption> getPredefinedDeviceProfiles(Context context,
+    private static List<DisplayOption> getPredefinedDeviceProfiles(Context context,
             String gridName, @DeviceType int deviceType, boolean allowDisabledGrid) {
         ArrayList<DisplayOption> profiles = new ArrayList<>();
 
@@ -554,7 +554,7 @@
 
                     GridOption gridOption = new GridOption(context, Xml.asAttributeSet(parser));
                     if ((gridOption.isEnabled(deviceType) || allowDisabledGrid)
-                            && (Flags.oneGridSpecs() == gridOption.isNewGridOption())) {
+                            && gridOption.filterByFlag(deviceType)) {
                         final int displayDepth = parser.getDepth();
                         while (((type = parser.next()) != XmlPullParser.END_TAG
                                 || parser.getDepth() > displayDepth)
@@ -710,7 +710,7 @@
         return parseAllDefinedGridOptions(context)
                 .stream()
                 .filter(go -> go.isEnabled(deviceType))
-                .filter(go -> (Flags.oneGridSpecs() == go.isNewGridOption()))
+                .filter(go -> go.filterByFlag(deviceType))
                 .collect(Collectors.toList());
     }
 
@@ -967,6 +967,7 @@
         private final int demoModeLayoutId;
 
         private final boolean isScalable;
+        private final boolean mIsDualGrid;
         private final int devicePaddingId;
         private final int mWorkspaceSpecsId;
         private final int mWorkspaceSpecsTwoPanelId;
@@ -991,6 +992,7 @@
                     DEVICE_CATEGORY_ALL);
             mRowCountSpecsId = a.getResourceId(
                     R.styleable.GridDisplayOption_rowCountSpecsId, INVALID_RESOURCE_HANDLE);
+            mIsDualGrid = a.getBoolean(R.styleable.GridDisplayOption_isDualGrid, false);
             if (mRowCountSpecsId != INVALID_RESOURCE_HANDLE) {
                 ResourceHelper resourceHelper = new ResourceHelper(context, mRowCountSpecsId);
                 NumRows numR = getRowCount(resourceHelper, context, deviceCategory);
@@ -1154,6 +1156,13 @@
         public boolean isNewGridOption() {
             return mRowCountSpecsId != INVALID_RESOURCE_HANDLE;
         }
+
+        public boolean filterByFlag(int deviceType) {
+            if (deviceType == TYPE_TABLET) {
+                return Flags.oneGridRotationHandling() == mIsDualGrid;
+            }
+            return Flags.oneGridSpecs() == isNewGridOption();
+        }
     }
 
     public static final class NumRows {