Package org.robolectric.shadows
Class ShadowFingerprintManager
java.lang.Object
org.robolectric.shadows.ShadowFingerprintManager
@Implements(android.hardware.fingerprint.FingerprintManager.class) public class ShadowFingerprintManager extends Object
Provides testing APIs for
FingerprintManager
-
Field Summary
Fields Modifier and Type Field Description protected FingerprintManager.CryptoObject
pendingCryptoObject
-
Constructor Summary
Constructors Constructor Description ShadowFingerprintManager()
-
Method Summary
Modifier and Type Method Description protected void
authenticate(FingerprintManager.CryptoObject crypto, CancellationSignal cancel, int flags, FingerprintManager.AuthenticationCallback callback, Handler handler)
Success or failure can be simulated with a subsequent call toauthenticationSucceeds()
orauthenticationFails()
.void
authenticationFails()
Simulates a failed fingerprint authentication.void
authenticationSucceeds()
Simulates a successful fingerprint authentication.protected FingerprintManager.AuthenticationResult
createAuthenticationResult()
protected List<Fingerprint>
getEnrolledFingerprints()
int
getFingerprintId(int index)
protected boolean
hasEnrolledFingerprints()
Returnsfalse
by default, or the value specified viasetHasEnrolledFingerprints(boolean)
.protected boolean
isHardwareDetected()
void
setDefaultFingerprints(int num)
Enrolls the given number of fingerprints, which will be returned ingetEnrolledFingerprints()
.void
setHasEnrolledFingerprints(boolean hasEnrolledFingerprints)
Deprecated.usesetDefaultFingerprints(int)
instead.void
setIsHardwareDetected(boolean isHardwareDetected)
Sets the return value ofFingerprintManager.isHardwareDetected()
.
-
Field Details
-
Constructor Details
-
ShadowFingerprintManager
public ShadowFingerprintManager()
-
-
Method Details
-
authenticationSucceeds
public void authenticationSucceeds()Simulates a successful fingerprint authentication. An authentication request must have been issued withFingerprintManager.authenticate(CryptoObject, CancellationSignal, int, AuthenticationCallback, Handler)
and not cancelled. -
createAuthenticationResult
-
authenticationFails
public void authenticationFails()Simulates a failed fingerprint authentication. An authentication request must have been issued withFingerprintManager.authenticate(CryptoObject, CancellationSignal, int, AuthenticationCallback, Handler)
and not cancelled. -
authenticate
@Implementation(minSdk=23) protected void authenticate(FingerprintManager.CryptoObject crypto, CancellationSignal cancel, int flags, FingerprintManager.AuthenticationCallback callback, Handler handler)Success or failure can be simulated with a subsequent call toauthenticationSucceeds()
orauthenticationFails()
. -
setHasEnrolledFingerprints
Deprecated.usesetDefaultFingerprints(int)
instead.Sets the return value ofFingerprintManager.hasEnrolledFingerprints()
. -
hasEnrolledFingerprints
Returnsfalse
by default, or the value specified viasetHasEnrolledFingerprints(boolean)
. -
getEnrolledFingerprints
- Returns:
- lists of current fingerprint items, the list be set via
setDefaultFingerprints(int)
-
getFingerprintId
public int getFingerprintId(int index)- Returns:
- Returns the finger ID for the given index.
-
setDefaultFingerprints
public void setDefaultFingerprints(int num)Enrolls the given number of fingerprints, which will be returned ingetEnrolledFingerprints()
.- Parameters:
num
- the quantity of fingerprint item.
-
setIsHardwareDetected
public void setIsHardwareDetected(boolean isHardwareDetected)Sets the return value ofFingerprintManager.isHardwareDetected()
. -
isHardwareDetected
- Returns:
- false by default, or the value specified via
setIsHardwareDetected(boolean)
-