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

Commit ce01d291 authored by Dan Pasanen's avatar Dan Pasanen Committed by Gerrit Code Review
Browse files

SystemUI: fix toggling lockscreen rotation [1/3]

Change-Id: I28fea0124c91b8efc206a940761e77fa61d1fefc
parent ce709c9f
Loading
Loading
Loading
Loading
+20 −5
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.graphics.Point;
import android.graphics.PixelFormat;
import android.os.Handler;
import android.os.SystemProperties;
import android.provider.Settings;
import android.view.Gravity;
import android.view.Display;
import android.view.SurfaceSession;
@@ -54,7 +55,7 @@ public class StatusBarWindowManager implements KeyguardMonitor.Callback {
    private WindowManager.LayoutParams mLp;
    private WindowManager.LayoutParams mLpChanged;
    private int mBarHeight;
    private final boolean mKeyguardScreenRotation;
    private boolean mKeyguardScreenRotation;
    private final float mScreenBrightnessDoze;

    private boolean mKeyguardBlurEnabled;
@@ -86,8 +87,13 @@ public class StatusBarWindowManager implements KeyguardMonitor.Callback {

    private boolean shouldEnableKeyguardScreenRotation() {
        Resources res = mContext.getResources();
        boolean enableAccelerometerRotation = Settings.System.getInt(mContext.getContentResolver(),
                Settings.System.ACCELEROMETER_ROTATION, 1) != 0;
        boolean enableLockScreenRotation = CMSettings.System.getInt(mContext.getContentResolver(),
                CMSettings.System.LOCKSCREEN_ROTATION, 0) != 0;
        return SystemProperties.getBoolean("lockscreen.rot_override", false)
                || res.getBoolean(R.bool.config_enableLockScreenRotation);
                || (res.getBoolean(R.bool.config_enableLockScreenRotation)
                && (enableLockScreenRotation && enableAccelerometerRotation));
    }

    /**
@@ -133,11 +139,11 @@ public class StatusBarWindowManager implements KeyguardMonitor.Callback {
            if (mKeyguardBlur != null) {
                mKeyguardBlur.setLayer(STATUS_BAR_LAYER - 2);
            }
        }

        SettingsObserver observer = new SettingsObserver(new Handler());
        observer.observe(mContext);
    }
    }

    private void applyKeyguardFlags(State state) {
        if (state.keyguardShowing) {
@@ -468,6 +474,14 @@ public class StatusBarWindowManager implements KeyguardMonitor.Callback {
                    CMSettings.Secure.getUriFor(CMSettings.Secure.LOCK_SCREEN_BLUR_ENABLED),
                    false,
                    this);
            context.getContentResolver().registerContentObserver(
                    Settings.System.getUriFor(Settings.System.ACCELEROMETER_ROTATION),
                    false,
                    this);
            context.getContentResolver().registerContentObserver(
                    CMSettings.System.getUriFor(CMSettings.System.LOCKSCREEN_ROTATION),
                    false,
                    this);
        }

        public void unobserve(Context context) {
@@ -479,6 +493,7 @@ public class StatusBarWindowManager implements KeyguardMonitor.Callback {
            // default to being enabled since we are here because the blur config was set to true
            mKeyguardBlurEnabled = CMSettings.Secure.getInt(mContext.getContentResolver(),
                    CMSettings.Secure.LOCK_SCREEN_BLUR_ENABLED, 1) == 1;
            mKeyguardScreenRotation = shouldEnableKeyguardScreenRotation();
            // update the state
            apply(mCurrentState);
        }