Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0a50b350 authored by Will Osborn's avatar Will Osborn
Browse files

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
parent 78108c10
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -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
+4 −0
Original line number Diff line number Diff line
@@ -576,6 +576,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
+1 −0
Original line number Diff line number Diff line
@@ -1732,6 +1732,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" />