From 0a50b3505ef3dc92efd8a2a3576881bb21b77455 Mon Sep 17 00:00:00 2001 From: Will Osborn Date: Mon, 9 Jan 2023 14:38:10 +0000 Subject: [PATCH] Allow rotations to portrait on unlocking when unfolded Bug: 261090028 Test: locally tested that 180 degree rotation is still not allowed Test: atest com.android.server.wm.DisplayPolicyTests Test: atest com.android.server.wm.DisplayRotationTests Change-Id: Ia4802a791a951d7accfcd99397e2f5514c26f054 --- core/java/com/android/internal/view/RotationPolicy.java | 9 ++++++++- core/res/res/values/config.xml | 4 ++++ core/res/res/values/symbols.xml | 1 + 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/core/java/com/android/internal/view/RotationPolicy.java b/core/java/com/android/internal/view/RotationPolicy.java index 869da1ffcb6ee..058c6ec4d13c7 100644 --- a/core/java/com/android/internal/view/RotationPolicy.java +++ b/core/java/com/android/internal/view/RotationPolicy.java @@ -106,7 +106,9 @@ public final class RotationPolicy { * Enables or disables rotation lock from the system UI toggle. */ public static void setRotationLock(Context context, final boolean enabled) { - final int rotation = areAllRotationsAllowed(context) ? CURRENT_ROTATION : NATURAL_ROTATION; + final int rotation = areAllRotationsAllowed(context) + || useCurrentRotationOnRotationLockChange(context) ? CURRENT_ROTATION + : NATURAL_ROTATION; setRotationLockAtAngle(context, enabled, rotation); } @@ -139,6 +141,11 @@ public final class RotationPolicy { return context.getResources().getBoolean(R.bool.config_allowAllRotations); } + private static boolean useCurrentRotationOnRotationLockChange(Context context) { + return context.getResources().getBoolean( + R.bool.config_useCurrentRotationOnRotationLockChange); + } + private static void setRotationLock(final boolean enabled, final int rotation) { AsyncTask.execute(new Runnable() { @Override diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml index 2f5efd12a2ba8..c759239bd5bdd 100644 --- a/core/res/res/values/config.xml +++ b/core/res/res/values/config.xml @@ -576,6 +576,10 @@ rotations as the default behavior. --> false + + false +