Add CTS test for PROPERTY_COMPAT_ALLOW_USER_ASPECT_RATIO_OVERRIDE

Test that the property allows to opt-in and opt-out from the user
aspect ratio settings.

Also, test behaviour of the override when the property is not set.

Bug: 294227289
Test: atest CtsWindowManagerDeviceDisplay:CompatChangeTests
Change-Id: I515a9c856182118ad03c2e0df86f9a298e3aec2c
diff --git a/tests/framework/base/windowmanager/Android.bp b/tests/framework/base/windowmanager/Android.bp
index 22f5c9f..b070aff 100644
--- a/tests/framework/base/windowmanager/Android.bp
+++ b/tests/framework/base/windowmanager/Android.bp
@@ -88,6 +88,8 @@
         ":CtsPropertyIgnoreOrientationRequestOverrideOptInApp",
         ":CtsPropertyCompatAllowResizeableActivityOverridesOptInApp",
         ":CtsPropertyCompatAllowResizeableActivityOverridesOptOutApp",
+        ":CtsPropertyCompatAllowUserAspectRatioOverrideOptInApp",
+        ":CtsPropertyCompatAllowUserAspectRatioOverrideOptOutApp",
         ":CtsPropertyCameraCompatAllowForceRotationApp",
         ":CtsPropertyCameraCompatAllowRefreshApp",
         ":CtsPropertyCameraCompatEnableRefreshViaPauseOptInApp",
diff --git a/tests/framework/base/windowmanager/AndroidTestTemplate.xml b/tests/framework/base/windowmanager/AndroidTestTemplate.xml
index 0b7733b..be976cc 100644
--- a/tests/framework/base/windowmanager/AndroidTestTemplate.xml
+++ b/tests/framework/base/windowmanager/AndroidTestTemplate.xml
@@ -41,6 +41,8 @@
         <option name="test-file-name" value="CtsPropertyCompatAllowIgnoringOrientationRequestWhenLoopDetectedUnsetApp.apk" />
         <option name="test-file-name" value="CtsPropertyCompatAllowResizeableActivityOverridesOptInApp.apk" />
         <option name="test-file-name" value="CtsPropertyCompatAllowResizeableActivityOverridesOptOutApp.apk" />
+        <option name="test-file-name" value="CtsPropertyCompatAllowUserAspectRatioOverrideOptInApp.apk" />
+        <option name="test-file-name" value="CtsPropertyCompatAllowUserAspectRatioOverrideOptOutApp.apk" />
         <option name="test-file-name" value="CtsDragAndDropSourceApp.apk"/>
         <option name="test-file-name" value="CtsDragAndDropTargetApp.apk"/>
         <option name="test-file-name" value="CtsDeviceAlertWindowTestApp.apk"/>
