diff options
| -rw-r--r-- | core/java/com/android/internal/view/RotationPolicy.java | 9 | ||||
| -rw-r--r-- | core/res/res/values/config.xml | 4 | ||||
| -rw-r--r-- | core/res/res/values/symbols.xml | 1 |
3 files changed, 13 insertions, 1 deletions
diff --git a/core/java/com/android/internal/view/RotationPolicy.java b/core/java/com/android/internal/view/RotationPolicy.java index 869da1ffcb6e..058c6ec4d13c 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 6d21fb657a88..0e2dcf3e439e 100644 --- a/core/res/res/values/config.xml +++ b/core/res/res/values/config.xml @@ -560,6 +560,10 @@ rotations as the default behavior. --> <bool name="config_allowAllRotations">false</bool> + <!-- If false and config_allowAllRotations is false, the screen will rotate to the natural + orientation of the device when the auto-rotate policy is toggled. --> + <bool name="config_useCurrentRotationOnRotationLockChange">false</bool> + <!-- If true, the direction rotation is applied to get to an application's requested orientation is reversed. Normally, the model is that landscape is clockwise from portrait; thus on a portrait device an app requesting diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index 2abb0d89835b..2f73dfbf9e33 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -1668,6 +1668,7 @@ <java-symbol type="attr" name="dialogTitleDecorLayout" /> <java-symbol type="attr" name="dialogTitleIconsDecorLayout" /> <java-symbol type="bool" name="config_allowAllRotations" /> + <java-symbol type="bool" name="config_useCurrentRotationOnRotationLockChange"/> <java-symbol type="bool" name="config_annoy_dianne" /> <java-symbol type="bool" name="config_startDreamImmediatelyOnDock" /> <java-symbol type="bool" name="config_carDockEnablesAccelerometer" /> |