Merge "Dismiss the keyguard through #notifyKeyguardAuthentiated" into udc-dev

This commit is contained in:
Beverly Tai
2023-05-11 17:18:45 +00:00
committed by Android (Google) Code Review
8 changed files with 40 additions and 39 deletions

View File

@@ -257,14 +257,14 @@ public class KeyguardSecurityContainerController extends ViewController<Keyguard
* Authentication has happened and it's time to dismiss keyguard. This function * Authentication has happened and it's time to dismiss keyguard. This function
* should clean up and inform KeyguardViewMediator. * should clean up and inform KeyguardViewMediator.
* *
* @param strongAuth whether the user has authenticated with strong authentication like * @param fromPrimaryAuth whether the user has authenticated with primary auth like
* pattern, password or PIN but not by trust agents or fingerprint * pattern, password or PIN but not by trust agents or fingerprint
* @param targetUserId a user that needs to be the foreground user at the dismissal * @param targetUserId a user that needs to be the foreground user at the dismissal
* completion. * completion.
*/ */
@Override @Override
public void finish(boolean strongAuth, int targetUserId) { public void finish(boolean fromPrimaryAuth, int targetUserId) {
if (!mKeyguardStateController.canDismissLockScreen() && !strongAuth) { if (!mKeyguardStateController.canDismissLockScreen() && !fromPrimaryAuth) {
Log.e(TAG, Log.e(TAG,
"Tried to dismiss keyguard when lockscreen is not dismissible and user " "Tried to dismiss keyguard when lockscreen is not dismissible and user "
+ "was not authenticated with a primary security method " + "was not authenticated with a primary security method "
@@ -283,9 +283,9 @@ public class KeyguardSecurityContainerController extends ViewController<Keyguard
} }
if (mViewMediatorCallback != null) { if (mViewMediatorCallback != null) {
if (deferKeyguardDone) { if (deferKeyguardDone) {
mViewMediatorCallback.keyguardDonePending(strongAuth, targetUserId); mViewMediatorCallback.keyguardDonePending(fromPrimaryAuth, targetUserId);
} else { } else {
mViewMediatorCallback.keyguardDone(strongAuth, targetUserId); mViewMediatorCallback.keyguardDone(fromPrimaryAuth, targetUserId);
} }
} }
} }
@@ -603,8 +603,8 @@ public class KeyguardSecurityContainerController extends ViewController<Keyguard
/** /**
* Dismiss keyguard due to a user unlock event. * Dismiss keyguard due to a user unlock event.
*/ */
public void finish(boolean strongAuth, int currentUser) { public void finish(boolean primaryAuth, int currentUser) {
mKeyguardSecurityCallback.finish(strongAuth, currentUser); mKeyguardSecurityCallback.finish(primaryAuth, currentUser);
} }
/** /**
@@ -736,7 +736,7 @@ public class KeyguardSecurityContainerController extends ViewController<Keyguard
} }
boolean finish = false; boolean finish = false;
boolean strongAuth = false; boolean primaryAuth = false;
int eventSubtype = -1; int eventSubtype = -1;
BouncerUiEvent uiEvent = BouncerUiEvent.UNKNOWN; BouncerUiEvent uiEvent = BouncerUiEvent.UNKNOWN;
if (mUpdateMonitor.getUserHasTrust(targetUserId)) { if (mUpdateMonitor.getUserHasTrust(targetUserId)) {
@@ -761,7 +761,7 @@ public class KeyguardSecurityContainerController extends ViewController<Keyguard
case Pattern: case Pattern:
case Password: case Password:
case PIN: case PIN:
strongAuth = true; primaryAuth = true;
finish = true; finish = true;
eventSubtype = BOUNCER_DISMISS_PASSWORD; eventSubtype = BOUNCER_DISMISS_PASSWORD;
uiEvent = BouncerUiEvent.BOUNCER_DISMISS_PASSWORD; uiEvent = BouncerUiEvent.BOUNCER_DISMISS_PASSWORD;
@@ -805,7 +805,7 @@ public class KeyguardSecurityContainerController extends ViewController<Keyguard
mUiEventLogger.log(uiEvent, getSessionId()); mUiEventLogger.log(uiEvent, getSessionId());
} }
if (finish) { if (finish) {
mKeyguardSecurityCallback.finish(strongAuth, targetUserId); mKeyguardSecurityCallback.finish(primaryAuth, targetUserId);
} }
return finish; return finish;
} }

View File

@@ -893,7 +893,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
} }
@VisibleForTesting @VisibleForTesting
protected void onFingerprintAuthenticated(int userId, boolean isStrongBiometric) { public void onFingerprintAuthenticated(int userId, boolean isStrongBiometric) {
Assert.isMainThread(); Assert.isMainThread();
Trace.beginSection("KeyGuardUpdateMonitor#onFingerPrintAuthenticated"); Trace.beginSection("KeyGuardUpdateMonitor#onFingerPrintAuthenticated");
mUserFingerprintAuthenticated.put(userId, mUserFingerprintAuthenticated.put(userId,
@@ -1169,7 +1169,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
} }
@VisibleForTesting @VisibleForTesting
protected void onFaceAuthenticated(int userId, boolean isStrongBiometric) { public void onFaceAuthenticated(int userId, boolean isStrongBiometric) {
Trace.beginSection("KeyGuardUpdateMonitor#onFaceAuthenticated"); Trace.beginSection("KeyGuardUpdateMonitor#onFaceAuthenticated");
Assert.isMainThread(); Assert.isMainThread();
mUserFaceAuthenticated.put(userId, mUserFaceAuthenticated.put(userId,

View File

@@ -29,11 +29,11 @@ public interface ViewMediatorCallback {
/** /**
* Report that the keyguard is done. * Report that the keyguard is done.
* *
* @param strongAuth whether the user has authenticated with strong authentication like * @param primaryAuth whether the user has authenticated with primary authentication like
* pattern, password or PIN but not by trust agents or fingerprint * pattern, password or PIN but not by trust agents or fingerprint
* @param targetUserId a user that needs to be the foreground user at the completion. * @param targetUserId a user that needs to be the foreground user at the completion.
*/ */
void keyguardDone(boolean strongAuth, int targetUserId); void keyguardDone(boolean primaryAuth, int targetUserId);
/** /**
* Report that the keyguard is done drawing. * Report that the keyguard is done drawing.
@@ -49,11 +49,11 @@ public interface ViewMediatorCallback {
/** /**
* Report that the keyguard is dismissable, pending the next keyguardDone call. * Report that the keyguard is dismissable, pending the next keyguardDone call.
* *
* @param strongAuth whether the user has authenticated with strong authentication like * @param primaryAuth whether the user has authenticated with primary authentication like
* pattern, password or PIN but not by trust agents or fingerprint * pattern, password or PIN but not by trust agents or fingerprint
* @param targetUserId a user that needs to be the foreground user at the completion. * @param targetUserId a user that needs to be the foreground user at the completion.
*/ */
void keyguardDonePending(boolean strongAuth, int targetUserId); void keyguardDonePending(boolean primaryAuth, int targetUserId);
/** /**
* Report when keyguard is actually gone * Report when keyguard is actually gone

View File

@@ -20,7 +20,6 @@ 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.BiometricConstants;
import android.hardware.biometrics.BiometricSourceType; import android.hardware.biometrics.BiometricSourceType;
import android.os.Build; import android.os.Build;
import android.provider.DeviceConfig; import android.provider.DeviceConfig;
@@ -57,6 +56,7 @@ public class LatencyTester implements CoreStartable {
private final BiometricUnlockController mBiometricUnlockController; private final BiometricUnlockController mBiometricUnlockController;
private final BroadcastDispatcher mBroadcastDispatcher; private final BroadcastDispatcher mBroadcastDispatcher;
private final DeviceConfigProxy mDeviceConfigProxy; private final DeviceConfigProxy mDeviceConfigProxy;
private final KeyguardUpdateMonitor mKeyguardUpdateMonitor;
private boolean mEnabled; private boolean mEnabled;
@@ -65,11 +65,13 @@ public class LatencyTester implements CoreStartable {
BiometricUnlockController biometricUnlockController, BiometricUnlockController biometricUnlockController,
BroadcastDispatcher broadcastDispatcher, BroadcastDispatcher broadcastDispatcher,
DeviceConfigProxy deviceConfigProxy, DeviceConfigProxy deviceConfigProxy,
@Main DelayableExecutor mainExecutor @Main DelayableExecutor mainExecutor,
KeyguardUpdateMonitor keyguardUpdateMonitor
) { ) {
mBiometricUnlockController = biometricUnlockController; mBiometricUnlockController = biometricUnlockController;
mBroadcastDispatcher = broadcastDispatcher; mBroadcastDispatcher = broadcastDispatcher;
mDeviceConfigProxy = deviceConfigProxy; mDeviceConfigProxy = deviceConfigProxy;
mKeyguardUpdateMonitor = keyguardUpdateMonitor;
updateEnabled(); updateEnabled();
mDeviceConfigProxy.addOnPropertiesChangedListener(DeviceConfig.NAMESPACE_LATENCY_TRACKER, mDeviceConfigProxy.addOnPropertiesChangedListener(DeviceConfig.NAMESPACE_LATENCY_TRACKER,
@@ -85,10 +87,13 @@ public class LatencyTester implements CoreStartable {
if (!mEnabled) { if (!mEnabled) {
return; return;
} }
mBiometricUnlockController.onBiometricAcquired(type, if (type == BiometricSourceType.FACE) {
BiometricConstants.BIOMETRIC_ACQUIRED_GOOD); mKeyguardUpdateMonitor.onFaceAuthenticated(KeyguardUpdateMonitor.getCurrentUser(),
mBiometricUnlockController.onBiometricAuthenticated( true);
KeyguardUpdateMonitor.getCurrentUser(), type, true /* isStrongBiometric */); } else if (type == BiometricSourceType.FINGERPRINT) {
mKeyguardUpdateMonitor.onFingerprintAuthenticated(
KeyguardUpdateMonitor.getCurrentUser(), true);
}
} }
private void registerForBroadcasts(boolean register) { private void registerForBroadcasts(boolean register) {

View File

@@ -466,7 +466,7 @@ public class UdfpsController implements DozeReceiver, Dumpable {
if (!mOnFingerDown) { if (!mOnFingerDown) {
playStartHaptic(); playStartHaptic();
} }
mKeyguardViewManager.notifyKeyguardAuthenticated(false /* strongAuth */); mKeyguardViewManager.notifyKeyguardAuthenticated(false /* primaryAuth */);
mAttemptedToDismissKeyguard = true; mAttemptedToDismissKeyguard = true;
} }

View File

@@ -79,7 +79,6 @@ import android.provider.DeviceConfig;
import android.provider.Settings; import android.provider.Settings;
import android.telephony.SubscriptionManager; import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager; import android.telephony.TelephonyManager;
import android.util.EventLog;
import android.util.Log; import android.util.Log;
import android.util.Slog; import android.util.Slog;
import android.util.SparseBooleanArray; import android.util.SparseBooleanArray;
@@ -744,7 +743,7 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,
} }
@Override @Override
public void keyguardDone(boolean strongAuth, int targetUserId) { public void keyguardDone(boolean primaryAuth, int targetUserId) {
if (targetUserId != KeyguardUpdateMonitor.getCurrentUser()) { if (targetUserId != KeyguardUpdateMonitor.getCurrentUser()) {
return; return;
} }
@@ -765,7 +764,7 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,
} }
@Override @Override
public void keyguardDonePending(boolean strongAuth, int targetUserId) { public void keyguardDonePending(boolean primaryAuth, int targetUserId) {
Trace.beginSection("KeyguardViewMediator.mViewMediatorCallback#keyguardDonePending"); Trace.beginSection("KeyguardViewMediator.mViewMediatorCallback#keyguardDonePending");
if (DEBUG) Log.d(TAG, "keyguardDonePending"); if (DEBUG) Log.d(TAG, "keyguardDonePending");
if (targetUserId != KeyguardUpdateMonitor.getCurrentUser()) { if (targetUserId != KeyguardUpdateMonitor.getCurrentUser()) {
@@ -2219,16 +2218,6 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,
} }
}; };
private void keyguardDone() {
Trace.beginSection("KeyguardViewMediator#keyguardDone");
if (DEBUG) Log.d(TAG, "keyguardDone()");
userActivity();
EventLog.writeEvent(70000, 2);
Message msg = mHandler.obtainMessage(KEYGUARD_DONE);
mHandler.sendMessage(msg);
Trace.endSection();
}
/** /**
* This handler will be associated with the policy thread, which will also * This handler will be associated with the policy thread, which will also
* be the UI thread of the keyguard. Since the apis of the policy, and therefore * be the UI thread of the keyguard. Since the apis of the policy, and therefore
@@ -3124,7 +3113,8 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,
Trace.beginSection("KeyguardViewMediator#onWakeAndUnlocking"); Trace.beginSection("KeyguardViewMediator#onWakeAndUnlocking");
mWakeAndUnlocking = true; mWakeAndUnlocking = true;
keyguardDone(); mKeyguardViewControllerLazy.get().notifyKeyguardAuthenticated(/* primaryAuth */ false);
userActivity();
Trace.endSection(); Trace.endSection();
} }

