Package org.robolectric.shadows
Class ShadowBiometricPrompt
java.lang.Object
org.robolectric.shadows.ShadowBiometricPrompt
@Implements(className="android.hardware.biometrics.BiometricPrompt",
minSdk=28,
isInAndroidSdk=false)
public class ShadowBiometricPrompt
extends Object
Provides testing APIs for
BiometricPrompt-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidauthenticate(BiometricPrompt.CryptoObject crypto, CancellationSignal cancel, Executor executor, BiometricPrompt.AuthenticationCallback callback) protected voidauthenticate(CancellationSignal cancel, Executor executor, BiometricPrompt.AuthenticationCallback callback) static voidSimulates a successful authentication and triggersBiometricPrompt.AuthenticationCallback.onAuthenticationSucceeded(android.hardware.biometrics.BiometricPrompt.AuthenticationResult).static voidauthenticateCurrentSessionWithError(int errorCode, String message) Simulates an error authentication and triggersBiometricPrompt.AuthenticationCallback.onAuthenticationError(int, java.lang.CharSequence).static voidCancels the current authentication session and triggersCancellationSignal.cancel().static voidSimulates a failed authentication by triggeringBiometricPrompt.AuthenticationCallback.onAuthenticationFailed().static BiometricPromptReturns theBiometricPromptfor the current authentication session, ornullif there is no session in progress.static voidreset()
-
Constructor Details
-
ShadowBiometricPrompt
public ShadowBiometricPrompt()
-
-
Method Details
-
reset
-
getCurrentPrompt
Returns theBiometricPromptfor the current authentication session, ornullif there is no session in progress.Use this method to check if an authentication session is in progress, and/or to perform additional assertions on the
BiometricPromptbeing shown such as its title or description. -
cancelCurrentSession
public static void cancelCurrentSession()Cancels the current authentication session and triggersCancellationSignal.cancel(). -
authenticateCurrentSessionSuccessfully
public static void authenticateCurrentSessionSuccessfully()Simulates a successful authentication and triggersBiometricPrompt.AuthenticationCallback.onAuthenticationSucceeded(android.hardware.biometrics.BiometricPrompt.AuthenticationResult). -
authenticateCurrentSessionWithError
Simulates an error authentication and triggersBiometricPrompt.AuthenticationCallback.onAuthenticationError(int, java.lang.CharSequence).- Parameters:
errorCode- The error code to be returned.message- The error message to be returned.
-
failCurrentSessionOnce
public static void failCurrentSessionOnce()Simulates a failed authentication by triggeringBiometricPrompt.AuthenticationCallback.onAuthenticationFailed().Note that this does not clear the current session. A failed authentication typically means the user can retry.
-
authenticate
@Filter(order=AFTER) protected void authenticate(CancellationSignal cancel, Executor executor, BiometricPrompt.AuthenticationCallback callback) -
authenticate
@Filter(order=AFTER) protected void authenticate(BiometricPrompt.CryptoObject crypto, CancellationSignal cancel, Executor executor, BiometricPrompt.AuthenticationCallback callback)
-