diff options
author | Adrian Roos <roosa@google.com> | 2015-04-16 12:23:18 -0700 |
---|---|---|
committer | Adrian Roos <roosa@google.com> | 2015-04-17 01:12:30 +0000 |
commit | 94e15a59b757678949cccb5d783bee1638e84697 (patch) | |
tree | 1f69ef1533739cba105578e95d03934c1ee87261 /packages/Keyguard/src | |
parent | fbad74b29cdaf955f48024123bd198fa7c49662c (diff) | |
download | frameworks_base-94e15a59b757678949cccb5d783bee1638e84697.zip frameworks_base-94e15a59b757678949cccb5d783bee1638e84697.tar.gz frameworks_base-94e15a59b757678949cccb5d783bee1638e84697.tar.bz2 |
Allow dismissing Keyguard from TrustAgentService
Bug: 19900313
Change-Id: I44d13ee6fe65070327076e73a3ed96c94acdc108
Diffstat (limited to 'packages/Keyguard/src')
4 files changed, 31 insertions, 13 deletions
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardHostView.java b/packages/Keyguard/src/com/android/keyguard/KeyguardHostView.java index a88497c..be71b034 100644 --- a/packages/Keyguard/src/com/android/keyguard/KeyguardHostView.java +++ b/packages/Keyguard/src/com/android/keyguard/KeyguardHostView.java @@ -23,6 +23,7 @@ import android.content.res.Resources; import android.graphics.Canvas; import android.media.AudioManager; import android.os.SystemClock; +import android.service.trust.TrustAgentService; import android.telephony.TelephonyManager; import android.util.AttributeSet; import android.util.Log; @@ -69,14 +70,27 @@ public class KeyguardHostView extends FrameLayout implements SecurityCallback { } @Override - public void onTrustInitiatedByUser(int userId) { + public void onTrustGrantedWithFlags(int flags, int userId) { if (userId != mLockPatternUtils.getCurrentUser()) return; if (!isAttachedToWindow()) return; - - if (isVisibleToUser()) { - dismiss(false /* authenticated */); - } else { - mViewMediatorCallback.playTrustedSound(); + boolean bouncerVisible = isVisibleToUser(); + boolean initiatedByUser = + (flags & TrustAgentService.FLAG_GRANT_TRUST_INITIATED_BY_USER) != 0; + boolean dismissKeyguard = + (flags & TrustAgentService.FLAG_GRANT_TRUST_DISMISS_KEYGUARD) != 0; + + if (initiatedByUser || dismissKeyguard) { + if (mViewMediatorCallback.isScreenOn() && (bouncerVisible || dismissKeyguard)) { + if (!bouncerVisible) { + // The trust agent dismissed the keyguard without the user proving + // that they are present (by swiping up to show the bouncer). That's fine if + // the user proved presence via some other way to the trust agent. + Log.i(TAG, "TrustAgent dismissed Keyguard."); + } + dismiss(false /* authenticated */); + } else { + mViewMediatorCallback.playTrustedSound(); + } } } }; diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java b/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java index 50c9f2d..1eec532 100644 --- a/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java +++ b/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java @@ -58,12 +58,12 @@ import android.hardware.fingerprint.FingerprintManager; import android.hardware.fingerprint.FingerprintManager.AuthenticationCallback; import android.hardware.fingerprint.FingerprintUtils; import android.hardware.fingerprint.FingerprintManager.AuthenticationResult; +import android.service.trust.TrustAgentService; import android.telephony.SubscriptionInfo; import android.telephony.SubscriptionManager; import android.telephony.SubscriptionManager.OnSubscriptionsChangedListener; import android.telephony.TelephonyManager; import android.util.Log; -import android.util.Slog; import android.util.SparseBooleanArray; import com.google.android.collect.Lists; @@ -245,15 +245,14 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener { private SparseBooleanArray mUserFaceUnlockRunning = new SparseBooleanArray(); @Override - public void onTrustChanged(boolean enabled, int userId, boolean initiatedByUser) { + public void onTrustChanged(boolean enabled, int userId, int flags) { mUserHasTrust.put(userId, enabled); - for (int i = 0; i < mCallbacks.size(); i++) { KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get(); if (cb != null) { cb.onTrustChanged(userId); - if (enabled && initiatedByUser) { - cb.onTrustInitiatedByUser(userId); + if (enabled && flags != 0) { + cb.onTrustGrantedWithFlags(flags, userId); } } } diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java b/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java index 756a7a4..26e6973 100644 --- a/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java +++ b/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java @@ -171,9 +171,9 @@ public class KeyguardUpdateMonitorCallback { public void onTrustManagedChanged(int userId) { } /** - * Called when the user has proved to a trust agent that they want to use the device. + * Called after trust was granted with non-zero flags. */ - public void onTrustInitiatedByUser(int userId) { } + public void onTrustGrantedWithFlags(int flags, int userId) { } /** * Called when a fingerprint is recognized. diff --git a/packages/Keyguard/src/com/android/keyguard/ViewMediatorCallback.java b/packages/Keyguard/src/com/android/keyguard/ViewMediatorCallback.java index 5bbcc8c..f5c809a 100644 --- a/packages/Keyguard/src/com/android/keyguard/ViewMediatorCallback.java +++ b/packages/Keyguard/src/com/android/keyguard/ViewMediatorCallback.java @@ -76,4 +76,9 @@ public interface ViewMediatorCallback { * (legacy API) */ boolean isInputRestricted(); + + /** + * @return true if the screen is on + */ + boolean isScreenOn(); } |