View File

@@ -469,13 +469,13 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback imp
case MODE_DISMISS_BOUNCER: case MODE_DISMISS_BOUNCER:
Trace.beginSection("MODE_DISMISS_BOUNCER"); Trace.beginSection("MODE_DISMISS_BOUNCER");
mKeyguardViewController.notifyKeyguardAuthenticated( mKeyguardViewController.notifyKeyguardAuthenticated(
false /* strongAuth */); false /* primaryAuth */);
Trace.endSection(); Trace.endSection();
break; break;
case MODE_UNLOCK_COLLAPSING: case MODE_UNLOCK_COLLAPSING:
Trace.beginSection("MODE_UNLOCK_COLLAPSING"); Trace.beginSection("MODE_UNLOCK_COLLAPSING");
mKeyguardViewController.notifyKeyguardAuthenticated( mKeyguardViewController.notifyKeyguardAuthenticated(
false /* strongAuth */); false /* primaryAuth */);
Trace.endSection(); Trace.endSection();
break; break;
case MODE_SHOW_BOUNCER: case MODE_SHOW_BOUNCER:

View File

@@ -518,6 +518,12 @@ public class KeyguardViewMediatorTest extends SysuiTestCase {
assertTrue(mViewMediator.isShowingAndNotOccluded()); assertTrue(mViewMediator.isShowingAndNotOccluded());
} }
@Test
public void testWakeAndUnlocking() {
mViewMediator.onWakeAndUnlocking();
verify(mStatusBarKeyguardViewManager).notifyKeyguardAuthenticated(anyBoolean());
}
@Test @Test
@TestableLooper.RunWithLooper(setAsMainLooper = true) @TestableLooper.RunWithLooper(setAsMainLooper = true)
public void testDoKeyguardWhileInteractive_resets() { public void testDoKeyguardWhileInteractive_resets() {