From 983986d12e6e9ac10bef05bd8f646907f314a7b1 Mon Sep 17 00:00:00 2001 From: Roman Birg Date: Wed, 4 Feb 2015 14:00:23 -0800 Subject: 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 --- .../systemui/keyguard/KeyguardViewMediator.java | 46 ++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'packages/SystemUI/src/com') 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. */ -- cgit v1.1