Merge "Disable bypass if there aren't enrolled faces" into qt-r1-dev am: 9369357e1d

am: 883581f176

Change-Id: Ic7136202d2d3b3ae48c0815e36d1e7a964736d03
This commit is contained in:
Lucas Dupin
2019-06-05 15:37:51 -07:00
committed by android-build-merger
4 changed files with 28 additions and 19 deletions

View File

@@ -46,6 +46,7 @@ import com.android.internal.widget.LockPatternUtils;
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 @@ public class KeyguardSecurityContainer extends FrameLayout implements KeyguardSe
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 @@ public class KeyguardSecurityContainer extends FrameLayout implements KeyguardSe
mSpringAnimation = new SpringAnimation(this, DynamicAnimation.Y);
mInjectionInflationController = new InjectionInflationController(
SystemUIFactory.getInstance().getRootComponent());
mUnlockMethodCache = UnlockMethodCache.getInstance(context);
mViewConfiguration = ViewConfiguration.get(context);
}
@@ -265,8 +268,7 @@ public class KeyguardSecurityContainer extends FrameLayout implements KeyguardSe
*/
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

View File

@@ -29,9 +29,18 @@ import javax.inject.Singleton
@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 @@ class KeyguardBypassController {
}
@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
}

View File

@@ -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 @@ public class UnlockMethodCache {
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 @@ public class UnlockMethodCache {
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 @@ public class UnlockMethodCache {
|| (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();

View File

@@ -37,7 +37,6 @@ import com.android.keyguard.KeyguardUpdateMonitor;
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 @@ public class BiometricsUnlockControllerTest extends SysuiTestCase {
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 @@ public class BiometricsUnlockControllerTest extends SysuiTestCase {
super(mContext, mDozeScrimController,
mKeyguardViewMediator, mScrimController, mStatusBar, mUnlockMethodCache,
mHandler, mUpdateMonitor, 0 /* wakeUpDelay */,
new KeyguardBypassController(faceDismissesKeyguard));
new KeyguardBypassController(faceDismissesKeyguard, mUnlockMethodCache));
}
}
}