diff options
author | Roman Birg <roman@cyngn.com> | 2016-02-08 15:59:34 -0800 |
---|---|---|
committer | Roman Birg <roman@cyngn.com> | 2016-02-08 18:45:18 -0800 |
commit | 61cdfc02db3594dca416b96548a39da552b44b5a (patch) | |
tree | fd5559ecfd705508644698cd85ae9b6963909c02 /packages/SystemUI/src/com/android/systemui/qs | |
parent | deb5c35ebe59b0ca822b93fbc80df3054f7589da (diff) | |
download | frameworks_base-61cdfc02db3594dca416b96548a39da552b44b5a.zip frameworks_base-61cdfc02db3594dca416b96548a39da552b44b5a.tar.gz frameworks_base-61cdfc02db3594dca416b96548a39da552b44b5a.tar.bz2 |
SystemUI: improve lockscreen tile behavior with profiles
Disable (grey out) the lock screen tile when a profile is already
disabling it. Profiles takes precedence over the internal setting.
Also simplify lockscreen disable logic - using a null'd Boolean without
synchonization will lead to things falling out of place.
Ref: CYNGNOS-1930
Change-Id: Ia4cb7926e418a4d72426be65e5bfb11dc44bee5e
Signed-off-by: Roman Birg <roman@cyngn.com>
Diffstat (limited to 'packages/SystemUI/src/com/android/systemui/qs')
-rw-r--r-- | packages/SystemUI/src/com/android/systemui/qs/tiles/LockscreenToggleTile.java | 67 |
1 files changed, 40 insertions, 27 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/LockscreenToggleTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/LockscreenToggleTile.java index 2d764ba..a24c249 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/LockscreenToggleTile.java +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/LockscreenToggleTile.java @@ -23,6 +23,9 @@ import com.android.systemui.SystemUIApplication; import com.android.systemui.keyguard.KeyguardViewMediator; import com.android.systemui.qs.QSTile; import com.android.systemui.statusbar.policy.KeyguardMonitor; + +import cyanogenmod.app.Profile; +import cyanogenmod.app.ProfileManager; import cyanogenmod.providers.CMSettings; import org.cyanogenmod.internal.logging.CMMetricsLogger; @@ -32,7 +35,6 @@ public class LockscreenToggleTile extends QSTile<QSTile.BooleanState> private static final Intent LOCK_SCREEN_SETTINGS = new Intent("android.settings.LOCK_SCREEN_SETTINGS"); - private KeyguardViewMediator mKeyguardViewMediator; private KeyguardMonitor mKeyguard; private boolean mListening; @@ -42,21 +44,13 @@ public class LockscreenToggleTile extends QSTile<QSTile.BooleanState> super(host); mKeyguard = host.getKeyguardMonitor(); - mKeyguardViewMediator = - ((SystemUIApplication) - mContext.getApplicationContext()).getComponent(KeyguardViewMediator.class); mSettingsObserver = new KeyguardViewMediator.LockscreenEnabledSettingsObserver(mContext, mUiHandler) { @Override public void update() { - boolean newState = CMSettings.Secure.getIntForUser( - mContext.getContentResolver(), - CMSettings.Secure.LOCKSCREEN_INTERNALLY_ENABLED, - getPersistedDefaultOldSetting() ? 1 : 0, - UserHandle.USER_CURRENT) != 0; - refreshState(newState); + refreshState(); } }; @@ -97,24 +91,43 @@ public class LockscreenToggleTile extends QSTile<QSTile.BooleanState> @Override protected void handleUpdateState(BooleanState state, Object arg) { - final boolean lockscreenEnforced = mKeyguardViewMediator.lockscreenEnforcedByDevicePolicy(); - final boolean lockscreenEnabled = lockscreenEnforced || - arg != null ? (Boolean) arg : mKeyguardViewMediator.getKeyguardEnabledInternal(); - - state.value = lockscreenEnabled; - state.visible = mKeyguardViewMediator.isKeyguardBound(); - state.enabled = !mKeyguard.isShowing() || !mKeyguard.isSecure(); - state.label = mContext.getString(lockscreenEnforced - ? R.string.quick_settings_lockscreen_label_enforced - : R.string.quick_settings_lockscreen_label); - if (lockscreenEnabled) { - state.icon = ResourceIcon.get(R.drawable.ic_qs_lock_screen_on); - state.contentDescription = mContext.getString( - R.string.accessibility_quick_settings_lock_screen_on); + KeyguardViewMediator mediator = ((SystemUIApplication) + mContext.getApplicationContext()).getComponent(KeyguardViewMediator.class); + + if (mediator == null) { + state.visible = false; + state.value = false; + state.enabled = false; } else { - state.icon = ResourceIcon.get(R.drawable.ic_qs_lock_screen_off); - state.contentDescription = mContext.getString( - R.string.accessibility_quick_settings_lock_screen_off); + final boolean lockscreenEnforced = mediator.lockscreenEnforcedByDevicePolicy(); + final boolean lockscreenEnabled = lockscreenEnforced || + arg != null ? (Boolean) arg : mediator.getKeyguardEnabledInternal(); + + state.visible = mediator.isKeyguardBound(); + + if (mediator.isProfileDisablingKeyguard()) { + state.label = mContext.getString( + R.string.quick_settings_lockscreen_label_locked_by_profile); + state.value = false; + state.enabled = false; + } else { + state.value = lockscreenEnabled; + state.enabled = !mKeyguard.isShowing() || !mKeyguard.isSecure(); + + state.label = mContext.getString(lockscreenEnforced + ? R.string.quick_settings_lockscreen_label_enforced + : R.string.quick_settings_lockscreen_label); + } + // update icon + if (lockscreenEnabled) { + state.icon = ResourceIcon.get(R.drawable.ic_qs_lock_screen_on); + state.contentDescription = mContext.getString( + R.string.accessibility_quick_settings_lock_screen_on); + } else { + state.icon = ResourceIcon.get(R.drawable.ic_qs_lock_screen_off); + state.contentDescription = mContext.getString( + R.string.accessibility_quick_settings_lock_screen_off); + } } } |