Merge "Activity orientation experiment on only large screens" into main
diff --git a/services/core/java/com/android/server/wm/ActivityRecord.java b/services/core/java/com/android/server/wm/ActivityRecord.java
index ef33ffe..776bf53 100644
--- a/services/core/java/com/android/server/wm/ActivityRecord.java
+++ b/services/core/java/com/android/server/wm/ActivityRecord.java
@@ -3238,10 +3238,12 @@
         }
         final boolean compatEnabled = isLargeScreen && Flags.universalResizableByDefault()
                 && appInfo.isChangeEnabled(ActivityInfo.UNIVERSAL_RESIZABLE_BY_DEFAULT);
-        if (!compatEnabled && !wms.mConstants.mIgnoreActivityOrientationRequest) {
-            return false;
-        }
-        if (wms.mConstants.isPackageOptOutIgnoreActivityOrientationRequest(appInfo.packageName)) {
+        final boolean configEnabled = (isLargeScreen
+                ? wms.mConstants.mIgnoreActivityOrientationRequestLargeScreen
+                : wms.mConstants.mIgnoreActivityOrientationRequestSmallScreen)
+                && !wms.mConstants.isPackageOptOutIgnoreActivityOrientationRequest(
+                        appInfo.packageName);
+        if (!compatEnabled && !configEnabled) {
             return false;
         }
         if (forActivity) {
diff --git a/services/core/java/com/android/server/wm/WindowManagerConstants.java b/services/core/java/com/android/server/wm/WindowManagerConstants.java
index 31ca24c..3ad9b62 100644
--- a/services/core/java/com/android/server/wm/WindowManagerConstants.java
+++ b/services/core/java/com/android/server/wm/WindowManagerConstants.java
@@ -36,7 +36,15 @@
  */
 final class WindowManagerConstants {
 
-    /** The orientation of activity will be always "unspecified" except for game apps. */
+    /**
+     * The orientation of activity will be always "unspecified" except for game apps.
+     * <p>Possible values:
+     * <ul>
+     * <li>false: applies to no apps (default)</li>
+     * <li>true: applies to all apps</li>
+     * <li>large: applies to all apps but only on large screens</li>
+     * </ul>
+     */
     private static final String KEY_IGNORE_ACTIVITY_ORIENTATION_REQUEST =
             "ignore_activity_orientation_request";
 
@@ -69,7 +77,8 @@
     boolean mSystemGestureExcludedByPreQStickyImmersive;
 
     /** @see #KEY_IGNORE_ACTIVITY_ORIENTATION_REQUEST */
-    boolean mIgnoreActivityOrientationRequest;
+    boolean mIgnoreActivityOrientationRequestLargeScreen;
+    boolean mIgnoreActivityOrientationRequestSmallScreen;
 
     /** @see #KEY_OPT_OUT_IGNORE_ACTIVITY_ORIENTATION_REQUEST_LIST */
     private ArraySet<String> mOptOutIgnoreActivityOrientationRequestPackages;
@@ -177,9 +186,12 @@
     }
 
     private void updateIgnoreActivityOrientationRequest() {
-        mIgnoreActivityOrientationRequest = mDeviceConfig.getBoolean(
+        final String value = mDeviceConfig.getProperty(
                 DeviceConfig.NAMESPACE_WINDOW_MANAGER,
-                KEY_IGNORE_ACTIVITY_ORIENTATION_REQUEST, false);
+                KEY_IGNORE_ACTIVITY_ORIENTATION_REQUEST);
+        mIgnoreActivityOrientationRequestSmallScreen = Boolean.parseBoolean(value);
+        mIgnoreActivityOrientationRequestLargeScreen = mIgnoreActivityOrientationRequestSmallScreen
+                || ("large".equals(value));
     }
 
     private void updateOptOutIgnoreActivityOrientationRequestList() {
@@ -196,8 +208,7 @@
     }
 
     boolean isPackageOptOutIgnoreActivityOrientationRequest(String packageName) {
-        return mIgnoreActivityOrientationRequest
-                && mOptOutIgnoreActivityOrientationRequestPackages != null
+        return mOptOutIgnoreActivityOrientationRequestPackages != null
                 && mOptOutIgnoreActivityOrientationRequestPackages.contains(packageName);
     }
 
@@ -211,7 +222,8 @@
         pw.print("  "); pw.print(KEY_SYSTEM_GESTURES_EXCLUDED_BY_PRE_Q_STICKY_IMMERSIVE);
         pw.print("="); pw.println(mSystemGestureExcludedByPreQStickyImmersive);
         pw.print("  "); pw.print(KEY_IGNORE_ACTIVITY_ORIENTATION_REQUEST);
-        pw.print("="); pw.println(mIgnoreActivityOrientationRequest);
+        pw.print("="); pw.println(mIgnoreActivityOrientationRequestSmallScreen ? "true"
+                : mIgnoreActivityOrientationRequestLargeScreen ? "large" : "false");
         if (mOptOutIgnoreActivityOrientationRequestPackages != null) {
             pw.print("  "); pw.print(KEY_OPT_OUT_IGNORE_ACTIVITY_ORIENTATION_REQUEST_LIST);
             pw.print("="); pw.println(mOptOutIgnoreActivityOrientationRequestPackages);
diff --git a/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java b/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java
index fee646d..d4a921c 100644
--- a/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java
@@ -2670,7 +2670,7 @@
         assertSetOrientation(Build.VERSION_CODES.CUR_DEVELOPMENT, CATEGORY_GAME, true);
 
         // Blanket application, also ignoring Target SDK
-        mWm.mConstants.mIgnoreActivityOrientationRequest = true;
+        mWm.mConstants.mIgnoreActivityOrientationRequestLargeScreen = true;
         assertSetOrientation(Build.VERSION_CODES.VANILLA_ICE_CREAM, CATEGORY_SOCIAL, false);
     }
 
diff --git a/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java b/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java
index 87db6c0..bf96f0eb 100644
--- a/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java
@@ -4892,7 +4892,8 @@
 
     @Test
     public void testUniversalResizeable() {
-        mWm.mConstants.mIgnoreActivityOrientationRequest = true;
+        mWm.mConstants.mIgnoreActivityOrientationRequestSmallScreen = true;
+        mWm.mConstants.mIgnoreActivityOrientationRequestLargeScreen = true;
         setUpApp(mDisplayContent);
         final float maxAspect = 1.8f;
         final float minAspect = 1.5f;