summaryrefslogtreecommitdiffstats
path: root/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
diff options
context:
space:
mode:
authorWolfgang Wiedmeyer <wolfgit@wiedmeyer.de>2016-01-14 22:13:02 +0100
committerWolfgang Wiedmeyer <wolfgit@wiedmeyer.de>2016-01-14 22:13:02 +0100
commit69a68b55dfbb1603ca549610bfd14dd4698a3c67 (patch)
tree28c1bcec9bd0af829cd642df8fddc54032ad5730 /packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
parent85e8acfb6b7f12598c11ca6f88b06407de32db90 (diff)
parent0f4b580ed9af38dabb217e4cb843c0b0acf210ee (diff)
downloadframeworks_base-7dcac68b2bd4ec4f57af73ec22bd22305430f441.zip
frameworks_base-7dcac68b2bd4ec4f57af73ec22bd22305430f441.tar.gz
frameworks_base-7dcac68b2bd4ec4f57af73ec22bd22305430f441.tar.bz2
Merge branch 'cm-13.0' of https://github.com/CyanogenMod/android_frameworks_base into replicant-6.0replicant-6.0-alpha-0001
Diffstat (limited to 'packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java')
-rwxr-xr-xpackages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java70
1 files changed, 67 insertions, 3 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
index 0957316..8555ef0 100755
--- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
@@ -30,7 +30,9 @@ import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
+import android.content.SharedPreferences;
import android.content.pm.UserInfo;
+import android.database.ContentObserver;
import android.media.AudioManager;
import android.media.SoundPool;
import android.os.Bundle;
@@ -57,6 +59,7 @@ import android.view.WindowManagerPolicy;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
+import com.android.systemui.cm.UserContentObserver;
import com.android.systemui.qs.tiles.LockscreenToggleTile;
import cyanogenmod.app.Profile;
import cyanogenmod.app.ProfileManager;
@@ -78,6 +81,7 @@ import com.android.systemui.statusbar.phone.PhoneStatusBar;
import com.android.systemui.statusbar.phone.ScrimController;
import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager;
import com.android.systemui.statusbar.phone.StatusBarWindowManager;
+import cyanogenmod.providers.CMSettings;
import java.io.FileDescriptor;
import java.io.PrintWriter;
@@ -343,6 +347,50 @@ public class KeyguardViewMediator extends SystemUI {
private boolean mWakeAndUnlocking;
private IKeyguardDrawnCallback mDrawnCallback;
+ private LockscreenEnabledSettingsObserver mSettingsObserver;
+ public static class LockscreenEnabledSettingsObserver extends UserContentObserver {
+
+ private static final String KEY_ENABLED = "lockscreen_enabled";
+
+ private boolean mObserving;
+ private SharedPreferences mPrefs;
+ private Context mContext;
+
+ public LockscreenEnabledSettingsObserver(Context context, Handler handler) {
+ super(handler);
+ mContext = context;
+ mPrefs = mContext.getSharedPreferences("quicksettings", Context.MODE_PRIVATE);
+ }
+
+ public boolean getPersistedDefaultOldSetting() {
+ return mPrefs.getBoolean(KEY_ENABLED, true);
+ }
+
+ @Override
+ public void observe() {
+ if (mObserving) {
+ return;
+ }
+ mObserving = true;
+ mContext.getContentResolver().registerContentObserver(CMSettings.Secure.getUriFor(
+ CMSettings.Secure.LOCKSCREEN_INTERNALLY_ENABLED), false, this,
+ UserHandle.USER_ALL);
+ update();
+ }
+
+ @Override
+ public void unobserve() {
+ if (mObserving) {
+ mObserving = false;
+ mContext.getContentResolver().unregisterContentObserver(this);
+ }
+ }
+
+ @Override
+ public void update() {
+ }
+ }
+
KeyguardUpdateMonitorCallback mUpdateCallback = new KeyguardUpdateMonitorCallback() {
@Override
@@ -634,6 +682,20 @@ public class KeyguardViewMediator extends SystemUI {
mHideAnimation = AnimationUtils.loadAnimation(mContext,
com.android.internal.R.anim.lock_screen_behind_enter);
+
+ mSettingsObserver = new LockscreenEnabledSettingsObserver(mContext, new Handler()) {
+ @Override
+ public void update() {
+ boolean newDisabledState = CMSettings.Secure.getIntForUser(mContext.getContentResolver(),
+ CMSettings.Secure.LOCKSCREEN_INTERNALLY_ENABLED,
+ getPersistedDefaultOldSetting() ? 1 : 0,
+ UserHandle.USER_CURRENT) == 0;
+ if (newDisabledState != mInternallyDisabled && mKeyguardBound) {
+ // it was updated,
+ setKeyguardEnabledInternal(!newDisabledState);
+ }
+ }
+ };
}
@Override
@@ -1298,9 +1360,11 @@ public class KeyguardViewMediator extends SystemUI {
}
} else if (KEYGUARD_SERVICE_ACTION_STATE_CHANGE.equals(intent.getAction())) {
mKeyguardBound = intent.getBooleanExtra(KEYGUARD_SERVICE_EXTRA_ACTIVE, false);
- context.sendBroadcast(new Intent(
- LockscreenToggleTile.ACTION_APPLY_LOCKSCREEN_STATE)
- .setPackage(context.getPackageName()));
+ if (mKeyguardBound) {
+ mSettingsObserver.observe();
+ } else {
+ mSettingsObserver.unobserve();
+ }
}
}
};