Loading packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java +3 −3 Original line number Diff line number Diff line Loading @@ -1683,12 +1683,12 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener { strongAuth == StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_LOCKOUT || strongAuth == StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_USER_LOCKDOWN; boolean canBypass = mKeyguardBypassController != null && mKeyguardBypassController.canBypass(); // There's no reason to ask the HAL for authentication when the user can dismiss the // bouncer, unless we're bypassing and need to auto-dismiss the lock screen even when // TrustAgents or biometrics are keeping the device unlocked. boolean bypassEnabled = mKeyguardBypassController != null && mKeyguardBypassController.getBypassEnabled(); boolean becauseCannotSkipBouncer = !getUserCanSkipBouncer(user) || bypassEnabled; boolean becauseCannotSkipBouncer = !getUserCanSkipBouncer(user) || canBypass; // Only listen if this KeyguardUpdateMonitor belongs to the primary user. There is an // instance of KeyguardUpdateMonitor for each user but KeyguardUpdateMonitor is user-aware. Loading packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBypassController.kt +19 −15 Original line number Diff line number Diff line Loading @@ -104,23 +104,11 @@ class KeyguardBypassController { */ fun onBiometricAuthenticated(biometricSourceType: BiometricSourceType): Boolean { if (bypassEnabled) { if (bouncerShowing) { // Whenever the bouncer is showing, we want to unlock. Otherwise we can get stuck // in the shade locked where the bouncer wouldn't unlock return true } if (statusBarStateController.state != StatusBarState.KEYGUARD) { // We're bypassing but not actually on the lockscreen, the user should decide when // to unlock return false } if (launchingAffordance) { return false } if (isPulseExpanding || qSExpanded) { val can = canBypass() if (!can && (isPulseExpanding || qSExpanded)) { pendingUnlockType = biometricSourceType return false } return can } return true } Loading @@ -134,6 +122,22 @@ class KeyguardBypassController { } } /** * If keyguard can be dismissed because of bypass. */ fun canBypass(): Boolean { if (bypassEnabled) { return when { bouncerShowing -> true statusBarStateController.state != StatusBarState.KEYGUARD -> false launchingAffordance -> false isPulseExpanding || qSExpanded -> false else -> true } } return false } fun onStartedGoingToSleep() { pendingUnlockType = null } Loading packages/SystemUI/tests/src/com/android/keyguard/KeyguardUpdateMonitorTest.java +25 −0 Original line number Diff line number Diff line Loading @@ -52,6 +52,7 @@ import com.android.internal.telephony.IccCardConstants; import com.android.internal.telephony.PhoneConstants; import com.android.internal.telephony.TelephonyIntents; import com.android.systemui.SysuiTestCase; import com.android.systemui.statusbar.phone.KeyguardBypassController; import org.junit.Assert; import org.junit.Before; Loading Loading @@ -88,6 +89,8 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase { private UserManager mUserManager; @Mock private DevicePolicyManager mDevicePolicyManager; @Mock private KeyguardBypassController mKeyguardBypassController; private TestableLooper mTestableLooper; private TestableKeyguardUpdateMonitor mKeyguardUpdateMonitor; Loading Loading @@ -331,6 +334,28 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase { verify(mFaceManager).authenticate(any(), any(), anyInt(), any(), any(), anyInt()); } @Test public void testTriesToAuthenticate_whenTrustOnAgentKeyguard_ifBypass() { mKeyguardUpdateMonitor.setKeyguardBypassController(mKeyguardBypassController); mKeyguardUpdateMonitor.dispatchStartedWakingUp(); mTestableLooper.processAllMessages(); when(mKeyguardBypassController.canBypass()).thenReturn(true); mKeyguardUpdateMonitor.onTrustChanged(true /* enabled */, KeyguardUpdateMonitor.getCurrentUser(), 0 /* flags */); mKeyguardUpdateMonitor.onKeyguardVisibilityChanged(true); verify(mFaceManager).authenticate(any(), any(), anyInt(), any(), any(), anyInt()); } @Test public void testIgnoresAuth_whenTrustAgentOnKeyguard_withoutBypass() { mKeyguardUpdateMonitor.dispatchStartedWakingUp(); mTestableLooper.processAllMessages(); mKeyguardUpdateMonitor.onTrustChanged(true /* enabled */, KeyguardUpdateMonitor.getCurrentUser(), 0 /* flags */); mKeyguardUpdateMonitor.onKeyguardVisibilityChanged(true); verify(mFaceManager, never()).authenticate(any(), any(), anyInt(), any(), any(), anyInt()); } @Test public void testOnFaceAuthenticated_skipsFaceWhenAuthenticated() { mKeyguardUpdateMonitor.onFaceAuthenticated(KeyguardUpdateMonitor.getCurrentUser()); Loading Loading
packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java +3 −3 Original line number Diff line number Diff line Loading @@ -1683,12 +1683,12 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener { strongAuth == StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_LOCKOUT || strongAuth == StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_USER_LOCKDOWN; boolean canBypass = mKeyguardBypassController != null && mKeyguardBypassController.canBypass(); // There's no reason to ask the HAL for authentication when the user can dismiss the // bouncer, unless we're bypassing and need to auto-dismiss the lock screen even when // TrustAgents or biometrics are keeping the device unlocked. boolean bypassEnabled = mKeyguardBypassController != null && mKeyguardBypassController.getBypassEnabled(); boolean becauseCannotSkipBouncer = !getUserCanSkipBouncer(user) || bypassEnabled; boolean becauseCannotSkipBouncer = !getUserCanSkipBouncer(user) || canBypass; // Only listen if this KeyguardUpdateMonitor belongs to the primary user. There is an // instance of KeyguardUpdateMonitor for each user but KeyguardUpdateMonitor is user-aware. Loading
packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBypassController.kt +19 −15 Original line number Diff line number Diff line Loading @@ -104,23 +104,11 @@ class KeyguardBypassController { */ fun onBiometricAuthenticated(biometricSourceType: BiometricSourceType): Boolean { if (bypassEnabled) { if (bouncerShowing) { // Whenever the bouncer is showing, we want to unlock. Otherwise we can get stuck // in the shade locked where the bouncer wouldn't unlock return true } if (statusBarStateController.state != StatusBarState.KEYGUARD) { // We're bypassing but not actually on the lockscreen, the user should decide when // to unlock return false } if (launchingAffordance) { return false } if (isPulseExpanding || qSExpanded) { val can = canBypass() if (!can && (isPulseExpanding || qSExpanded)) { pendingUnlockType = biometricSourceType return false } return can } return true } Loading @@ -134,6 +122,22 @@ class KeyguardBypassController { } } /** * If keyguard can be dismissed because of bypass. */ fun canBypass(): Boolean { if (bypassEnabled) { return when { bouncerShowing -> true statusBarStateController.state != StatusBarState.KEYGUARD -> false launchingAffordance -> false isPulseExpanding || qSExpanded -> false else -> true } } return false } fun onStartedGoingToSleep() { pendingUnlockType = null } Loading
packages/SystemUI/tests/src/com/android/keyguard/KeyguardUpdateMonitorTest.java +25 −0 Original line number Diff line number Diff line Loading @@ -52,6 +52,7 @@ import com.android.internal.telephony.IccCardConstants; import com.android.internal.telephony.PhoneConstants; import com.android.internal.telephony.TelephonyIntents; import com.android.systemui.SysuiTestCase; import com.android.systemui.statusbar.phone.KeyguardBypassController; import org.junit.Assert; import org.junit.Before; Loading Loading @@ -88,6 +89,8 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase { private UserManager mUserManager; @Mock private DevicePolicyManager mDevicePolicyManager; @Mock private KeyguardBypassController mKeyguardBypassController; private TestableLooper mTestableLooper; private TestableKeyguardUpdateMonitor mKeyguardUpdateMonitor; Loading Loading @@ -331,6 +334,28 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase { verify(mFaceManager).authenticate(any(), any(), anyInt(), any(), any(), anyInt()); } @Test public void testTriesToAuthenticate_whenTrustOnAgentKeyguard_ifBypass() { mKeyguardUpdateMonitor.setKeyguardBypassController(mKeyguardBypassController); mKeyguardUpdateMonitor.dispatchStartedWakingUp(); mTestableLooper.processAllMessages(); when(mKeyguardBypassController.canBypass()).thenReturn(true); mKeyguardUpdateMonitor.onTrustChanged(true /* enabled */, KeyguardUpdateMonitor.getCurrentUser(), 0 /* flags */); mKeyguardUpdateMonitor.onKeyguardVisibilityChanged(true); verify(mFaceManager).authenticate(any(), any(), anyInt(), any(), any(), anyInt()); } @Test public void testIgnoresAuth_whenTrustAgentOnKeyguard_withoutBypass() { mKeyguardUpdateMonitor.dispatchStartedWakingUp(); mTestableLooper.processAllMessages(); mKeyguardUpdateMonitor.onTrustChanged(true /* enabled */, KeyguardUpdateMonitor.getCurrentUser(), 0 /* flags */); mKeyguardUpdateMonitor.onKeyguardVisibilityChanged(true); verify(mFaceManager, never()).authenticate(any(), any(), anyInt(), any(), any(), anyInt()); } @Test public void testOnFaceAuthenticated_skipsFaceWhenAuthenticated() { mKeyguardUpdateMonitor.onFaceAuthenticated(KeyguardUpdateMonitor.getCurrentUser()); Loading