Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 49a5d9df authored by Haining Chen's avatar Haining Chen
Browse files

Disable adaptive auth for automotive devices by default

Bug: 323085596
Bug: 285053096
Test: atest AdaptiveAuthServiceTest
Change-Id: Ide837783914e88656c6b69f0b532740e6ed0d670
parent 96ff9923
Loading
Loading
Loading
Loading
+6 −0
Original line number Original line Diff line number Diff line
@@ -20,6 +20,7 @@ import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.SOM


import android.app.KeyguardManager;
import android.app.KeyguardManager;
import android.content.Context;
import android.content.Context;
import android.content.pm.PackageManager;
import android.hardware.biometrics.AuthenticationStateListener;
import android.hardware.biometrics.AuthenticationStateListener;
import android.hardware.biometrics.BiometricManager;
import android.hardware.biometrics.BiometricManager;
import android.hardware.biometrics.BiometricSourceType;
import android.hardware.biometrics.BiometricSourceType;
@@ -187,6 +188,11 @@ public class AdaptiveAuthService extends SystemService {
    }
    }


    private void reportAuthAttempt(int authType, boolean success, int userId) {
    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) {
        if (success) {
            // Deleting the entry effectively resets the counter of failed attempts for the user
            // Deleting the entry effectively resets the counter of failed attempts for the user
            mFailedAttemptsForUser.delete(userId);
            mFailedAttemptsForUser.delete(userId);
+6 −0
Original line number Original line Diff line number Diff line
@@ -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 com.android.server.adaptiveauth.AdaptiveAuthService.MAX_ALLOWED_FAILED_AUTH_ATTEMPTS;


import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assume.assumeTrue;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.spy;
@@ -32,6 +33,7 @@ import static org.mockito.Mockito.when;


import android.app.KeyguardManager;
import android.app.KeyguardManager;
import android.content.Context;
import android.content.Context;
import android.content.pm.PackageManager;
import android.hardware.biometrics.AuthenticationStateListener;
import android.hardware.biometrics.AuthenticationStateListener;
import android.hardware.biometrics.BiometricManager;
import android.hardware.biometrics.BiometricManager;
import android.os.RemoteException;
import android.os.RemoteException;
@@ -103,6 +105,10 @@ public class AdaptiveAuthServiceTest {
        mSetFlagsRule.enableFlags(FLAG_REPORT_BIOMETRIC_AUTH_ATTEMPTS);
        mSetFlagsRule.enableFlags(FLAG_REPORT_BIOMETRIC_AUTH_ATTEMPTS);


        mContext = spy(ApplicationProvider.getApplicationContext());
        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(BiometricManager.class)).thenReturn(mBiometricManager);
        when(mContext.getSystemService(KeyguardManager.class)).thenReturn(mKeyguardManager);
        when(mContext.getSystemService(KeyguardManager.class)).thenReturn(mKeyguardManager);