Disable bypass if there aren't enrolled faces
Bug: 130327302
Test: manual
Test: BiometricsUnlockControllerTest
Change-Id: I699bae45a2a9ce21bdca5a9ca177c97a91ba5f5a
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainer.java b/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainer.java
index eef61db..b6f42df 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainer.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainer.java
@@ -46,6 +46,7 @@
import com.android.keyguard.KeyguardSecurityModel.SecurityMode;
import com.android.systemui.Dependency;
import com.android.systemui.SystemUIFactory;
+import com.android.systemui.statusbar.phone.UnlockMethodCache;
import com.android.systemui.util.InjectionInflationController;
public class KeyguardSecurityContainer extends FrameLayout implements KeyguardSecurityView {
@@ -90,6 +91,7 @@
private final SpringAnimation mSpringAnimation;
private final VelocityTracker mVelocityTracker = VelocityTracker.obtain();
private final KeyguardUpdateMonitor mUpdateMonitor;
+ private final UnlockMethodCache mUnlockMethodCache;
private final MetricsLogger mMetricsLogger = Dependency.get(MetricsLogger.class);
private float mLastTouchY = -1;
@@ -129,6 +131,7 @@
mSpringAnimation = new SpringAnimation(this, DynamicAnimation.Y);
mInjectionInflationController = new InjectionInflationController(
SystemUIFactory.getInstance().getRootComponent());
+ mUnlockMethodCache = UnlockMethodCache.getInstance(context);
mViewConfiguration = ViewConfiguration.get(context);
}
@@ -265,8 +268,7 @@
*/
private void updateBiometricRetry() {
SecurityMode securityMode = getSecurityMode();
- int userId = KeyguardUpdateMonitor.getCurrentUser();
- mSwipeUpToRetry = mUpdateMonitor.isUnlockWithFacePossible(userId)
+ mSwipeUpToRetry = mUnlockMethodCache.isUnlockingWithFacePossible()
&& securityMode != SecurityMode.SimPin
&& securityMode != SecurityMode.SimPuk
&& securityMode != SecurityMode.None
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBypassController.kt b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBypassController.kt
index 5abf39e7..c9dd461 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBypassController.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBypassController.kt
@@ -29,9 +29,18 @@
@Singleton
class KeyguardBypassController {
+ /**
+ * If face unlock dismisses the lock screen or keeps user on keyguard for the current user.
+ */
+ var bypassEnabled: Boolean = false
+ get() = field && unlockMethodCache.isUnlockingWithFacePossible
+ private set
+
+ private val unlockMethodCache: UnlockMethodCache
+
@Inject
- constructor(context: Context,
- tunerService: TunerService) {
+ constructor(context: Context, tunerService: TunerService) {
+ unlockMethodCache = UnlockMethodCache.getInstance(context)
val faceManager = context.getSystemService(FaceManager::class.java)
if (faceManager?.isHardwareDetected != true) {
return
@@ -52,13 +61,8 @@
}
@VisibleForTesting
- constructor(bypassEnabled: Boolean) {
- this.bypassEnabled = bypassEnabled;
+ constructor(bypassEnabled: Boolean, unlockMethodCache: UnlockMethodCache) {
+ this.bypassEnabled = bypassEnabled
+ this.unlockMethodCache = unlockMethodCache
}
-
- /**
- * If face unlock dismisses the lock screen or keeps user on keyguard for the current user.
- */
- var bypassEnabled: Boolean = false
- private set
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/UnlockMethodCache.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/UnlockMethodCache.java
index 39bf728..78eb394 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/UnlockMethodCache.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/UnlockMethodCache.java
@@ -16,18 +16,14 @@
package com.android.systemui.statusbar.phone;
-import android.app.admin.DevicePolicyManager;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.hardware.biometrics.BiometricSourceType;
-import android.media.AudioManager;
import android.os.Build;
import android.os.Trace;
-import android.telephony.TelephonyManager;
-import com.android.internal.telephony.TelephonyIntents;
import com.android.internal.widget.LockPatternUtils;
import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.keyguard.KeyguardUpdateMonitorCallback;
@@ -55,6 +51,7 @@
private boolean mTrustManaged;
private boolean mTrusted;
private boolean mDebugUnlocked = false;
+ private boolean mIsUnlockingWithFacePossible;
private UnlockMethodCache(Context ctx) {
mLockPatternUtils = new LockPatternUtils(ctx);
@@ -110,6 +107,10 @@
mListeners.remove(listener);
}
+ public boolean isUnlockingWithFacePossible() {
+ return mIsUnlockingWithFacePossible;
+ }
+
private void update(boolean updateAlways) {
Trace.beginSection("UnlockMethodCache#update");
int user = KeyguardUpdateMonitor.getCurrentUser();
@@ -118,13 +119,15 @@
|| (Build.IS_DEBUGGABLE && DEBUG_AUTH_WITH_ADB && mDebugUnlocked);
boolean trustManaged = mKeyguardUpdateMonitor.getUserTrustIsManaged(user);
boolean trusted = mKeyguardUpdateMonitor.getUserHasTrust(user);
+ boolean hasEnrolledFaces = mKeyguardUpdateMonitor.isUnlockWithFacePossible(user);
boolean changed = secure != mSecure || canSkipBouncer != mCanSkipBouncer ||
- trustManaged != mTrustManaged;
+ trustManaged != mTrustManaged || mIsUnlockingWithFacePossible != hasEnrolledFaces;
if (changed || updateAlways) {
mSecure = secure;
mCanSkipBouncer = canSkipBouncer;
mTrusted = trusted;
mTrustManaged = trustManaged;
+ mIsUnlockingWithFacePossible = hasEnrolledFaces;
notifyListeners();
}
Trace.endSection();
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/BiometricsUnlockControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/BiometricsUnlockControllerTest.java
index fdc2cd3..9b8d09e 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/BiometricsUnlockControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/BiometricsUnlockControllerTest.java
@@ -37,7 +37,6 @@
import com.android.systemui.SysuiTestCase;
import com.android.systemui.keyguard.KeyguardViewMediator;
import com.android.systemui.statusbar.NotificationMediaManager;
-import com.android.systemui.tuner.TunerService;
import org.junit.Before;
import org.junit.Test;
@@ -79,6 +78,7 @@
MockitoAnnotations.initMocks(this);
when(mStatusBarKeyguardViewManager.isShowing()).thenReturn(true);
when(mUpdateMonitor.isDeviceInteractive()).thenReturn(true);
+ when(mUnlockMethodCache.isUnlockingWithFacePossible()).thenReturn(true);
mContext.addMockSystemService(PowerManager.class, mPowerManager);
mDependency.injectTestDependency(NotificationMediaManager.class, mMediaManager);
mDependency.injectTestDependency(StatusBarWindowController.class,
@@ -191,7 +191,7 @@
super(mContext, mDozeScrimController,
mKeyguardViewMediator, mScrimController, mStatusBar, mUnlockMethodCache,
mHandler, mUpdateMonitor, 0 /* wakeUpDelay */,
- new KeyguardBypassController(faceDismissesKeyguard));
+ new KeyguardBypassController(faceDismissesKeyguard, mUnlockMethodCache));
}
}
}