diff --git a/tests/framework/base/windowmanager/appPropertyCompatAllowUserAspectRatioOverrideOptIn/Android.bp b/tests/framework/base/windowmanager/appPropertyCompatAllowUserAspectRatioOverrideOptIn/Android.bp
new file mode 100644
index 0000000..66abdeb
--- /dev/null
+++ b/tests/framework/base/windowmanager/appPropertyCompatAllowUserAspectRatioOverrideOptIn/Android.bp
@@ -0,0 +1,34 @@
+// Copyright (C) 2024 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package {
+    default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
+android_test {
+    name: "CtsPropertyCompatAllowUserAspectRatioOverrideOptInApp",
+    defaults: ["cts_support_defaults"],
+
+    static_libs: ["cts-wm-app-base"],
+
+    srcs: ["src/**/*.java"],
+
+    sdk_version: "test_current",
+
+    test_suites: [
+        "cts",
+        "general-tests",
+        "sts",
+    ],
+}
diff --git a/tests/framework/base/windowmanager/appPropertyCompatAllowUserAspectRatioOverrideOptIn/AndroidManifest.xml b/tests/framework/base/windowmanager/appPropertyCompatAllowUserAspectRatioOverrideOptIn/AndroidManifest.xml
new file mode 100644
index 0000000..755c021
--- /dev/null
+++ b/tests/framework/base/windowmanager/appPropertyCompatAllowUserAspectRatioOverrideOptIn/AndroidManifest.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+     Copyright (C) 2024 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+          package="android.server.wm.allowuseraspectratiooverrideoptin">
+
+    <application android:debuggable="true">
+
+        <property android:name="android.window.PROPERTY_COMPAT_ALLOW_USER_ASPECT_RATIO_OVERRIDE"
+                  android:value="true"/>
+
+        <activity android:name=".AllowUserAspectRatioOverrideOptInActivity"
+                  android:exported="true"/>
+
+    </application>
+
+</manifest>
\ No newline at end of file
diff --git a/tests/framework/base/windowmanager/appPropertyCompatAllowUserAspectRatioOverrideOptIn/src/android/server/wm/allowuseraspectratiooverrideoptin/AllowUserAspectRatioOverrideOptInActivity.java b/tests/framework/base/windowmanager/appPropertyCompatAllowUserAspectRatioOverrideOptIn/src/android/server/wm/allowuseraspectratiooverrideoptin/AllowUserAspectRatioOverrideOptInActivity.java
new file mode 100644
index 0000000..b520d4a
--- /dev/null
+++ b/tests/framework/base/windowmanager/appPropertyCompatAllowUserAspectRatioOverrideOptIn/src/android/server/wm/allowuseraspectratiooverrideoptin/AllowUserAspectRatioOverrideOptInActivity.java
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.server.wm.allowuseraspectratiooverrideoptin;
+
+import android.app.Activity;
+
+public class AllowUserAspectRatioOverrideOptInActivity extends Activity {
+}
diff --git a/tests/framework/base/windowmanager/appPropertyCompatAllowUserAspectRatioOverrideOptIn/src/android/server/wm/allowuseraspectratiooverrideoptin/Components.java b/tests/framework/base/windowmanager/appPropertyCompatAllowUserAspectRatioOverrideOptIn/src/android/server/wm/allowuseraspectratiooverrideoptin/Components.java
new file mode 100644
index 0000000..e7b3fdf
--- /dev/null
+++ b/tests/framework/base/windowmanager/appPropertyCompatAllowUserAspectRatioOverrideOptIn/src/android/server/wm/allowuseraspectratiooverrideoptin/Components.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.server.wm.allowuseraspectratiooverrideoptin;
+
+import android.content.ComponentName;
+import android.server.wm.component.ComponentsBase;
+
+public class Components extends ComponentsBase {
+
+    /** Activity in the app with application level component property. */
+    public static final ComponentName ALLOW_USER_ASPECT_RATIO_OVERRIDE_OPT_IN_ACTIVITY =
+            component(Components.class, "AllowUserAspectRatioOverrideOptInActivity");
+
+}
diff --git a/tests/framework/base/windowmanager/appPropertyCompatAllowUserAspectRatioOverrideOptOut/Android.bp b/tests/framework/base/windowmanager/appPropertyCompatAllowUserAspectRatioOverrideOptOut/Android.bp
new file mode 100644
index 0000000..5eebff8
--- /dev/null
+++ b/tests/framework/base/windowmanager/appPropertyCompatAllowUserAspectRatioOverrideOptOut/Android.bp
@@ -0,0 +1,34 @@
+// Copyright (C) 2024 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package {
+    default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
+android_test {
+    name: "CtsPropertyCompatAllowUserAspectRatioOverrideOptOutApp",
+    defaults: ["cts_support_defaults"],
+
+    static_libs: ["cts-wm-app-base"],
+
+    srcs: ["src/**/*.java"],
+
+    sdk_version: "test_current",
+
+    test_suites: [
+        "cts",
+        "general-tests",
+        "sts",
+    ],
+}
diff --git a/tests/framework/base/windowmanager/appPropertyCompatAllowUserAspectRatioOverrideOptOut/AndroidManifest.xml b/tests/framework/base/windowmanager/appPropertyCompatAllowUserAspectRatioOverrideOptOut/AndroidManifest.xml
new file mode 100644
index 0000000..49116aa
--- /dev/null
+++ b/tests/framework/base/windowmanager/appPropertyCompatAllowUserAspectRatioOverrideOptOut/AndroidManifest.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+     Copyright (C) 2024 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+          package="android.server.wm.allowuseraspectratiooverrideoptout">
+
+    <application android:debuggable="true">
+
+        <property android:name="android.window.PROPERTY_COMPAT_ALLOW_USER_ASPECT_RATIO_OVERRIDE"
+                  android:value="false"/>
+
+        <activity android:name=".AllowUserAspectRatioOverrideOptOutActivity"
+                  android:exported="true"/>
+
+    </application>
+
+</manifest>
\ No newline at end of file
diff --git a/tests/framework/base/windowmanager/appPropertyCompatAllowUserAspectRatioOverrideOptOut/src/android/server/wm/allowuseraspectratiooverrideoptout/AllowUserAspectRatioOverrideOptOutActivity.java b/tests/framework/base/windowmanager/appPropertyCompatAllowUserAspectRatioOverrideOptOut/src/android/server/wm/allowuseraspectratiooverrideoptout/AllowUserAspectRatioOverrideOptOutActivity.java
new file mode 100644
index 0000000..2d4f75a
--- /dev/null
+++ b/tests/framework/base/windowmanager/appPropertyCompatAllowUserAspectRatioOverrideOptOut/src/android/server/wm/allowuseraspectratiooverrideoptout/AllowUserAspectRatioOverrideOptOutActivity.java
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.server.wm.allowuseraspectratiooverrideoptout;
+
+import android.app.Activity;
+
+public class AllowUserAspectRatioOverrideOptOutActivity extends Activity {
+}
diff --git a/tests/framework/base/windowmanager/appPropertyCompatAllowUserAspectRatioOverrideOptOut/src/android/server/wm/allowuseraspectratiooverrideoptout/Components.java b/tests/framework/base/windowmanager/appPropertyCompatAllowUserAspectRatioOverrideOptOut/src/android/server/wm/allowuseraspectratiooverrideoptout/Components.java
new file mode 100644
index 0000000..01a9652
--- /dev/null
+++ b/tests/framework/base/windowmanager/appPropertyCompatAllowUserAspectRatioOverrideOptOut/src/android/server/wm/allowuseraspectratiooverrideoptout/Components.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.server.wm.allowuseraspectratiooverrideoptout;
+
+import android.content.ComponentName;
+import android.server.wm.component.ComponentsBase;
+
+public class Components extends ComponentsBase {
+
+    /** Activity in the app with application level component property. */
+    public static final ComponentName ALLOW_USER_ASPECT_RATIO_OVERRIDE_OPT_OUT_ACTIVITY =
+            component(Components.class, "AllowUserAspectRatioOverrideOptOutActivity");
+
+}
diff --git a/tests/framework/base/windowmanager/src/android/server/wm/display/CompatChangeTests.java b/tests/framework/base/windowmanager/src/android/server/wm/display/CompatChangeTests.java
index 562f874..e279a3b 100644
--- a/tests/framework/base/windowmanager/src/android/server/wm/display/CompatChangeTests.java
+++ b/tests/framework/base/windowmanager/src/android/server/wm/display/CompatChangeTests.java
@@ -46,6 +46,8 @@
 import static android.server.wm.allowsandboxingviewboundsapis.Components.ACTION_TEST_VIEW_SANDBOX_NOT_ALLOWED_PASSED;
 import static android.server.wm.allowsandboxingviewboundsapis.Components.TEST_VIEW_SANDBOX_ALLOWED_ACTIVITY;
 import static android.server.wm.allowsandboxingviewboundsapis.Components.TEST_VIEW_SANDBOX_ALLOWED_TIMEOUT_MS;
