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

Commit 44f615c4 authored by Roman Birg's avatar Roman Birg Committed by Gerrit Code Review
Browse files

Revert "RotationPolicy: fix rotation toggle logic"

Breaks landscape rotation lock for some devices.

Ref: CYNGNOS-1163

This reverts commit be2d4a12.

Change-Id: I552c0a25cd547343400c4b78971b25d3f3193d7a
parent 4664f66b
Loading
Loading
Loading
Loading
+14 −4
Original line number Diff line number Diff line
@@ -74,7 +74,7 @@ public final class RotationPolicy {
     * otherwise Configuration.ORIENTATION_UNDEFINED if any orientation is lockable.
     */
    public static int getRotationLockOrientation(Context context) {
        if (!areAllRotationsAllowed(context)) {
        if (!isCurrentRotationAllowed(context)) {
            final Point size = new Point();
            final IWindowManager wm = WindowManagerGlobal.getWindowManagerService();
            try {
@@ -114,7 +114,7 @@ public final class RotationPolicy {
                Settings.System.HIDE_ROTATION_LOCK_TOGGLE_FOR_ACCESSIBILITY, 0,
                UserHandle.USER_CURRENT);

        final int rotation = areAllRotationsAllowed(context)
        final int rotation = isCurrentRotationAllowed(context)
                ? CURRENT_ROTATION : NATURAL_ROTATION;
        setRotationLock(enabled, rotation);
    }
@@ -153,8 +153,18 @@ public final class RotationPolicy {
        return false;
    }

    private static boolean areAllRotationsAllowed(Context context) {
        return context.getResources().getBoolean(R.bool.config_allowAllRotations);
    private static boolean isCurrentRotationAllowed(Context context) {
        int userRotationAngles = Settings.System.getInt(context.getContentResolver(),
                Settings.System.ACCELEROMETER_ROTATION_ANGLES, -1);
        boolean allowAllRotations = context.getResources().getBoolean(
                com.android.internal.R.bool.config_allowAllRotations);
        final IWindowManager wm = WindowManagerGlobal.getWindowManagerService();
        try {
            return isRotationAllowed(wm.getRotation(), userRotationAngles, allowAllRotations);
        } catch (RemoteException exc) {
            Log.w(TAG, "Unable to getWindowManagerService.getRotation()");
        }
        return false;
    }

    private static void setRotationLock(final boolean enabled, final int rotation) {