Loading services/core/java/com/android/server/biometrics/AuthService.java +19 −7 Original line number Diff line number Diff line Loading @@ -27,6 +27,8 @@ import static android.Manifest.permission.USE_FINGERPRINT; import static android.hardware.biometrics.BiometricAuthenticator.TYPE_FACE; import static android.hardware.biometrics.BiometricAuthenticator.TYPE_FINGERPRINT; import static android.hardware.biometrics.BiometricAuthenticator.TYPE_IRIS; import static android.hardware.biometrics.BiometricAuthenticator.TYPE_NONE; import static android.hardware.biometrics.BiometricConstants.BIOMETRIC_ERROR_CANCELED; import static android.hardware.biometrics.BiometricManager.Authenticators; import android.annotation.NonNull; Loading Loading @@ -76,7 +78,6 @@ import java.util.List; */ public class AuthService extends SystemService { private static final String TAG = "AuthService"; private static final boolean DEBUG = false; private static final String SETTING_HIDL_DISABLED = "com.android.server.biometrics.AuthService.hidlDisabled"; private static final int DEFAULT_HIDL_DISABLED = 0; Loading Loading @@ -208,7 +209,6 @@ public class AuthService extends SystemService { public void authenticate(IBinder token, long sessionId, int userId, IBiometricServiceReceiver receiver, String opPackageName, PromptInfo promptInfo) throws RemoteException { // Only allow internal clients to authenticate with a different userId. final int callingUserId = UserHandle.getCallingUserId(); final int callingUid = Binder.getCallingUid(); Loading @@ -222,17 +222,18 @@ public class AuthService extends SystemService { } if (!checkAppOps(callingUid, opPackageName, "authenticate()")) { Slog.e(TAG, "Denied by app ops: " + opPackageName); authenticateFastFail("Denied by app ops: " + opPackageName, receiver); return; } if (!Utils.isForeground(callingUid, callingPid)) { Slog.e(TAG, "Caller is not foreground: " + opPackageName); if (token == null || receiver == null || opPackageName == null || promptInfo == null) { authenticateFastFail( "Unable to authenticate, one or more null arguments", receiver); return; } if (token == null || receiver == null || opPackageName == null || promptInfo == null) { Slog.e(TAG, "Unable to authenticate, one or more null arguments"); if (!Utils.isForeground(callingUid, callingPid)) { authenticateFastFail("Caller is not foreground: " + opPackageName, receiver); return; } Loading @@ -257,6 +258,17 @@ public class AuthService extends SystemService { } } private void authenticateFastFail(String message, IBiometricServiceReceiver receiver) { // notify caller in cases where authentication is aborted before calling into // IBiometricService without raising an exception Slog.e(TAG, message); try { receiver.onError(TYPE_NONE, BIOMETRIC_ERROR_CANCELED, 0 /*vendorCode */); } catch (RemoteException e) { Slog.e(TAG, "authenticateFastFail failed to notify caller", e); } } @Override public void cancelAuthentication(IBinder token, String opPackageName) throws RemoteException { Loading services/tests/servicestests/src/com/android/server/biometrics/AuthServiceTest.java +23 −1 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.server.biometrics; import static android.hardware.biometrics.BiometricAuthenticator.TYPE_NONE; import static android.hardware.biometrics.BiometricConstants.BIOMETRIC_ERROR_CANCELED; import static android.hardware.biometrics.BiometricConstants.BIOMETRIC_SUCCESS; import static junit.framework.Assert.assertEquals; Loading Loading @@ -234,6 +236,27 @@ public class AuthServiceTest { eq(mReceiver), eq(TEST_OP_PACKAGE_NAME), eq(promptInfo)); verify(mReceiver).onError(eq(TYPE_NONE), eq(BIOMETRIC_ERROR_CANCELED), anyInt()); } @Test public void testAuthenticate_missingRequiredParam() throws Exception { mAuthService = new AuthService(mContext, mInjector); mAuthService.onStart(); final PromptInfo promptInfo = new PromptInfo(); final long sessionId = 0; final int userId = 0; mAuthService.mImpl.authenticate( null /* token */, sessionId, userId, mReceiver, TEST_OP_PACKAGE_NAME, promptInfo); waitForIdle(); verify(mReceiver).onError(eq(TYPE_NONE), eq(BIOMETRIC_ERROR_CANCELED), anyInt()); } @Test Loading @@ -259,7 +282,6 @@ public class AuthServiceTest { eq(authenticators)); } @Test public void testHasEnrolledBiometrics_callsBiometricServiceHasEnrolledBiometrics() throws Exception { Loading Loading
services/core/java/com/android/server/biometrics/AuthService.java +19 −7 Original line number Diff line number Diff line Loading @@ -27,6 +27,8 @@ import static android.Manifest.permission.USE_FINGERPRINT; import static android.hardware.biometrics.BiometricAuthenticator.TYPE_FACE; import static android.hardware.biometrics.BiometricAuthenticator.TYPE_FINGERPRINT; import static android.hardware.biometrics.BiometricAuthenticator.TYPE_IRIS; import static android.hardware.biometrics.BiometricAuthenticator.TYPE_NONE; import static android.hardware.biometrics.BiometricConstants.BIOMETRIC_ERROR_CANCELED; import static android.hardware.biometrics.BiometricManager.Authenticators; import android.annotation.NonNull; Loading Loading @@ -76,7 +78,6 @@ import java.util.List; */ public class AuthService extends SystemService { private static final String TAG = "AuthService"; private static final boolean DEBUG = false; private static final String SETTING_HIDL_DISABLED = "com.android.server.biometrics.AuthService.hidlDisabled"; private static final int DEFAULT_HIDL_DISABLED = 0; Loading Loading @@ -208,7 +209,6 @@ public class AuthService extends SystemService { public void authenticate(IBinder token, long sessionId, int userId, IBiometricServiceReceiver receiver, String opPackageName, PromptInfo promptInfo) throws RemoteException { // Only allow internal clients to authenticate with a different userId. final int callingUserId = UserHandle.getCallingUserId(); final int callingUid = Binder.getCallingUid(); Loading @@ -222,17 +222,18 @@ public class AuthService extends SystemService { } if (!checkAppOps(callingUid, opPackageName, "authenticate()")) { Slog.e(TAG, "Denied by app ops: " + opPackageName); authenticateFastFail("Denied by app ops: " + opPackageName, receiver); return; } if (!Utils.isForeground(callingUid, callingPid)) { Slog.e(TAG, "Caller is not foreground: " + opPackageName); if (token == null || receiver == null || opPackageName == null || promptInfo == null) { authenticateFastFail( "Unable to authenticate, one or more null arguments", receiver); return; } if (token == null || receiver == null || opPackageName == null || promptInfo == null) { Slog.e(TAG, "Unable to authenticate, one or more null arguments"); if (!Utils.isForeground(callingUid, callingPid)) { authenticateFastFail("Caller is not foreground: " + opPackageName, receiver); return; } Loading @@ -257,6 +258,17 @@ public class AuthService extends SystemService { } } private void authenticateFastFail(String message, IBiometricServiceReceiver receiver) { // notify caller in cases where authentication is aborted before calling into // IBiometricService without raising an exception Slog.e(TAG, message); try { receiver.onError(TYPE_NONE, BIOMETRIC_ERROR_CANCELED, 0 /*vendorCode */); } catch (RemoteException e) { Slog.e(TAG, "authenticateFastFail failed to notify caller", e); } } @Override public void cancelAuthentication(IBinder token, String opPackageName) throws RemoteException { Loading
services/tests/servicestests/src/com/android/server/biometrics/AuthServiceTest.java +23 −1 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.server.biometrics; import static android.hardware.biometrics.BiometricAuthenticator.TYPE_NONE; import static android.hardware.biometrics.BiometricConstants.BIOMETRIC_ERROR_CANCELED; import static android.hardware.biometrics.BiometricConstants.BIOMETRIC_SUCCESS; import static junit.framework.Assert.assertEquals; Loading Loading @@ -234,6 +236,27 @@ public class AuthServiceTest { eq(mReceiver), eq(TEST_OP_PACKAGE_NAME), eq(promptInfo)); verify(mReceiver).onError(eq(TYPE_NONE), eq(BIOMETRIC_ERROR_CANCELED), anyInt()); } @Test public void testAuthenticate_missingRequiredParam() throws Exception { mAuthService = new AuthService(mContext, mInjector); mAuthService.onStart(); final PromptInfo promptInfo = new PromptInfo(); final long sessionId = 0; final int userId = 0; mAuthService.mImpl.authenticate( null /* token */, sessionId, userId, mReceiver, TEST_OP_PACKAGE_NAME, promptInfo); waitForIdle(); verify(mReceiver).onError(eq(TYPE_NONE), eq(BIOMETRIC_ERROR_CANCELED), anyInt()); } @Test Loading @@ -259,7 +282,6 @@ public class AuthServiceTest { eq(authenticators)); } @Test public void testHasEnrolledBiometrics_callsBiometricServiceHasEnrolledBiometrics() throws Exception { Loading