+import static android.server.wm.allowuseraspectratiooverrideoptin.Components.ALLOW_USER_ASPECT_RATIO_OVERRIDE_OPT_IN_ACTIVITY;
+import static android.server.wm.allowuseraspectratiooverrideoptout.Components.ALLOW_USER_ASPECT_RATIO_OVERRIDE_OPT_OUT_ACTIVITY;
 import static android.server.wm.enablefakefocusoptin.Components.ENABLE_FAKE_FOCUS_OPT_IN_LEFT_ACTIVITY;
 import static android.server.wm.enablefakefocusoptin.Components.ENABLE_FAKE_FOCUS_OPT_IN_RIGHT_ACTIVITY;
 import static android.server.wm.enablefakefocusoptout.Components.ENABLE_FAKE_FOCUS_OPT_OUT_LEFT_ACTIVITY;
@@ -70,6 +72,7 @@
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
+import static org.junit.Assume.assumeFalse;
 import static org.junit.Assume.assumeTrue;
 
 import android.app.Activity;
@@ -1299,6 +1302,124 @@
         }
     }
 
+    /**
+     * Test that the user aspect ratio settings are enabled when {@link
+     * android.view.WindowManager#PROPERTY_COMPAT_ALLOW_USER_ASPECT_RATIO_OVERRIDE} is set to true
+     * and {@link com.android.internal.R.bool.config_appCompatUserAppAspectRatioSettingsIsEnabled}
+     * is true.
+     */
+    @Test
+    @ApiTest(apis = {"android.view.WindowManager#PROPERTY_COMPAT_ALLOW_USER_ASPECT_RATIO_OVERRIDE"})
+    @RequiresFlagsEnabled(Flags.FLAG_APP_COMPAT_PROPERTIES_API)
+    public void testAllowUserAspectRatioSettings_propertyTrue_configEnabled_overrideAllowed() {
+        assumeTrue("Skipping test: config_appCompatUserAppAspectRatioSettingsIsEnabled not enabled",
+                isUserAppAspectRatioSettingsIsEnabled());
+
+        try (var session = new ActivitySessionCloseable(
+                ALLOW_USER_ASPECT_RATIO_OVERRIDE_OPT_IN_ACTIVITY)) {
+            assertTrue(session.getActivityState().getShouldEnableUserAspectRatioSettings());
+        }
+    }
+
+    /**
+     * Test that the user aspect ratio settings are disabled when {@link
+     * android.view.WindowManager#PROPERTY_COMPAT_ALLOW_USER_ASPECT_RATIO_OVERRIDE} is set to true
+     * but {@link com.android.internal.R.bool.config_appCompatUserAppAspectRatioSettingsIsEnabled}
+     * is false.
+     */
+    @Test
+    @ApiTest(apis = {"android.view.WindowManager#PROPERTY_COMPAT_ALLOW_USER_ASPECT_RATIO_OVERRIDE"})
+    @RequiresFlagsEnabled(Flags.FLAG_APP_COMPAT_PROPERTIES_API)
+    public void testAllowUserAspectRatioSettings_propertyTrue_configDisabled_overrideNotAllowed() {
+        assumeFalse("Skipping test: config_appCompatUserAppAspectRatioSettingsIsEnabled is enabled",
+                isUserAppAspectRatioSettingsIsEnabled());
+
+        try (var session = new ActivitySessionCloseable(
+                ALLOW_USER_ASPECT_RATIO_OVERRIDE_OPT_IN_ACTIVITY)) {
+            assertFalse(session.getActivityState().getShouldEnableUserAspectRatioSettings());
+        }
+    }
+
+    /**
+     * Test that the user aspect ratio settings are disabled when {@link
+     * android.view.WindowManager#PROPERTY_COMPAT_ALLOW_USER_ASPECT_RATIO_OVERRIDE} is set to false
+     * but {@link com.android.internal.R.bool.config_appCompatUserAppAspectRatioSettingsIsEnabled}
+     * is true.
+     */
+    @Test
+    @ApiTest(apis = {"android.view.WindowManager#PROPERTY_COMPAT_ALLOW_USER_ASPECT_RATIO_OVERRIDE"})
+    @RequiresFlagsEnabled(Flags.FLAG_APP_COMPAT_PROPERTIES_API)
+    public void testAllowUserAspectRatioSettings_propertyFalse_configEnabled_overrideNotAllowed() {
+        assumeTrue("Skipping test: config_appCompatUserAppAspectRatioSettingsIsEnabled not enabled",
+                isUserAppAspectRatioSettingsIsEnabled());
+
+        try (var session = new ActivitySessionCloseable(
+                ALLOW_USER_ASPECT_RATIO_OVERRIDE_OPT_OUT_ACTIVITY)) {
+            assertFalse(session.getActivityState().getShouldEnableUserAspectRatioSettings());
+        }
+    }
+
+    /**
+     * Test that the user aspect ratio settings are disabled when {@link
+     * android.view.WindowManager#PROPERTY_COMPAT_ALLOW_USER_ASPECT_RATIO_OVERRIDE} is set to false
+     * and {@link com.android.internal.R.bool.config_appCompatUserAppAspectRatioSettingsIsEnabled}
+     * is false.
+     */
+    @Test
+    @ApiTest(apis = {"android.view.WindowManager#PROPERTY_COMPAT_ALLOW_USER_ASPECT_RATIO_OVERRIDE"})
+    @RequiresFlagsEnabled(Flags.FLAG_APP_COMPAT_PROPERTIES_API)
+    public void testAllowUserAspectRatioSettings_propertyFalse_configDisabled_overrideNotAllowed() {
+        assumeFalse("Skipping test: config_appCompatUserAppAspectRatioSettingsIsEnabled is enabled",
+                isUserAppAspectRatioSettingsIsEnabled());
+
+        try (var session = new ActivitySessionCloseable(
+                ALLOW_USER_ASPECT_RATIO_OVERRIDE_OPT_OUT_ACTIVITY)) {
+            assertFalse(session.getActivityState().getShouldEnableUserAspectRatioSettings());
+        }
+    }
+
+    /**
+     * Test that the user aspect ratio settings are enabled when {@link
+     * android.view.WindowManager#PROPERTY_COMPAT_ALLOW_USER_ASPECT_RATIO_OVERRIDE} is unset and
+     * {@link com.android.internal.R.bool.config_appCompatUserAppAspectRatioSettingsIsEnabled}
+     * is true.
+     */
+    @Test
+    @ApiTest(apis = {"android.view.WindowManager#PROPERTY_COMPAT_ALLOW_USER_ASPECT_RATIO_OVERRIDE"})
+    @RequiresFlagsEnabled(Flags.FLAG_APP_COMPAT_PROPERTIES_API)
+    public void testAllowUserAspectRatioSettings_propertyUnset_configEnabled_overrideAllowed() {
+        assumeTrue("Skipping test: config_appCompatUserAppAspectRatioSettingsIsEnabled not enabled",
+                isUserAppAspectRatioSettingsIsEnabled());
+
+        try (var session = new ActivitySessionCloseable(
+                NON_RESIZEABLE_NON_FIXED_ORIENTATION_ACTIVITY)) {
+            assertTrue(session.getActivityState().getShouldEnableUserAspectRatioSettings());
+        }
+    }
+
+    /**
+     * Test that the user aspect ratio settings are disabled when {@link
+     * android.view.WindowManager#PROPERTY_COMPAT_ALLOW_USER_ASPECT_RATIO_OVERRIDE} is unset but
+     * {@link com.android.internal.R.bool.config_appCompatUserAppAspectRatioSettingsIsEnabled}
+     * is false.
+     */
+    @Test
+    @ApiTest(apis = {"android.view.WindowManager#PROPERTY_COMPAT_ALLOW_USER_ASPECT_RATIO_OVERRIDE"})
+    @RequiresFlagsEnabled(Flags.FLAG_APP_COMPAT_PROPERTIES_API)
+    public void testAllowUserAspectRatioSettings_propertyUnset_configDisabled_overrideNotAllowed() {
+        assumeFalse("Skipping test: config_appCompatUserAppAspectRatioSettingsIsEnabled is enabled",
+                isUserAppAspectRatioSettingsIsEnabled());
+
+        try (var session = new ActivitySessionCloseable(
+                NON_RESIZEABLE_NON_FIXED_ORIENTATION_ACTIVITY)) {
+            assertFalse(session.getActivityState().getShouldEnableUserAspectRatioSettings());
+        }
+    }
+
+    private boolean isUserAppAspectRatioSettingsIsEnabled() {
+        return getBooleanConfig("config_appCompatUserAppAspectRatioSettingsIsEnabled");
+    }
+
     private boolean isCameraCompatForceRotationTreatmentConfigEnabled() {
         return getBooleanConfig("config_isWindowManagerCameraCompatTreatmentEnabled");
     }
