Fix keyguard logic for listening to sfps

Test: atest KeyguardUpdateMonitorTest
Test: manual
Bug: 245343077O
Change-Id: Ic71c82cf9f07fbb3e57039bcff197616b8ddb3cf
This commit is contained in:
Joshua McCloskey
2022-11-01 20:47:15 +00:00
parent 1eaa038b62
commit 494ef026b2
2 changed files with 29 additions and 38 deletions

View File

@@ -384,6 +384,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
protected Handler getHandler() { protected Handler getHandler() {
return mHandler; return mHandler;
} }
private final Handler mHandler; private final Handler mHandler;
private final IBiometricEnabledOnKeyguardCallback mBiometricEnabledCallback = private final IBiometricEnabledOnKeyguardCallback mBiometricEnabledCallback =
@@ -708,6 +709,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
/** /**
* Request to listen for face authentication when an app is occluding keyguard. * Request to listen for face authentication when an app is occluding keyguard.
*
* @param request if true and mKeyguardOccluded, request face auth listening, else default * @param request if true and mKeyguardOccluded, request face auth listening, else default
* to normal behavior. * to normal behavior.
* See {@link KeyguardUpdateMonitor#shouldListenForFace()} * See {@link KeyguardUpdateMonitor#shouldListenForFace()}
@@ -720,6 +722,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
/** /**
* Request to listen for fingerprint when an app is occluding keyguard. * Request to listen for fingerprint when an app is occluding keyguard.
*
* @param request if true and mKeyguardOccluded, request fingerprint listening, else default * @param request if true and mKeyguardOccluded, request fingerprint listening, else default
* to normal behavior. * to normal behavior.
* See {@link KeyguardUpdateMonitor#shouldListenForFingerprint(boolean)} * See {@link KeyguardUpdateMonitor#shouldListenForFingerprint(boolean)}
@@ -2225,22 +2228,20 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
Settings.System.getUriFor(Settings.System.TIME_12_24), Settings.System.getUriFor(Settings.System.TIME_12_24),
false, mTimeFormatChangeObserver, UserHandle.USER_ALL); false, mTimeFormatChangeObserver, UserHandle.USER_ALL);
if (isSfpsSupported() && isSfpsEnrolled()) { updateSfpsRequireScreenOnToAuthPref();
updateSfpsRequireScreenOnToAuthPref(); mSfpsRequireScreenOnToAuthPrefObserver = new ContentObserver(mHandler) {
mSfpsRequireScreenOnToAuthPrefObserver = new ContentObserver(mHandler) { @Override
@Override public void onChange(boolean selfChange) {
public void onChange(boolean selfChange) { updateSfpsRequireScreenOnToAuthPref();
updateSfpsRequireScreenOnToAuthPref(); }
} };
};
mContext.getContentResolver().registerContentObserver( mContext.getContentResolver().registerContentObserver(
mSecureSettings.getUriFor( mSecureSettings.getUriFor(
Settings.Secure.SFPS_REQUIRE_SCREEN_ON_TO_AUTH_ENABLED), Settings.Secure.SFPS_REQUIRE_SCREEN_ON_TO_AUTH_ENABLED),
false, false,
mSfpsRequireScreenOnToAuthPrefObserver, mSfpsRequireScreenOnToAuthPrefObserver,
getCurrentUser()); getCurrentUser());
}
} }
protected void updateSfpsRequireScreenOnToAuthPref() { protected void updateSfpsRequireScreenOnToAuthPref() {
@@ -2635,27 +2636,21 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
!(mFingerprintLockedOut && mBouncerIsOrWillBeShowing && mCredentialAttempted); !(mFingerprintLockedOut && mBouncerIsOrWillBeShowing && mCredentialAttempted);
final boolean isEncryptedOrLockdownForUser = isEncryptedOrLockdown(user); final boolean isEncryptedOrLockdownForUser = isEncryptedOrLockdown(user);
final boolean shouldListenUdfpsState = !isUdfps final boolean shouldListenUdfpsState = !isUdfps
|| (!userCanSkipBouncer || (!userCanSkipBouncer
&& !isEncryptedOrLockdownForUser && !isEncryptedOrLockdownForUser
&& userDoesNotHaveTrust); && userDoesNotHaveTrust);
boolean shouldListenSfpsState = true; boolean shouldListenSideFpsState = true;
// If mSfpsRequireScreenOnToAuthPrefEnabled, require screen on to listen to SFPS if (isSfpsSupported() && isSfpsEnrolled()) {
if (isSfpsSupported() && isSfpsEnrolled() && mSfpsRequireScreenOnToAuthPrefEnabled) { shouldListenSideFpsState =
shouldListenSfpsState = isDeviceInteractive(); mSfpsRequireScreenOnToAuthPrefEnabled ? isDeviceInteractive() : true;
} }
boolean shouldListen = shouldListenKeyguardState && shouldListenUserState boolean shouldListen = shouldListenKeyguardState && shouldListenUserState
&& shouldListenBouncerState && !isFingerprintLockedOut(); && shouldListenBouncerState && shouldListenUdfpsState && !isFingerprintLockedOut()
&& shouldListenSideFpsState;
if (isUdfpsSupported()) {
shouldListen = shouldListen && shouldListenUdfpsState;
}
if (isSfpsSupported()) {
shouldListen = shouldListen && shouldListenSfpsState;
}
maybeLogListenerModelData( maybeLogListenerModelData(
new KeyguardFingerprintListenModel( new KeyguardFingerprintListenModel(
@@ -2677,7 +2672,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
mKeyguardOccluded, mKeyguardOccluded,
mOccludingAppRequestingFp, mOccludingAppRequestingFp,
mIsPrimaryUser, mIsPrimaryUser,
shouldListenSfpsState, shouldListenSideFpsState,
shouldListenForFingerprintAssistant, shouldListenForFingerprintAssistant,
mSwitchingUser, mSwitchingUser,
isUdfps, isUdfps,

View File

@@ -1162,7 +1162,10 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
public void testStartsListeningForSfps_whenKeyguardIsVisible_ifRequireScreenOnToAuthEnabled() public void testStartsListeningForSfps_whenKeyguardIsVisible_ifRequireScreenOnToAuthEnabled()
throws RemoteException { throws RemoteException {
// SFPS supported and enrolled // SFPS supported and enrolled
setup_SfpsProps(); final ArrayList<FingerprintSensorPropertiesInternal> props = new ArrayList<>();
props.add(newFingerprintSensorPropertiesInternal(TYPE_POWER_BUTTON));
when(mAuthController.getSfpsProps()).thenReturn(props);
when(mAuthController.isSfpsEnrolled(anyInt())).thenReturn(true);
// WHEN require screen on to auth is disabled, and keyguard is not awake // WHEN require screen on to auth is disabled, and keyguard is not awake
when(mSecureSettings.getIntForUser(anyString(), anyInt(), anyInt())).thenReturn(0); when(mSecureSettings.getIntForUser(anyString(), anyInt(), anyInt())).thenReturn(0);
@@ -1201,13 +1204,6 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
assertThat(mKeyguardUpdateMonitor.shouldListenForFingerprint(false)).isTrue(); assertThat(mKeyguardUpdateMonitor.shouldListenForFingerprint(false)).isTrue();
} }
private void setup_SfpsProps() {
final ArrayList<FingerprintSensorPropertiesInternal> props = new ArrayList<>();
props.add(newFingerprintSensorPropertiesInternal(TYPE_POWER_BUTTON));
when(mAuthController.getSfpsProps()).thenReturn(props);
when(mAuthController.isSfpsEnrolled(anyInt())).thenReturn(true);
}
private FingerprintSensorPropertiesInternal newFingerprintSensorPropertiesInternal( private FingerprintSensorPropertiesInternal newFingerprintSensorPropertiesInternal(
@FingerprintSensorProperties.SensorType int sensorType) { @FingerprintSensorProperties.SensorType int sensorType) {
return new FingerprintSensorPropertiesInternal( return new FingerprintSensorPropertiesInternal(