diff options
author | 2024-11-27 10:22:26 +0000 | |
---|---|---|
committer | 2024-11-27 10:22:26 +0000 | |
commit | 4e46533a41bcda2f5891b24bda513e4eb974ebbb (patch) | |
tree | ebca6003cba737d41a2cd06387d44c1762b679b4 | |
parent | 2af6f148556b5c67d5b9ef96f46d3432d774a71d (diff) | |
parent | a0e65ae391f88ddf1646278053ca3a20a45fcdda (diff) |
Merge "Activity orientation experiment on only large screens" into main
4 files changed, 28 insertions, 13 deletions
diff --git a/services/core/java/com/android/server/wm/ActivityRecord.java b/services/core/java/com/android/server/wm/ActivityRecord.java index ef33ffe509b3..776bf537837a 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 class ActivityRecord extends WindowToken implements WindowManagerService.A } 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 31ca24c46f4b..3ad9b62ef058 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 @@ import java.util.concurrent.Executor; */ 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 @@ final class WindowManagerConstants { 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 @@ final class WindowManagerConstants { } 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 @@ final class WindowManagerConstants { } boolean isPackageOptOutIgnoreActivityOrientationRequest(String packageName) { - return mIgnoreActivityOrientationRequest - && mOptOutIgnoreActivityOrientationRequestPackages != null + return mOptOutIgnoreActivityOrientationRequestPackages != null && mOptOutIgnoreActivityOrientationRequestPackages.contains(packageName); } @@ -211,7 +222,8 @@ final class WindowManagerConstants { 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 fee646d9cb9c..d4a921c5f00a 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 @@ public class ActivityRecordTests extends WindowTestsBase { 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 87db6c0e8577..bf96f0eb03b8 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 @@ public class SizeCompatTests extends WindowTestsBase { @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; |