Prevent keyguard from dismissing if not...
dismissable and add a log here if this is the case. KeyguardStateController#isLockscreenDismissable checks to see if the user has unlocked with biometric auth or if the user's security method is not secure (i.e. swipe/none). Is the user is attemping to dismiss the lockscreen when the user has not bio auth unlocked and has a pin/password/pattern, we also assert that the user has correctly auth'd with the respective pin/password/pattern. Fixes: 272249570 Test: Try to dismiss keyguard with bouncer and bio auth. Test: sim pin/sim puk with swipe and pin security set. Test: call StatusBarKeyguardViewManager#notifyKeyguardAuthenticated directly when on LS and observe the log being reached. Change-Id: I5150d58a44fcd927661672ec61b915f51801fb7f
This commit is contained in:
@@ -260,6 +260,14 @@ public class KeyguardSecurityContainerController extends ViewController<Keyguard
|
||||
*/
|
||||
@Override
|
||||
public void finish(boolean strongAuth, int targetUserId) {
|
||||
if (mFeatureFlags.isEnabled(Flags.PREVENT_BYPASS_KEYGUARD)
|
||||
&& !mKeyguardStateController.canDismissLockScreen() && !strongAuth) {
|
||||
Log.e(TAG,
|
||||
"Tried to dismiss keyguard when lockscreen is not dismissible and user "
|
||||
+ "was not authenticated with a primary security method "
|
||||
+ "(pin/password/pattern).");
|
||||
return;
|
||||
}
|
||||
// If there's a pending runnable because the user interacted with a widget
|
||||
// and we're leaving keyguard, then run it.
|
||||
boolean deferKeyguardDone = false;
|
||||
|
||||
@@ -196,6 +196,7 @@ public class KeyguardSecurityContainerControllerTest extends SysuiTestCase {
|
||||
.thenReturn(mKeyguardMessageAreaController);
|
||||
when(mKeyguardPasswordView.getWindowInsetsController()).thenReturn(mWindowInsetsController);
|
||||
when(mKeyguardSecurityModel.getSecurityMode(anyInt())).thenReturn(SecurityMode.PIN);
|
||||
when(mKeyguardStateController.canDismissLockScreen()).thenReturn(true);
|
||||
mKeyguardPasswordViewController = new KeyguardPasswordViewController(
|
||||
(KeyguardPasswordView) mKeyguardPasswordView, mKeyguardUpdateMonitor,
|
||||
SecurityMode.Password, mLockPatternUtils, null,
|
||||
@@ -551,6 +552,22 @@ public class KeyguardSecurityContainerControllerTest extends SysuiTestCase {
|
||||
assertThat(mKeyguardSecurityContainerController.willRunDismissFromKeyguard()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSecurityCallbackFinish() {
|
||||
when(mKeyguardStateController.canDismissLockScreen()).thenReturn(true);
|
||||
when(mKeyguardUpdateMonitor.isUserUnlocked(0)).thenReturn(true);
|
||||
mKeyguardSecurityContainerController.finish(true, 0);
|
||||
verify(mViewMediatorCallback).keyguardDone(anyBoolean(), anyInt());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSecurityCallbackFinish_cannotDismissLockScreenAndNotStrongAuth() {
|
||||
when(mFeatureFlags.isEnabled(Flags.PREVENT_BYPASS_KEYGUARD)).thenReturn(true);
|
||||
when(mKeyguardStateController.canDismissLockScreen()).thenReturn(false);
|
||||
mKeyguardSecurityContainerController.finish(false, 0);
|
||||
verify(mViewMediatorCallback, never()).keyguardDone(anyBoolean(), anyInt());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOnStartingToHide() {
|
||||
mKeyguardSecurityContainerController.onStartingToHide();
|
||||
|
||||
Reference in New Issue
Block a user