diff options
author | Dan Pasanen <invisiblek@cyanogenmod.org> | 2016-05-02 09:34:21 -0500 |
---|---|---|
committer | Gerrit Code Review <gerrit@cyanogenmod.org> | 2016-06-03 14:03:13 -0700 |
commit | ce01d2915e6b0b4a93c9c4ebc019ada93f526f12 (patch) | |
tree | 4695523f5599380be19d0bf4df58d34ffa5ef66f /packages/SystemUI/src | |
parent | ce709c9f22d500606d20c682298e937bd32e14d9 (diff) | |
download | frameworks_base-ce01d2915e6b0b4a93c9c4ebc019ada93f526f12.zip frameworks_base-ce01d2915e6b0b4a93c9c4ebc019ada93f526f12.tar.gz frameworks_base-ce01d2915e6b0b4a93c9c4ebc019ada93f526f12.tar.bz2 |
SystemUI: fix toggling lockscreen rotation [1/3]
Change-Id: I28fea0124c91b8efc206a940761e77fa61d1fefc
Diffstat (limited to 'packages/SystemUI/src')
-rw-r--r-- | packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowManager.java | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowManager.java index 4cb24bd..bbb56fe 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowManager.java @@ -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,10 +139,10 @@ public class StatusBarWindowManager implements KeyguardMonitor.Callback { if (mKeyguardBlur != null) { mKeyguardBlur.setLayer(STATUS_BAR_LAYER - 2); } - - SettingsObserver observer = new SettingsObserver(new Handler()); - observer.observe(mContext); } + + SettingsObserver observer = new SettingsObserver(new Handler()); + observer.observe(mContext); } private void applyKeyguardFlags(State state) { @@ -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); } |