Class ShadowBiometricManager

java.lang.Object
org.robolectric.shadows.ShadowBiometricManager

@Implements(className="android.hardware.biometrics.BiometricManager", minSdk=29, isInAndroidSdk=false) public class ShadowBiometricManager extends Object
Provides testing APIs for BiometricManager
  • Field Details

    • biometricServiceConnected

      protected static boolean biometricServiceConnected
  • Constructor Details

    • ShadowBiometricManager

      public ShadowBiometricManager()
  • Method Details

    • reset

      @Resetter public static void reset()
    • canAuthenticate

      @Implementation protected int canAuthenticate()
    • canAuthenticate

      @Implementation(minSdk=30) protected int canAuthenticate(int authenticators)
    • canAuthenticate

      @Implementation(minSdk=30) protected int canAuthenticate(int userId, int authenticators)
    • setCanAuthenticate

      public void setCanAuthenticate(boolean flag)
      Sets the value true to allow canAuthenticate() return BiometricManager.BIOMETRIC_SUCCESS If sets the value to false, result will depend on
      invalid reference
      BiometricManager#hasBiometrics(Context)
      Parameters:
      flag - to set can authenticate or not
    • setAuthenticatorType

      public void setAuthenticatorType(int type)
      Allow different result canAuthenticate(int), result will depend on the combination as described here For example, you can set the value BiometricManager.Authenticators.BIOMETRIC_STRONG to allow canAuthenticate(int) return BiometricManager.BIOMETRIC_SUCCESS when you passed BiometricManager.Authenticators.BIOMETRIC_WEAK as parameter in canAuthenticate(int)
      Parameters:
      type - to set the authenticatorType
      See Also:
    • setLastAuthenticationTime

      public void setLastAuthenticationTime(long time)
      Sets the last authentication time.
      Parameters:
      time - the last authentication time or BiometricManager.BIOMETRIC_NO_AUTHENTICATION
    • getLastAuthenticationTime

      @Implementation(minSdk=35) protected long getLastAuthenticationTime(int authenticators)
      Gets the last authentication time set by setLastAuthenticationTime(long).