diff --git a/tests/framework/base/windowmanager/util/src/android/server/wm/WindowManagerState.java b/tests/framework/base/windowmanager/util/src/android/server/wm/WindowManagerState.java
index baf1537..7a49e25 100644
--- a/tests/framework/base/windowmanager/util/src/android/server/wm/WindowManagerState.java
+++ b/tests/framework/base/windowmanager/util/src/android/server/wm/WindowManagerState.java
@@ -1736,6 +1736,7 @@
         private boolean mShouldOverrideMinAspectRatio;
         private boolean mShouldIgnoreOrientationRequestLoop;
         private boolean mShouldOverrideForceResizeApp;
+        private boolean mShouldEnableUserAspectRatioSettings;
 
         Activity(ActivityRecordProto proto, WindowContainer parent) {
             super(proto.windowToken.windowContainer);
@@ -1763,6 +1764,7 @@
             mShouldOverrideMinAspectRatio = proto.shouldOverrideMinAspectRatio;
             mShouldIgnoreOrientationRequestLoop = proto.shouldIgnoreOrientationRequestLoop;
             mShouldOverrideForceResizeApp = proto.shouldOverrideForceResizeApp;
+            mShouldEnableUserAspectRatioSettings = proto.shouldEnableUserAspectRatioSettings;
         }
 
         @NonNull
@@ -1849,6 +1851,11 @@
             return mShouldOverrideForceResizeApp;
         }
 
+        public boolean getShouldEnableUserAspectRatioSettings() {
+            return mShouldEnableUserAspectRatioSettings;
+        }
+
+
         @Override
         public Rect getBounds() {
             if (mBounds == null) {