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

Commit 6e15c2a8 authored by Mike Digman's avatar Mike Digman Committed by Android (Google) Code Review
Browse files

Merge "Extend RotationPolicy to lock the screen at a specific rotation"

parents 0d79306b 6ca8711b
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -108,11 +108,19 @@ 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;
        setRotationLockAtAngle(context, enabled, rotation);
    }

    /**
     * Enables or disables rotation lock at a specific rotation from system UI.
     */
    public static void setRotationLockAtAngle(Context context, final boolean enabled,
            final int rotation) {
        Settings.System.putIntForUser(context.getContentResolver(),
                Settings.System.HIDE_ROTATION_LOCK_TOGGLE_FOR_ACCESSIBILITY, 0,
                UserHandle.USER_CURRENT);

        final int rotation = areAllRotationsAllowed(context) ? CURRENT_ROTATION : NATURAL_ROTATION;
        setRotationLock(enabled, rotation);
    }

+1 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ public interface RotationLockController extends Listenable,
    boolean isRotationLockAffordanceVisible();
    boolean isRotationLocked();
    void setRotationLocked(boolean locked);
    void setRotationLockedAtAngle(boolean locked, int rotation);

    public interface RotationLockControllerCallback {
        void onRotationLockStateChanged(boolean rotationLocked, boolean affordanceVisible);
+4 −0
Original line number Diff line number Diff line
@@ -63,6 +63,10 @@ public final class RotationLockControllerImpl implements RotationLockController
        RotationPolicy.setRotationLock(mContext, locked);
    }

    public void setRotationLockedAtAngle(boolean locked, int rotation){
        RotationPolicy.setRotationLockAtAngle(mContext, locked, rotation);
    }

    public boolean isRotationLockAffordanceVisible() {
        return RotationPolicy.isRotationLockToggleVisible(mContext);
    }
+5 −0
Original line number Diff line number Diff line
@@ -49,4 +49,9 @@ public class FakeRotationLockController extends BaseLeakChecker<RotationLockCont
    public void setRotationLocked(boolean locked) {

    }

    @Override
    public void setRotationLockedAtAngle(boolean locked, int rotation) {

    }
}