Documentation

Migration Guides

From 4.0.0, we've introduced significant API improvements and feature enhancements. To make upgrading easier, here’s what you need to know:

Due to numerous API changes this time, if you haven't made significant changes to the LivenessActivity.java code, it's recommended that you re-download the UI source code module and its dependencies.

GuardianLivenessDetectionSDK

  1. Due to the presence of different types of initialization methods in the SDK, the parameters of the initmethod have grown increasingly numerous, making it difficult to understand their meanings. Therefore, starting from version 4.1.0, we have redesigned the initmethod. Please select the corresponding initmethod based on your current initialization approach.

    • ​License Authentication Method​:

      GuardianLivenessDetectionSDK.init(new SDKLicenseAuthModeConfig.Builder()
                                        .setMarket(Market market)
                                        .setIsGlobalService(boolean isGlobalService)
                                        .build(), this);
    • ​Static AccessKey & SecretKey Authentication Method​:

      GuardianLivenessDetectionSDK.init(new SDKStaticKeyAuthModeConfig.Builder()
                                        .setAccessKey("your access key")
                                        .setSecretKey("your secret key")
                                        .setMarket(Market market)
                                        .setIsGlobalService(boolean isGlobalService)
                                        .build(),
                                        this);
  2. As the SDK evolves, the ​GuardianLivenessDetectionSDK​ has seen an increasing number of static methods with fragmented configurations. Therefore, starting from ​version 4.0.0, we have consolidated these configurations into ​LivenessConfig. You can refer to the table below for migration guidance.

    Method/PropertyAlternativeNotes
    setRecordVideoSwitch-No need to call.
    letSDKHandleCameraPermission-No need to call.
    setMaxRecordVideoSecondsLivenessConfig#setMaxRecordVideoSeconds()Record if greater than 0, otherwise recording.
    setRecordVideoQuality-No need to call.
    isDetectOcclusionLivenessConfig#setDetectOcclusion()-
    setResultPictureSizeLivenessConfig#setResultPictureSize()-
    bindUserLivenessConfig#setUserId()-
    set3DLivenessTimeoutMillsLivenessConfig#setDistantNearTimeout()-
    setActionSequence-No need to call.
    setActionTimeoutMillsLivenessConfig#setActionTimeout()-
    setAuditImageConfigLivenessConfig#setAuditImageConfig()-
    setCameraTypeLivenessConfig#setCameraType()-
    setDetectionLevel-No need to call.
    setDeviceType-Not support.
    setPrepareTimeoutMillsLivenessConfig#setPrepareMillSeconds()-
    setSignatureIdLivenessConfig#setSignatureId()-
    setQueryIdLivenessConfig#setQueryId()-
    setTicketLivenessConfig#setTicket()-
    clearTicketAndQueryId-LivenessConfig#setQueryId(""), LivenessConfig#setTicket("")
    isSDKHandleCameraPermission-No need to call.

LivenessView

To accommodate various liveness types, we have adjusted some APIs of ​LivenessView​ and renamed ​DetectionType​ to ​LivenessStage​ to make its meaning more precise

Method/PropertyAlternativeNotes
setLivenssCallbackLivenessView$startDetection(configs, livenessCallback);The set method has been removed, and configs and callback need to be set each time the liveness detection is started.
onResume-No need to call.
onPause-No need to call.
onDestroy-No need to call.
isNotOnLoadingFaceData-No need to call.
getLivenessData-No need to call.
playSound(resID, true, 1500);LivenessConfig#setSoundRawId(), LivenessConfig#playSound()The playSound method is divided into two methods: setSoundRawId for setting the resource ID and playSound for playing the sound.
getCurrentDetectionTypeRemovedLiveness stage cannot be obtained from the view. Please retrieve the LivenessStage through the callback onLivenessStageChanged provided by the view.

Detector

The Detector class is no longer visible, and the related enumerations are replaced as follows

Method/PropertyAlternativeNotes
Detector.DetectionTypeaai.liveness.enums.LivenessStage-
Detector.WarnCodeaai.liveness.enums.WarnCode-
Detector.DetectionFailedTypeaai.liveness.enums.DetectionFailedType-

DetectionFailedType

AlternativeMethod/PropertyNotes
-NO_BEST_IMAGEA new error code has been added. It belongs to internal SDK errors and does not require user notification. Please contact us if this code appears.
-UNDEFINEDA new error code has been added. It belongs to internal SDK errors and does not require user notification. Please contact us if this code appears.

LivenessCallback

Method/PropertyAlternativeNotes
onDetectionActionChanged()onLivenessStageChanged(LivenessStage livenessStage)
onDetectionFrameStateChanged(Detector.WarnCode warnCode)onDetectionFrameStateChanged(LivenessStage livenessStage, WarnCode warnCode)
onDetectionFailed(Detector.DetectionFailedType failedType, Detector.DetectionType detectionType)onDetectionFailed(DetectionFailedType failedType, LivenessStage livenessStage)
onDetectionSuccess()RemovedNew methods onUploadFaceDataStart and onUploadFaceDataComplete have replaced the onDetectionSuccess method.
-onUploadFaceDataStart()Start uploading face data; please execute your loading here.
-onUploadFaceDataComplete()Face data upload completed; hide your loading. You can obtain the results through LivenessResult.

aai.liveness.impl.LivenessGetFaceDataCallback

Removed