Merge "Disable bypass if there aren't enrolled faces" into qt-r1-dev
am: 9369357e1d
Change-Id: I2591f861e338dda0d667874103e89c3833f707f8
This commit is contained in:
@@ -46,6 +46,7 @@ import com.android.internal.widget.LockPatternUtils;
|
|||||||
import com.android.keyguard.KeyguardSecurityModel.SecurityMode;
|
import com.android.keyguard.KeyguardSecurityModel.SecurityMode;
|
||||||
import com.android.systemui.Dependency;
|
import com.android.systemui.Dependency;
|
||||||
import com.android.systemui.SystemUIFactory;
|
import com.android.systemui.SystemUIFactory;
|
||||||
|
import com.android.systemui.statusbar.phone.UnlockMethodCache;
|
||||||
import com.android.systemui.util.InjectionInflationController;
|
import com.android.systemui.util.InjectionInflationController;
|
||||||
|
|
||||||
public class KeyguardSecurityContainer extends FrameLayout implements KeyguardSecurityView {
|
public class KeyguardSecurityContainer extends FrameLayout implements KeyguardSecurityView {
|
||||||
@@ -90,6 +91,7 @@ public class KeyguardSecurityContainer extends FrameLayout implements KeyguardSe
|
|||||||
private final SpringAnimation mSpringAnimation;
|
private final SpringAnimation mSpringAnimation;
|
||||||
private final VelocityTracker mVelocityTracker = VelocityTracker.obtain();
|
private final VelocityTracker mVelocityTracker = VelocityTracker.obtain();
|
||||||
private final KeyguardUpdateMonitor mUpdateMonitor;
|
private final KeyguardUpdateMonitor mUpdateMonitor;
|
||||||
|
private final UnlockMethodCache mUnlockMethodCache;
|
||||||
|
|
||||||
private final MetricsLogger mMetricsLogger = Dependency.get(MetricsLogger.class);
|
private final MetricsLogger mMetricsLogger = Dependency.get(MetricsLogger.class);
|
||||||
private float mLastTouchY = -1;
|
private float mLastTouchY = -1;
|
||||||
@@ -129,6 +131,7 @@ public class KeyguardSecurityContainer extends FrameLayout implements KeyguardSe
|
|||||||
mSpringAnimation = new SpringAnimation(this, DynamicAnimation.Y);
|
mSpringAnimation = new SpringAnimation(this, DynamicAnimation.Y);
|
||||||
mInjectionInflationController = new InjectionInflationController(
|
mInjectionInflationController = new InjectionInflationController(
|
||||||
SystemUIFactory.getInstance().getRootComponent());
|
SystemUIFactory.getInstance().getRootComponent());
|
||||||
|
mUnlockMethodCache = UnlockMethodCache.getInstance(context);
|
||||||
mViewConfiguration = ViewConfiguration.get(context);
|
mViewConfiguration = ViewConfiguration.get(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -265,8 +268,7 @@ public class KeyguardSecurityContainer extends FrameLayout implements KeyguardSe
|
|||||||
*/
|
*/
|
||||||
private void updateBiometricRetry() {
|
private void updateBiometricRetry() {
|
||||||
SecurityMode securityMode = getSecurityMode();
|
SecurityMode securityMode = getSecurityMode();
|
||||||
int userId = KeyguardUpdateMonitor.getCurrentUser();
|
mSwipeUpToRetry = mUnlockMethodCache.isUnlockingWithFacePossible()
|
||||||
mSwipeUpToRetry = mUpdateMonitor.isUnlockWithFacePossible(userId)
|
|
||||||
&& securityMode != SecurityMode.SimPin
|
&& securityMode != SecurityMode.SimPin
|
||||||
&& securityMode != SecurityMode.SimPuk
|
&& securityMode != SecurityMode.SimPuk
|
||||||
&& securityMode != SecurityMode.None
|
&& securityMode != SecurityMode.None
|
||||||
|
|||||||
@@ -29,9 +29,18 @@ import javax.inject.Singleton
|
|||||||
@Singleton
|
@Singleton
|
||||||
class KeyguardBypassController {
|
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
|
@Inject
|
||||||
constructor(context: Context,
|
constructor(context: Context, tunerService: TunerService) {
|
||||||
tunerService: TunerService) {
|
unlockMethodCache = UnlockMethodCache.getInstance(context)
|
||||||
val faceManager = context.getSystemService(FaceManager::class.java)
|
val faceManager = context.getSystemService(FaceManager::class.java)
|
||||||
if (faceManager?.isHardwareDetected != true) {
|
if (faceManager?.isHardwareDetected != true) {
|
||||||
return
|
return
|
||||||
@@ -52,13 +61,8 @@ class KeyguardBypassController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
constructor(bypassEnabled: Boolean) {
|
constructor(bypassEnabled: Boolean, unlockMethodCache: UnlockMethodCache) {
|
||||||
this.bypassEnabled = bypassEnabled;
|
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
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,18 +16,14 @@
|
|||||||
|
|
||||||
package com.android.systemui.statusbar.phone;
|
package com.android.systemui.statusbar.phone;
|
||||||
|
|
||||||
import android.app.admin.DevicePolicyManager;
|
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
import android.hardware.biometrics.BiometricSourceType;
|
import android.hardware.biometrics.BiometricSourceType;
|
||||||
import android.media.AudioManager;
|
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Trace;
|
import android.os.Trace;
|
||||||
import android.telephony.TelephonyManager;
|
|
||||||
|
|
||||||
import com.android.internal.telephony.TelephonyIntents;
|
|
||||||
import com.android.internal.widget.LockPatternUtils;
|
import com.android.internal.widget.LockPatternUtils;
|
||||||
import com.android.keyguard.KeyguardUpdateMonitor;
|
import com.android.keyguard.KeyguardUpdateMonitor;
|
||||||
import com.android.keyguard.KeyguardUpdateMonitorCallback;
|
import com.android.keyguard.KeyguardUpdateMonitorCallback;
|
||||||
@@ -55,6 +51,7 @@ public class UnlockMethodCache {
|
|||||||
private boolean mTrustManaged;
|
private boolean mTrustManaged;
|
||||||
private boolean mTrusted;
|
private boolean mTrusted;
|
||||||
private boolean mDebugUnlocked = false;
|
private boolean mDebugUnlocked = false;
|
||||||
|
private boolean mIsUnlockingWithFacePossible;
|
||||||
|
|
||||||
private UnlockMethodCache(Context ctx) {
|
private UnlockMethodCache(Context ctx) {
|
||||||
mLockPatternUtils = new LockPatternUtils(ctx);
|
mLockPatternUtils = new LockPatternUtils(ctx);
|
||||||
@@ -110,6 +107,10 @@ public class UnlockMethodCache {
|
|||||||
mListeners.remove(listener);
|
mListeners.remove(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isUnlockingWithFacePossible() {
|
||||||
|
return mIsUnlockingWithFacePossible;
|
||||||
|
}
|
||||||
|
|
||||||
private void update(boolean updateAlways) {
|
private void update(boolean updateAlways) {
|
||||||
Trace.beginSection("UnlockMethodCache#update");
|
Trace.beginSection("UnlockMethodCache#update");
|
||||||
int user = KeyguardUpdateMonitor.getCurrentUser();
|
int user = KeyguardUpdateMonitor.getCurrentUser();
|
||||||
@@ -118,13 +119,15 @@ public class UnlockMethodCache {
|
|||||||
|| (Build.IS_DEBUGGABLE && DEBUG_AUTH_WITH_ADB && mDebugUnlocked);
|
|| (Build.IS_DEBUGGABLE && DEBUG_AUTH_WITH_ADB && mDebugUnlocked);
|
||||||
boolean trustManaged = mKeyguardUpdateMonitor.getUserTrustIsManaged(user);
|
boolean trustManaged = mKeyguardUpdateMonitor.getUserTrustIsManaged(user);
|
||||||
boolean trusted = mKeyguardUpdateMonitor.getUserHasTrust(user);
|
boolean trusted = mKeyguardUpdateMonitor.getUserHasTrust(user);
|
||||||
|
boolean hasEnrolledFaces = mKeyguardUpdateMonitor.isUnlockWithFacePossible(user);
|
||||||
boolean changed = secure != mSecure || canSkipBouncer != mCanSkipBouncer ||
|
boolean changed = secure != mSecure || canSkipBouncer != mCanSkipBouncer ||
|
||||||
trustManaged != mTrustManaged;
|
trustManaged != mTrustManaged || mIsUnlockingWithFacePossible != hasEnrolledFaces;
|
||||||
if (changed || updateAlways) {
|
if (changed || updateAlways) {
|
||||||
mSecure = secure;
|
mSecure = secure;
|
||||||
mCanSkipBouncer = canSkipBouncer;
|
mCanSkipBouncer = canSkipBouncer;
|
||||||
mTrusted = trusted;
|
mTrusted = trusted;
|
||||||
mTrustManaged = trustManaged;
|
mTrustManaged = trustManaged;
|
||||||
|
mIsUnlockingWithFacePossible = hasEnrolledFaces;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
Trace.endSection();
|
Trace.endSection();
|
||||||
|
|||||||
@@ -37,7 +37,6 @@ import com.android.keyguard.KeyguardUpdateMonitor;
|
|||||||
import com.android.systemui.SysuiTestCase;
|
import com.android.systemui.SysuiTestCase;
|
||||||
import com.android.systemui.keyguard.KeyguardViewMediator;
|
import com.android.systemui.keyguard.KeyguardViewMediator;
|
||||||
import com.android.systemui.statusbar.NotificationMediaManager;
|
import com.android.systemui.statusbar.NotificationMediaManager;
|
||||||
import com.android.systemui.tuner.TunerService;
|
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -79,6 +78,7 @@ public class BiometricsUnlockControllerTest extends SysuiTestCase {
|
|||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
when(mStatusBarKeyguardViewManager.isShowing()).thenReturn(true);
|
when(mStatusBarKeyguardViewManager.isShowing()).thenReturn(true);
|
||||||
when(mUpdateMonitor.isDeviceInteractive()).thenReturn(true);
|
when(mUpdateMonitor.isDeviceInteractive()).thenReturn(true);
|
||||||
|
when(mUnlockMethodCache.isUnlockingWithFacePossible()).thenReturn(true);
|
||||||
mContext.addMockSystemService(PowerManager.class, mPowerManager);
|
mContext.addMockSystemService(PowerManager.class, mPowerManager);
|
||||||
mDependency.injectTestDependency(NotificationMediaManager.class, mMediaManager);
|
mDependency.injectTestDependency(NotificationMediaManager.class, mMediaManager);
|
||||||
mDependency.injectTestDependency(StatusBarWindowController.class,
|
mDependency.injectTestDependency(StatusBarWindowController.class,
|
||||||
@@ -191,7 +191,7 @@ public class BiometricsUnlockControllerTest extends SysuiTestCase {
|
|||||||
super(mContext, mDozeScrimController,
|
super(mContext, mDozeScrimController,
|
||||||
mKeyguardViewMediator, mScrimController, mStatusBar, mUnlockMethodCache,
|
mKeyguardViewMediator, mScrimController, mStatusBar, mUnlockMethodCache,
|
||||||
mHandler, mUpdateMonitor, 0 /* wakeUpDelay */,
|
mHandler, mUpdateMonitor, 0 /* wakeUpDelay */,
|
||||||
new KeyguardBypassController(faceDismissesKeyguard));
|
new KeyguardBypassController(faceDismissesKeyguard, mUnlockMethodCache));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user