diff options
author | Roman Birg <roman@cyngn.com> | 2015-02-04 14:00:23 -0800 |
---|---|---|
committer | Adnan Begovic <adnan@cyngn.com> | 2015-12-11 14:38:50 -0800 |
commit | 983986d12e6e9ac10bef05bd8f646907f314a7b1 (patch) | |
tree | 7c01a2cffcdc37a72e0ad477f2f112c5377704ae /packages/SystemUI/src/com | |
parent | 4601c9fda34494c2b5f9b34e328a560cc153b7d9 (diff) | |
download | frameworks_base-983986d12e6e9ac10bef05bd8f646907f314a7b1.zip frameworks_base-983986d12e6e9ac10bef05bd8f646907f314a7b1.tar.gz frameworks_base-983986d12e6e9ac10bef05bd8f646907f314a7b1.tar.bz2 |
SystemUI: improve lockscreen tile behavior
* Stay disabled when disabled
* No need to use Keyguard locks, use internal update monitor
Change-Id: I9e66458d5789aa45b933ca60643e049d932ce58b
Signed-off-by: Roman Birg <roman@cyngn.com>
Diffstat (limited to 'packages/SystemUI/src/com')
-rwxr-xr-x | packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java index ef326ec..0957316 100755 --- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java +++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java @@ -23,6 +23,7 @@ import android.app.AlarmManager; import android.app.PendingIntent; import android.app.SearchManager; import android.app.StatusBarManager; +import android.app.admin.DevicePolicyManager; import android.app.trust.TrustManager; import android.content.BroadcastReceiver; import android.content.ContentResolver; @@ -283,6 +284,11 @@ public class KeyguardViewMediator extends SystemUI { private boolean mHiding; /** + * Whether we are disabling the lock screen internally + */ + private boolean mInternallyDisabled = false; + + /** * we send this intent when the keyguard is dismissed. */ private static final Intent USER_PRESENT_INTENT = new Intent(Intent.ACTION_USER_PRESENT) @@ -870,6 +876,23 @@ public class KeyguardViewMediator extends SystemUI { } /** + * Set the internal keyguard enabled state. This allows SystemUI to disable the lockscreen, + * overriding any apps. + * @param enabled + */ + public void setKeyguardEnabledInternal(boolean enabled) { + mInternallyDisabled = !enabled; + setKeyguardEnabled(enabled); + if (mInternallyDisabled) { + mNeedToReshowWhenReenabled = false; + } + } + + public boolean getKeyguardEnabledInternal() { + return !mInternallyDisabled; + } + + /** * Same semantics as {@link android.view.WindowManagerPolicy#enableKeyguard}; provide * a way for external stuff to override normal keyguard behavior. For instance * the phone app disables the keyguard when it receives incoming calls. @@ -878,6 +901,12 @@ public class KeyguardViewMediator extends SystemUI { synchronized (this) { if (DEBUG) Log.d(TAG, "setKeyguardEnabled(" + enabled + ")"); + if (mInternallyDisabled && enabled && !lockscreenEnforcedByDevicePolicy()) { + // if keyguard is forcefully disabled internally (by lock screen tile), don't allow + // it to be enabled externally, unless the device policy manager says so. + return; + } + mExternallyEnabled = enabled; if (!enabled && mShowing) { @@ -1132,6 +1161,23 @@ public class KeyguardViewMediator extends SystemUI { return !mUpdateMonitor.isDeviceProvisioned() && !isSecure(); } + public boolean lockscreenEnforcedByDevicePolicy() { + DevicePolicyManager dpm = (DevicePolicyManager) + mContext.getSystemService(Context.DEVICE_POLICY_SERVICE); + if (dpm != null) { + int passwordQuality = dpm.getPasswordQuality(null); + switch (passwordQuality) { + case DevicePolicyManager.PASSWORD_QUALITY_ALPHABETIC: + case DevicePolicyManager.PASSWORD_QUALITY_ALPHANUMERIC: + case DevicePolicyManager.PASSWORD_QUALITY_COMPLEX: + case DevicePolicyManager.PASSWORD_QUALITY_NUMERIC: + case DevicePolicyManager.PASSWORD_QUALITY_SOMETHING: + return true; + } + } + return false; + } + /** * Dismiss the keyguard through the security layers. */ |