Fix issue where auth wouldn't be triggered

An auth interrupt should trigger authentication even if the device
is in non-interactive state.

Bug: 123581946
Test: manual, simulating auth interrupt
Test: atest StatusBarTest
Change-Id: Ib9113bdda40f309b4289e72dd6133f0b04aa23d9
This commit is contained in:
Lucas Dupin
2019-02-05 17:54:06 -05:00
parent 027b668bea
commit e0516d5a0c
3 changed files with 22 additions and 11 deletions

View File

@@ -205,6 +205,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
private boolean mKeyguardGoingAway;
private boolean mGoingToSleep;
private boolean mBouncer;
private boolean mAuthInterruptActive;
private boolean mBootCompleted;
private boolean mNeedsSlowUnlockTransition;
private boolean mHasLockscreenWallpaper;
@@ -1565,10 +1566,15 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
}
/**
* Request passive authentication, when sensors detect that a user might be present.
* Called whenever passive authentication is requested or aborted by a sensor.
* @param active If the interrupt started or ended.
*/
public void onAuthInterruptDetected() {
if (DEBUG) Log.d(TAG, "onAuthInterruptDetected()");
public void onAuthInterruptDetected(boolean active) {
if (DEBUG) Log.d(TAG, "onAuthInterruptDetected(" + active + ")");
if (mAuthInterruptActive == active) {
return;
}
mAuthInterruptActive = active;
updateFaceListeningState();
}
@@ -1612,7 +1618,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
final boolean awakeKeyguard = mKeyguardIsVisible && mDeviceInteractive && !mGoingToSleep;
final int user = getCurrentUser();
return (mBouncer || awakeKeyguard || shouldListenForFaceAssistant())
return (mBouncer || mAuthInterruptActive || awakeKeyguard || shouldListenForFaceAssistant())
&& !mSwitchingUser && !getUserCanSkipBouncer(user) && !isFaceDisabled(user)
&& !mKeyguardGoingAway && !mFaceLockedOut && mFaceSettingEnabledForUser
&& mUserManager.isUserUnlocked(user);

View File

@@ -3895,11 +3895,7 @@ public class StatusBar extends SystemUI implements DemoMode,
return;
}
if (mKeyguardUpdateMonitor != null
&& reason == DozeLog.PULSE_REASON_SENSOR_WAKE_LOCK_SCREEN) {
mKeyguardUpdateMonitor.onAuthInterruptDetected();
}
boolean passiveAuthInterrupt = reason == DozeLog.PULSE_REASON_SENSOR_WAKE_LOCK_SCREEN;
// Set the state to pulsing, so ScrimController will know what to do once we ask it to
// execute the transition. The pulse callback will then be invoked when the scrims
// are black, indicating that StatusBar is ready to present the rest of the UI.
@@ -3925,6 +3921,9 @@ public class StatusBar extends SystemUI implements DemoMode,
mNotificationPanel.setPulsing(pulsing);
mVisualStabilityManager.setPulsing(pulsing);
mIgnoreTouchWhilePulsing = false;
if (mKeyguardUpdateMonitor != null && passiveAuthInterrupt) {
mKeyguardUpdateMonitor.onAuthInterruptDetected(pulsing /* active */);
}
updateScrimController();
}
}, reason);

View File

@@ -655,13 +655,19 @@ public class StatusBarTest extends SysuiTestCase {
DozeLog.REASON_SENSOR_DOUBLE_TAP,
DozeLog.REASON_SENSOR_TAP));
doAnswer(invocation -> {
DozeHost.PulseCallback callback = invocation.getArgument(0);
callback.onPulseStarted();
return null;
}).when(mDozeScrimController).pulse(any(), anyInt());
for (int i = 0; i < DozeLog.REASONS; i++) {
reset(mKeyguardUpdateMonitor);
mStatusBar.mDozeServiceHost.pulseWhileDozing(mock(DozeHost.PulseCallback.class), i);
if (reasonsWantingAuth.contains(i)) {
verify(mKeyguardUpdateMonitor).onAuthInterruptDetected();
verify(mKeyguardUpdateMonitor).onAuthInterruptDetected(eq(true));
} else if (reasonsSkippingAuth.contains(i) || reasonsThatDontPulse.contains(i)) {
verify(mKeyguardUpdateMonitor, never()).onAuthInterruptDetected();
verify(mKeyguardUpdateMonitor, never()).onAuthInterruptDetected(eq(true));
} else {
throw new AssertionError("Reason " + i + " isn't specified as wanting or skipping"
+ " passive auth. Please consider how this pulse reason should behave.");