Skip to content
Snippets Groups Projects
Commit 5566c330 authored by Haining Chen's avatar Haining Chen Committed by Android (Google) Code Review
Browse files

Merge "Disable adaptive auth for automotive devices by default" into main

parents 1b037b83 49a5d9df
No related branches found
No related tags found
No related merge requests found
......@@ -20,6 +20,7 @@ import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.SOM
import android.app.KeyguardManager;
import android.content.Context;
import android.content.pm.PackageManager;
import android.hardware.biometrics.AuthenticationStateListener;
import android.hardware.biometrics.BiometricManager;
import android.hardware.biometrics.BiometricSourceType;
......@@ -187,6 +188,11 @@ public class AdaptiveAuthService extends SystemService {
}
private void reportAuthAttempt(int authType, boolean success, int userId) {
// Disable adaptive auth for automotive devices by default
if (getContext().getPackageManager().hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE)) {
return;
}
if (success) {
// Deleting the entry effectively resets the counter of failed attempts for the user
mFailedAttemptsForUser.delete(userId);
......
......@@ -24,6 +24,7 @@ import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.SOM
import static com.android.server.adaptiveauth.AdaptiveAuthService.MAX_ALLOWED_FAILED_AUTH_ATTEMPTS;
import static org.junit.Assert.assertEquals;
import static org.junit.Assume.assumeTrue;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
......@@ -32,6 +33,7 @@ import static org.mockito.Mockito.when;
import android.app.KeyguardManager;
import android.content.Context;
import android.content.pm.PackageManager;
import android.hardware.biometrics.AuthenticationStateListener;
import android.hardware.biometrics.BiometricManager;
import android.os.RemoteException;
......@@ -103,6 +105,10 @@ public class AdaptiveAuthServiceTest {
mSetFlagsRule.enableFlags(FLAG_REPORT_BIOMETRIC_AUTH_ATTEMPTS);
mContext = spy(ApplicationProvider.getApplicationContext());
assumeTrue("Adaptive auth is disabled on device",
!mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE));
when(mContext.getSystemService(BiometricManager.class)).thenReturn(mBiometricManager);
when(mContext.getSystemService(KeyguardManager.class)).thenReturn(mKeyguardManager);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment