目录

FaceManager

Class Info

public final class FaceManager

Main entrance to the facial authentication API of FIDO.

Public Field Summary

Return Code

Value

Description

Solution

FACE_SUCCESS

0

Facial authentication is available.

-

FACE_ERROR_HW_UNAVAILABLE

1

No authentication hardware is available.

Verify that the device works properly or use another device.

FACE_ERROR_UNABLE_TO_PROCESS

2

The sensor cannot process the current face image.

Verify that the device works properly or use another device.

FACE_ERROR_TIMEOUT

3

The request timed out.

Try again.

FACE_ERROR_NO_SPACE

4

The storage space is insufficient for registration.

Verify that the device works properly or use another device.

FACE_ERROR_CANCELED

5

The operation is canceled because the facial authentication sensor is unavailable.

Verify that the device works properly or use another device.

FACE_ERROR_UNABLE_TO_REMOVE

6

Face data failed to be deleted.

Verify that the device works properly or use another device.

FACE_ERROR_LOCKOUT

7

The number of unlocking attempts reaches the maximum.

-

FACE_ERROR_VENDOR

8

Vendor-defined errors.

-

FACE_ERROR_LOCKOUT_PERMANENT

9

Facial authentication is disabled.

-

FACE_ERROR_USER_CANCELED

10

The user cancels the authentication.

-

FACE_ERROR_NOT_ENROLLED

11

No facial authentication template is enrolled before authentication.

-

FACE_ERROR_HW_NOT_PRESENT

12

The device does not have a facial authentication sensor.

-

FACE_ERROR_VENDOR_BASE

1000

Vendor-defined errors.

-

FACE_ERROR_SYS_INTEGRITY_FAILED

1001

The device failed the system integrity check. The possible cause is that the device is unlocked or rooted.

Use a device meeting the security requirements.

FACE_ERROR_UNSUPPORTED_OS_VER

1002

Facial authentication is not supported in this OS version.

-

FACE_ERROR_HMS_FRAMEWORK_ERROR

1003

An HMS Core framework error occurred.

Update HMS Core (APK) to the latest version and clear app data.

FACE_ACQUIRED_GOOD

0

The obtained face image is clear.

-

FACE_ACQUIRED_INSUFFICIENT

1

The face image does not meet the processing requirements.

-

FACE_ACQUIRED_TOO_BRIGHT

2

The obtained face image is too bright due to high illumination.

-

FACE_ACQUIRED_TOO_DARK

3

The obtained face image is too dark due to low illumination.

-

FACE_ACQUIRED_TOO_CLOSE

4

The face position is too close to the user device.

-

FACE_ACQUIRED_TOO_FAR

5

The face position is too far away from the user device.

-

FACE_ACQUIRED_TOO_HIGH

6

The user device position is too high, and only the top part of the face is obtained.

-

FACE_ACQUIRED_TOO_LOW

7

The user device position is too low, and only the bottom part of the face is obtained.

-

FACE_ACQUIRED_TOO_RIGHT

8

The user device position is to the right, and only the right part of the face is obtained.

-

FACE_ACQUIRED_TOO_LEFT

9

The user device position is to the left, and only the left part of the face is obtained.

-

FACE_ACQUIRED_TOO_MUCH_MOTION

10

The face moves too frequently during image collection.

-

FACE_ACQUIRED_POOR_GAZE

11

The user's focus is too far away from the sensor, and an important part of the user's face is not detected.

-

FACE_ACQUIRED_NOT_DETECTED

12

The sensor detects no face.

-

FACE_ACQUIRED_VENDOR

13

Vendor-defined errors.

-

FACE_ACQUIRED_VENDOR:1038

1038

A face was detected. (BioAuthnCallback#onAuthHelp)

-

FACE_ACQUIRED_VENDOR:1012

1012

The face does not match the enrolled one. (BioAuthnCallback#onAuthHelp)

-

FACE_ERROR_VENDOR:1012

1012

The camera permission is not granted. (BioAuthnCallback#onAuthError)

-

FACE_MODALITY_UNSUPPORTED

1

Face modality (2D or 3D) check is not supported.

-

FACE_MODALITY_2D

2

2D face modality.

-

FACE_MODALITY_3D

3

3D face modality.

-

Public Constructor Summary

Constructor Name

FaceManager(android.content.Context context)

Constructs a FaceManager object for facial authentication, which is used to call the facial authentication API of FIDO BioAuthn.

Public Method Summary

Qualifier and Type

Method Name and Description

public int

canAuth()

Checks whether facial authentication can be used, including checking whether facial authentication is supported in this OS version, whether the device hardware supports facial authentication, and whether a facial authentication template has been enrolled.

public void

auth(final CryptoObject crypto, final android.os.CancellationSignal cancel, final int flags, final BioAuthnCallback callback, final android.os.Handler handler)

Initiates a facial authentication request on the device.

public boolean

isHardwareDetected()

Checks whether the device supports facial recognition. The value true will be returned if the device supports facial recognition, and false otherwise.

public boolean

hasEnrolledTemplates()

Checks whether the device has an enrolled face. The value true will be returned if the device has an enrolled face, and false otherwise.

public int

getFaceModality()

Checks whether the current face modality is 3D or 2D.

Public Field

[h2]FACE_SUCCESS

Field

public static final int FACE_SUCCESS

errorCode returned by the onAuthError method of BioAuthnCallback after the auth API is called.

Value: 0

Facial authentication is available. For other constant values, please refer to Constant-values.

[h2]FACE_ERROR_HW_UNAVAILABLE

Field

public static final int FACE_ERROR_HW_UNAVAILABLE

errorCode returned by the onAuthError method of BioAuthnCallback after the auth API is called.

Value: 1

No authentication hardware is available. For other constant values, please refer to Constant-values.

[h2]FACE_ERROR_UNABLE_TO_PROCESS

Field

public static final int FACE_ERROR_UNABLE_TO_PROCESS

errorCode returned by the onAuthError method of BioAuthnCallback after the auth API is called.

Value: 2

The sensor cannot process the current face image. For other constant values, please refer to Constant-values.

[h2]FACE_ERROR_TIMEOUT

Field

public static final int FACE_ERROR_TIMEOUT

errorCode returned by the onAuthError method of BioAuthnCallback after the auth API is called.

Value: 3

The request timed out. For other constant values, please refer to Constant-values.

[h2]FACE_ERROR_NO_SPACE

Field

public static final int FACE_ERROR_NO_SPACE

errorCode returned by the onAuthError method of BioAuthnCallback after the auth API is called.

Value: 4

The storage space is insufficient for registration. For other constant values, please refer to Constant-values.

[h2]FACE_ERROR_CANCELED

Field

public static final int FACE_ERROR_CANCELED

errorCode returned by the onAuthError method of BioAuthnCallback after the auth API is called.

Value: 5

The operation is canceled because the facial authentication sensor is unavailable. For other constant values, please refer to Constant-values.

[h2]FACE_ERROR_UNABLE_TO_REMOVE

Field

public static final int FACE_ERROR_UNABLE_TO_REMOVE

errorCode returned by the onAuthError method of BioAuthnCallback after the auth API is called.

Value: 6

Failed to delete face data. For other constant values, please refer to Constant-values.

[h2]FACE_ERROR_LOCKOUT

Field

public static final int FACE_ERROR_LOCKOUT

errorCode returned by the onAuthError method of BioAuthnCallback after the auth API is called.

Value: 7

The number of unlocking attempts reaches the maximum. For other constant values, please refer to Constant-values.

[h2]FACE_ERROR_VENDOR

Field

public static final int FACE_ERROR_VENDOR

errorCode returned by the onAuthError method of BioAuthnCallback after the auth API is called.

Value: 8

Vendor-defined errors. For other constant values, please refer to Constant-values.

[h2]FACE_ERROR_LOCKOUT_PERMANENT

Field

public static final int FACE_ERROR_LOCKOUT_PERMANENT

errorCode returned by the onAuthError method of BioAuthnCallback after the auth API is called.

Value: 9

Facial authentication is disabled. For other constant values, please refer to Constant-values.

[h2]FACE_ERROR_USER_CANCELED

Field

public static final int FACE_ERROR_USER_CANCELED

errorCode returned by the onAuthError method of BioAuthnCallback after the auth API is called.

Value: 10

The user cancels the authentication. For other constant values, please refer to Constant-values.

[h2]FACE_ERROR_NOT_ENROLLED

Field

public static final int FACE_ERROR_NOT_ENROLLED

errorCode returned by the onAuthError method of BioAuthnCallback after the auth API is called.

Value: 11

No facial authentication template is enrolled before authentication. For other constant values, please refer to Constant-values.

[h2]FACE_ERROR_HW_NOT_PRESENT

Field

public static final int FACE_ERROR_HW_NOT_PRESENT

errorCode returned by the onAuthError method of BioAuthnCallback after the auth API is called.

Value: 12

The device does not have a facial authentication sensor. For other constant values, please refer to Constant-values.

[h2]FACE_ERROR_VENDOR_BASE

Field

public static final int FACE_ERROR_VENDOR_BASE

errorCode returned by the onAuthError method of BioAuthnCallback after the auth API is called.

Value: 1000

Vendor-defined errors. For other constant values, please refer to Constant-values.

[h2]FACE_ERROR_SYS_INTEGRITY_FAILED

Field

public static final int FACE_ERROR_SYS_INTEGRITY_FAILED

errorCode returned by the onAuthError method of BioAuthnCallback after the auth API is called.

Value: 1001

The device failed the system integrity check, for example, the device has been rooted or the system integrity has been damaged. For other constant values, please refer to Constant-values.

[h2]FACE_ERROR_UNSUPPORTED_OS_VER

Field

public static final int FACE_ERROR_UNSUPPORTED_OS_VER

errorCode returned by the onAuthError method of BioAuthnCallback after the auth API is called.

Value: 1002

Facial authentication is not supported in this OS version. Facial authentication of FIDO BioAuthn can only be used on devices running EMUI 10.0.0 or later. For other constant values, please refer to Constant-values.

[h2]FACE_ERROR_HMS_FRAMEWORK_ERROR

Field

public static final int FACE_ERROR_HMS_FRAMEWORK_ERROR

errorCode returned by the onAuthError method of BioAuthnCallback after the auth API is called.

Value: 1003

An HMS Core framework error occurred. For other constant values, please refer to Constant-values.

[h2]FACE_ACQUIRED_GOOD

Field

public static final int FACE_ACQUIRED_GOOD

helpCode returned by the onAuthHelp method of BioAuthnCallback after the auth API is called.

Value: 0

The obtained face image is clear. For other constant values, please refer to Constant-values.

[h2]FACE_ACQUIRED_INSUFFICIENT

Field

public static final int FACE_ACQUIRED_INSUFFICIENT

helpCode returned by the onAuthHelp method of BioAuthnCallback after the auth API is called.

Value: 1

The face image does not meet the processing requirements. For other constant values, please refer to Constant-values.

[h2]FACE_ACQUIRED_TOO_BRIGHT

Field

public static final int FACE_ACQUIRED_TOO_BRIGHT

helpCode returned by the onAuthHelp method of BioAuthnCallback after the auth API is called.

Value: 2

The obtained face image is too bright due to high illumination. For other constant values, please refer to Constant-values.

[h2]FACE_ACQUIRED_TOO_DARK

Field

public static final int FACE_ACQUIRED_TOO_DARK

helpCode returned by the onAuthHelp method of BioAuthnCallback after the auth API is called.

Value: 3

The obtained face image is too dark due to low illumination. For other constant values, please refer to Constant-values.

[h2]FACE_ACQUIRED_TOO_CLOSE

Field

public static final int FACE_ACQUIRED_TOO_CLOSE

helpCode returned by the onAuthHelp method of BioAuthnCallback after the auth API is called.

Value: 4

The face position is too close to the user device. For other constant values, please refer to Constant-values.

[h2]FACE_ACQUIRED_TOO_FAR

Field

public static final int FACE_ACQUIRED_TOO_FAR

helpCode returned by the onAuthHelp method of BioAuthnCallback after the auth API is called.

Value: 5

The face position is too far away from the user device. For other constant values, please refer to Constant-values.

[h2]FACE_ACQUIRED_TOO_HIGH

Field

public static final int FACE_ACQUIRED_TOO_HIGH

helpCode returned by the onAuthHelp method of BioAuthnCallback after the auth API is called.

Value: 6

The user device position is too high, and only the top part of the face is obtained. For other constant values, please refer to Constant-values.

[h2]FACE_ACQUIRED_TOO_LOW

Field

public static final int FACE_ACQUIRED_TOO_LOW

helpCode returned by the onAuthHelp method of BioAuthnCallback after the auth API is called.

Value: 7

The user device position is too low, and only the bottom part of the face is obtained. For other constant values, please refer to Constant-values.

[h2]FACE_ACQUIRED_TOO_RIGHT

Field

public static final int FACE_ACQUIRED_TOO_RIGHT

helpCode returned by the onAuthHelp method of BioAuthnCallback after the auth API is called.

Value: 8

The user device position is to the right, and only the right part of the face is obtained. For other constant values, please refer to Constant-values.

[h2]FACE_ACQUIRED_TOO_LEFT

Field

public static final int FACE_ACQUIRED_TOO_LEFT

helpCode returned by the onAuthHelp method of BioAuthnCallback after the auth API is called.

Value: 9

The user device position is to the left, and only the left part of the face is obtained. For other constant values, please refer to Constant-values.

[h2]FACE_ACQUIRED_TOO_MUCH_MOTION

Field

public static final int FACE_ACQUIRED_TOO_MUCH_MOTION

helpCode returned by the onAuthHelp method of BioAuthnCallback after the auth API is called.

Value: 10

The face moves too frequently during image collection. For other constant values, please refer to Constant-values.

[h2]FACE_ACQUIRED_POOR_GAZE

Field

public static final int FACE_ACQUIRED_POOR_GAZE

helpCode returned by the onAuthHelp method of BioAuthnCallback after the auth API is called.

Value: 11

The user's focus is too far away from the sensor, and an important part of the user's face is not detected. For other constant values, please refer to Constant-values.

[h2]FACE_ACQUIRED_NOT_DETECTED

Field

public static final int FACE_ACQUIRED_NOT_DETECTED

helpCode returned by the onAuthHelp method of BioAuthnCallback after the auth API is called.

Value: 12

The sensor detects no face. For other constant values, please refer to Constant-values.

[h2]FACE_ACQUIRED_VENDOR

Field

public static final int FACE_ACQUIRED_VENDOR

helpCode returned by the onAuthHelp method of BioAuthnCallback after the auth API is called.

Value: 13

Vendor-defined errors. For other constant values, please refer to Constant-values.

[h2]FACE_MODALITY_UNSUPPORTED

Field

public static final int FACE_MODALITY_UNSUPPORTED

Return value of the getFaceModality method.

Value: 1

Face modality (2D or 3D) check is not supported. For other constant values, please refer to Constant-values.

[h2]FACE_MODALITY_2D

Field

public static final int FACE_MODALITY_2D

Return value of the getFaceModality method.

Value: 2

2D face modality. For other constant values, please refer to Constant-values.

[h2]FACE_MODALITY_3D

Field

public static final int FACE_MODALITY_3D

Return value of the getFaceModality method.

Value: 3

3D face modality. For other constant values, please refer to Constant-values.

Other Result Codes

Result Code

Description

1012

errorCode returned by the onAuthError method of BioAuthnCallback after the auth API is called.

Value: 1012

The camera permission is not granted. (Result code passed to the callback: BioAuthnCallback#onAuthError)

1038

helpCode returned by the onAuthHelp method of BioAuthnCallback after the auth API is called.

Value: 1038

A face was detected. (Result code passed to the callback: BioAuthnCallback#onAuthHelp)

1012

helpCode returned by the onAuthHelp method of BioAuthnCallback after the auth API is called.

Value: 1012

The face does not match the enrolled one. (Result code passed to the callback: BioAuthnCallback#onAuthHelp)

Public Constructors

[h2]FaceManager

Constructor

public FaceManager(android.content.Context context)

Constructs a FaceManager object for facial authentication, which is used to call the facial authentication API of FIDO BioAuthn.

Parameters

Name

Description

context

Context of an Android app.

Public Methods

[h2]canAuth

Method

public int canAuth()

Checks whether facial authentication can be used, including checking whether facial authentication is supported in this OS version, whether the device hardware supports facial authentication, and whether a facial authentication template has been enrolled.

Returns

Type

Description

int

FACE_SUCCESS: Facial authentication is available. (A valid facial template has been enrolled and the authentication hardware is available.)

FACE_ERROR_NOT_ENROLLED: No facial authentication template is enrolled before authentication.

FACE_ERROR_HW_UNAVAILABLE: The device hardware does not support facial authentication.

FACE_ERROR_UNSUPPORTED_OS_VER: Facial authentication is not supported in this OS version.

[h2]auth

Method

public void auth(final CryptoObject crypto, final android.os.CancellationSignal cancel, final int flags, final BioAuthnCallback callback, final android.os.Handler handler)

Initiates a facial authentication request on the device.

Parameters

Name

Description

crypto

Encryption object associated with the authentication. The value can be null.

cancel

Cancellation signal object for canceling the authentication. The value can be null.

flags

Authentication flag. The value should be 0.

callback

Authentication result callback. The value cannot be null.

handler

Authentication-related message processor object. The value can be null.

[h2]isHardwareDetected

Method

public boolean isHardwareDetected()

Checks whether facial authentication hardware exists and works properly.

Returns

Type

Description

boolean

true if facial authentication hardware exists and works properly; false otherwise.

[h2]hasEnrolledTemplates

Method

public boolean hasEnrolledTemplates()

Checks whether at least one facial authentication template has been enrolled in the system.

Returns

Type

Description

boolean

true if at least one facial authentication template has been enrolled in the system; false otherwise.

[h2]getFaceModality

Method

public int getFaceModality()

Checks whether the current face modality is 3D or 2D.

Returns

Type

Description

int