Clear identity when checking strongauth flags

Bug: 161557889
Bug: 161566755

Test: atest FingerprintManagerTest
Test: AccessibilityFingerprintGestureTest#testGestureDetectionListener_whenAuthenticationStartsAndStops_calledBack
Change-Id: Icb273fc0cf2ce1891550130539c0b2e6e788b533
This commit is contained in:
Kevin Chyn
2020-07-20 10:38:08 -07:00
parent c486219bcb
commit c88cd4418c

View File

@@ -135,19 +135,27 @@ public class FingerprintService extends SystemService {
return; return;
} }
if (Utils.isUserEncryptedOrLockdown(mLockPatternUtils, userId) // Keyguard check must be done on the caller's binder identity, since it also checks
&& Utils.isKeyguard(getContext(), opPackageName)) { // permission.
// If this happens, something in KeyguardUpdateMonitor is wrong. final boolean isKeyguard = Utils.isKeyguard(getContext(), opPackageName);
// SafetyNet for b/79776455
EventLog.writeEvent(0x534e4554, "79776455"); // Clear calling identity when checking LockPatternUtils for StrongAuth flags.
Slog.e(TAG, "Authenticate invoked when user is encrypted or lockdown"); final long identity = Binder.clearCallingIdentity();
return; try {
if (isKeyguard && Utils.isUserEncryptedOrLockdown(mLockPatternUtils, userId)) {
// If this happens, something in KeyguardUpdateMonitor is wrong.
// SafetyNet for b/79776455
EventLog.writeEvent(0x534e4554, "79776455");
Slog.e(TAG, "Authenticate invoked when user is encrypted or lockdown");
return;
}
} finally {
Binder.restoreCallingIdentity(identity);
} }
final boolean restricted = getContext().checkCallingPermission(MANAGE_FINGERPRINT) final boolean restricted = getContext().checkCallingPermission(MANAGE_FINGERPRINT)
!= PackageManager.PERMISSION_GRANTED; != PackageManager.PERMISSION_GRANTED;
final int statsClient = Utils.isKeyguard(getContext(), opPackageName) final int statsClient = isKeyguard ? BiometricsProtoEnums.CLIENT_KEYGUARD
? BiometricsProtoEnums.CLIENT_KEYGUARD
: BiometricsProtoEnums.CLIENT_FINGERPRINT_MANAGER; : BiometricsProtoEnums.CLIENT_FINGERPRINT_MANAGER;
mFingerprint21.scheduleAuthenticate(token, operationId, userId, 0 /* cookie */, mFingerprint21.scheduleAuthenticate(token, operationId, userId, 0 /* cookie */,
new ClientMonitorCallbackConverter(receiver), opPackageName, surface, new ClientMonitorCallbackConverter(receiver), opPackageName, surface,