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

Commit fc463c44 authored by Steve Kondik's avatar Steve Kondik
Browse files

Obey 180-rotation API, but allow override by system property.

Change-Id: Icf210b73e0be8ee8067b765bfe65f21ef31f070d
parent 9952cddd
Loading
Loading
Loading
Loading
+6 −3
Original line number Original line Diff line number Diff line
@@ -270,6 +270,8 @@ public abstract class WindowOrientationListener {
        private static final float ACCELERATING_LOWPASS_ALPHA =
        private static final float ACCELERATING_LOWPASS_ALPHA =
            computeLowpassAlpha(ACCELERATING_TIME_CONSTANT_MS);
            computeLowpassAlpha(ACCELERATING_TIME_CONSTANT_MS);


        private boolean mAllow180Rotation = false;

        private WindowOrientationListener mOrientationListener;
        private WindowOrientationListener mOrientationListener;
        private int mRotation = ROTATION_0; // Current orientation state
        private int mRotation = ROTATION_0; // Current orientation state
        private float mTiltAngle = 0; // low-pass filtered
        private float mTiltAngle = 0; // low-pass filtered
@@ -292,7 +294,7 @@ public abstract class WindowOrientationListener {
        }
        }


        void setAllow180Rotation(boolean allowed) {
        void setAllow180Rotation(boolean allowed) {
            // deprecated since ACCELEROMETER_ROTATE_180 in Settings is added
            mAllow180Rotation = allowed;
        }
        }


        int getCurrentRotation(int lastRotation) {
        int getCurrentRotation(int lastRotation) {
@@ -305,7 +307,8 @@ public abstract class WindowOrientationListener {


        private void calculateNewRotation(float orientation, float tiltAngle) {
        private void calculateNewRotation(float orientation, float tiltAngle) {
            if (localLOGV) Log.i(TAG, orientation + ", " + tiltAngle + ", " + mRotation);
            if (localLOGV) Log.i(TAG, orientation + ", " + tiltAngle + ", " + mRotation);
            boolean allow180Rotation = (Settings.System.getInt(mContext.getContentResolver(),
            final boolean allow180Rotation = mAllow180Rotation ||
                    (Settings.System.getInt(mContext.getContentResolver(),
                                            Settings.System.ACCELEROMETER_ROTATE_180, 0) != 0);
                                            Settings.System.ACCELEROMETER_ROTATE_180, 0) != 0);
            int thresholdRanges[][] = allow180Rotation
            int thresholdRanges[][] = allow180Rotation
                    ? THRESHOLDS_WITH_180[mRotation] : THRESHOLDS[mRotation];
                    ? THRESHOLDS_WITH_180[mRotation] : THRESHOLDS[mRotation];