diff --git a/faceauth/v1_0/BUILD.gn b/faceauth/v1_0/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..dd63419bfe5532e02c506f4d47ca3f8e7a225671 --- /dev/null +++ b/faceauth/v1_0/BUILD.gn @@ -0,0 +1,13 @@ +import("//drivers/adapter/uhdf2/hdi.gni") +hdi("faceauth") { + module_name = "faceauth" + sources = [ + "IExecutor.idl", + "IExecutorCallback.idl", + "IFaceAuthInterface.idl", + "FaceAuthTypes.idl", + ] + language = "cpp" + subsystem_name = "hdf" + part_name = "faceauth_device_driver" +} diff --git a/faceauth/v1_0/FaceAuthTypes.idl b/faceauth/v1_0/FaceAuthTypes.idl new file mode 100755 index 0000000000000000000000000000000000000000..fe89d691efb90e0664a5dbb5d7d17108ae9f7931 --- /dev/null +++ b/faceauth/v1_0/FaceAuthTypes.idl @@ -0,0 +1,163 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @addtogroup HdfFaceAuth + * @{ + * + * @brief Provides APIs for the face auth driver. + * + * The face auth driver provides a unified interface for the face auth service to access the face auth driver. + * After obtaining the face auth driver proxy, the service can call related APIs to obtain executors. + * After obtaining the face auth executors, the service can call related APIs to get executor info, get + * template info, enroll template, authenticate template, delete template, etc. + * + * @since 3.2 + */ + +/** + * @file FaceAuthTypes.idl + * + * @brief Defines face auth driver enumeration and data structure, including AuthType, ExecutorRole, ExecutorSecureLevel, + * CommandId, ResultCode, FaceTipsCode, ExecutorInfo and TemplateInfo. + * + * @since 3.2 + */ + +package ohos.hdi.faceauth.v1_0; + +/** + * Enumerates credential type for authentication. + * + * @since 3.2 + * @version 1.0 + */ +enum AuthType : unsigned int { + PIN = 1, /**< Indicates authentication type is PIN. */ + FACE = 2, /**< Indicates authentication type is face. */ + FINGERPRINT = 3, /**< Indicates authentication type is fingerprint. */ +}; + +/** + * Enumerates executor role. + * + * @since 3.2 + * @version 1.0 + */ +enum ExecutorRole : unsigned int { + COLLECTOR = 1, /**< Indicates executor role is collector. */ + VERIFIER = 2, /**< Indicates executor role is verifier. */ + ALL_IN_ONE = 3, /**< Indicates executor role is collector and verifier. */ +}; + +/** + * Enumerates executor secure level. + * + * @since 3.2 + * @version 1.0 + */ +enum ExecutorSecureLevel : unsigned int { + ESL0 = 0, /**< Indicates executor secure level is ESL0. */ + ESL1 = 1, /**< Indicates executor secure level is ESL1. */ + ESL2 = 2, /**< Indicates executor secure level is ESL2. */ + ESL3 = 3, /**< Indicates executor secure level is ESL3. */ +}; + +/** + * Enumerates command id. + * + * @since 3.2 + * @version 1.0 + */ +enum CommandId : unsigned int { + LOCK_TEMPLATE = 1, /**< Indicates lock template command id. */ + UNLOCK_TEMPLATE = 2, /**< Indicates unlock template command id. */ + FRAMEWORK_COMMAND_ID_MAX, /**< Indicates the max command id for framework. */ + VENDOR_COMMAND_BEGIN = 10000 /**< Vendor may add custom command id after this. */ +}; + +/** + * Enumerates operation result. + * + * @since 3.2 + * @version 1.0 + */ +enum ResultCode : unsigned int { + SUCCESS = 0, /**< Indicates the operation is success or ability is supported. */ + FAIL = 1, /**< Indicates the operation is fail. */ + GENERAL_ERROR = 2, /**< Indicates other errors happened during the operation. */ + CANCELED = 3, /**< Indicates that operation has been canceled. */ + TIMEOUT = 4, /**< Indicates that operation is timed out. */ + TYPE_NOT_SUPPORT = 5, /**< Indicates that auth type is not supported. */ + TRUST_LEVEL_NOT_SUPPORT = 6, /**< Indicates that trust level is not supported. */ + BUSY = 7, /**< Indicates that the executor is busy. */ + INVALID_PARAMETERS = 8, /**< Indicates that the parameters are invalid. */ + LOCKED = 9, /**< Indicates that the executor is locked. */ + NOT_ENROLLED = 10, /**< Indicates that the user has not enrolled credential for the executor. */ + OPERATION_NOT_SUPPORT = 21, /**< Indicates that the executor does not support this operation. */ + FRAMEWORK_RESULT_CODE_MAX, /**< Indicates Indicates the max result code for framework. */ + VENDOR_RESULT_CODE_BEGIN = 10000, /**< Vendor may add custom result code after this. */ +}; + +/** + * Enumerates prompt codes. + * + * @since 3.2 + * @version 1.0 + */ +enum FaceTipsCode : unsigned int { + FACE_AUTH_TIP_TOO_BRIGHT = 1, /**< Indicates that the obtained facial image is too bright due to high illumination. */ + FACE_AUTH_TIP_TOO_DARK = 2, /**< Indicates that the obtained facial image is too dark due to low illumination. */ + FACE_AUTH_TIP_TOO_CLOSE = 3, /**< Indicates that the face is too close to the device. */ + FACE_AUTH_TIP_TOO_FAR = 4, /**< Indicates that the face is too far away from the device. */ + FACE_AUTH_TIP_TOO_HIGH = 5, /**< Indicates that the device is too high, and that only the upper part of the face is captured. */ + FACE_AUTH_TIP_TOO_LOW = 6, /**< Indicates that the device is too low, and that only the lower part of the face is captured. */ + FACE_AUTH_TIP_TOO_RIGHT = 7, /**< Indicates that the device is deviated to the right, and that only the right part of the face is captured. */ + FACE_AUTH_TIP_TOO_LEFT = 8, /**< Indicates that the device is deviated to the left, and that only the left part of the face is captured. */ + FACE_AUTH_TIP_TOO_MUCH_MOTION = 9, /**< Indicates that the face moves too fast during facial information collection. */ + FACE_AUTH_TIP_POOR_GAZE = 10, /**< Indicates that the face is not facing the device. */ + FACE_AUTH_TIP_NOT_DETECTED = 11, /**< Indicates that no face is detected. */ + FRAMEWORK_FACE_AUTH_TIP_MAX, /**< Indicates the max face auth tip for framework. */ + VENDOR_FACE_AUTH_TIP_BEGIN = 10000 /**< Vendor may add custom face auth tip after this. */ +}; + +/** + * Indicates the executor info. + * + * @since 3.2 + * @version 1.0 + */ +struct ExecutorInfo { + unsigned int sensorId; /**< Indicates sensor id. Sensor id must be unique in driver. */ + unsigned int executorType; /**< Indicates executor type. */ + enum ExecutorRole executorRole; /**< Indicates executor role, see @{ExecutorRole}. */ + enum AuthType authType; /**< Indicates auth type, see @{AuthType}. */ + enum ExecutorSecureLevel esl; /**< Indicates executor secure level, see @{ExecutorSecureLevel}. */ + unsigned char[] publicKey; /**< Indicates publicKey. */ + unsigned char[] extraInfo; /**< Indicates extra info. */ +}; + +/** + * Indicates the template info. + * + * @since 3.2 + * @version 1.0 + */ +struct TemplateInfo { + unsigned int executorType; /**< Indicates executor type. */ + int freezingTime; /**< Indicates freezing time in seconds. */ + int remainTimes; /**< Indicates remain times before a lockout. */ + unsigned char[] extraInfo; /**< Indicates extra info. */ +}; \ No newline at end of file diff --git a/faceauth/v1_0/IExecutor.idl b/faceauth/v1_0/IExecutor.idl new file mode 100644 index 0000000000000000000000000000000000000000..000cf1133ac4d24e6b80d0ad97bf8dd9587b41fe --- /dev/null +++ b/faceauth/v1_0/IExecutor.idl @@ -0,0 +1,145 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @addtogroup HdfFaceAuth + * @{ + * + * @brief Provides APIs for the face auth driver. + * + * The face auth driver provides a unified interface for the face auth service to access the face auth driver. + * After obtaining the face auth driver proxy, the service can call related APIs to obtain executors. + * After obtaining the face auth executors, the service can call related APIs to get executor info, get + * template info, enroll template, authenticate template, delete template, etc. + * + * @since 3.2 + */ + +/** + * @file IExecutor.idl + * + * @brief Defines the APIs of executor. These APIs can be used to get executor info, get + * template info, enroll template, authenticate template, delete template, etc. + * + * @since 3.2 + */ + +package ohos.hdi.faceauth.v1_0; + +import ohos.hdi.faceauth.v1_0.FaceAuthTypes; +import ohos.hdi.faceauth.v1_0.IExecutorCallback; + +/** + * @brief Defines the APIs of executor. These APIs can be used to get executor info, get + * template info, enroll template, authenticate template, delete template, etc. + * + * @since 3.2 + * @version 1.0 + */ +interface IExecutor { + /** + * @brief Get executor info. + * + * @param info Indicates executor info, see {@link ExecutorInfo}. + * + * @return Returns 0 if the operation is successful. + * @return Returns a non-zero value if the operation fails. + */ + GetExecutorInfo([out] struct ExecutorInfo executorInfo); + /** + * @brief Get template info. + * + * @param templateId Indicates template id. + * @param info Indicates template info, see {@link TemplateInfo}. + * + * @return Returns 0 if the operation is successful. + * @return Returns a non-zero value if the operation fails. + */ + GetTemplateInfo([in] unsigned long templateId, [out] struct TemplateInfo templateInfo); + /** + * @brief Send parameters to driver when executor register finish. + * + * @param templateIdList Indicates templates previously registered to userauth framework. + * @param frameworkPublicKey Indicates framework public key. + * @param extraInfo Indicates extra info send to executor. + * + * @return Returns 0 if the operation is successful. + * @return Returns a non-zero value if the operation fails. + */ + OnRegisterFinish([in] unsigned long[] templateIdList, [in] unsigned char[] frameworkPublicKey, [in] unsigned char[] extraInfo); + /** + * @brief Enroll template. + * + * @param scheduleId Indicates schedule id of enroll. + * @param extraInfo Indicates extra info of enroll. + * @param callbackObj Indicates enroll callback object, see {@link IExecutorCallback}. + * + * @return Returns 0 if the operation is successful. + * @return Returns a non-zero value if the operation fails. + */ + Enroll([in] unsigned long scheduleId, [in] unsigned char[] extraInfo, [in] IExecutorCallback callbackObj); + /** + * @brief Authenticate template. + * + * @param scheduleId Indicates schedule id of authenticate. + * @param templateIdList Indicates the templates to authenticate. + * @param extraInfo Indicates extra info of authenticate. + * @param callbackObj Indicates authenticate callback object, see {@link IExecutorCallback}. + * + * @return Returns 0 if the operation is successful. + * @return Returns a non-zero value if the operation fails. + */ + Authenticate([in] unsigned long scheduleId, [in] unsigned long[] templateIdList, [in] unsigned char[] extraInfo, [in] IExecutorCallback callbackObj); + /** + * @brief Identify template. + * + * @param scheduleId Indicates schedule id of identify. + * @param extraInfo Indicates extra info of identify. + * @param callbackObj Indicates identify callback object, see {@link IExecutorCallback}. + * + * @return Returns 0 if the operation is successful. + * @return Returns a non-zero value if the operation fails. + */ + Identify([in] unsigned long scheduleId, [in] unsigned char[] extraInfo, [in] IExecutorCallback callbackObj); + /** + * @brief Delete templates. + * + * @param templateIdList Indicates the templates to delete. + * + * @return Returns 0 if the operation is successful. + * @return Returns a non-zero value if the operation fails. + */ + Delete([in] unsigned long[] templateIdList); + /** + * @brief Cancel enroll, authenticate or identify operation. + * + * @param scheduleId Indicates schedule id of operation to cancel. + * + * @return Returns 0 if the operation is successful. + * @return Returns a non-zero value if the operation fails. + */ + Cancel([in] unsigned long scheduleId); + /** + * @brief Send command to driver. + * + * @param commandId Indicates command id. For details, see {@link CommandId}. + * @param extraInfo Indicates extra info of command. + * @param callbackObj Indicates command callback object, see {@link IExecutorCallback}. + * + * @return Returns 0 if the operation is successful. + * @return Returns a non-zero value if the operation fails. + */ + SendCommand([in] int commandId, [in] unsigned char[] extraInfo, [in] IExecutorCallback callbackObj); +} \ No newline at end of file diff --git a/faceauth/v1_0/IExecutorCallback.idl b/faceauth/v1_0/IExecutorCallback.idl new file mode 100755 index 0000000000000000000000000000000000000000..f89f27cc7ba8778b3b4526e95ac1c2cc9f22a939 --- /dev/null +++ b/faceauth/v1_0/IExecutorCallback.idl @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @addtogroup HdfFaceAuth + * @{ + * + * @brief Provides APIs for the face auth driver. + * + * The face auth driver provides a unified interface for the face auth service to access the face auth driver. + * After obtaining the face auth driver proxy, the service can call related APIs to obtain executors. + * After obtaining the face auth executors, the service can call related APIs to get executor info, get + * template info, enroll template, authenticate template, delete template, etc. + * + * @since 3.2 + */ + +/** + * @file IExecutorCallback.idl + * + * @brief Defines the callback for async API. These callback can be used to report operation result or info + * of async API. + * + * @since 3.2 + */ + +package ohos.hdi.faceauth.v1_0; + +/** + * @brief Defines the callback for async API. This callback needs to be registered when + * executor user calls an async function. For details, see {@link IExecutor}. + * + * @since 3.2 + * @version 1.0 + */ +[callback] interface IExecutorCallback { + /** + * @brief Defines the function for reporting operation result. + * + * @param code Indicates acquire info code, see {@link ResultCode}. + * @param extraInfo Indicates extra info to report. + * + * @return Returns 0 if the operation is successful. + * @return Returns a non-zero value if the operation fails. + */ + OnResult([in] int code, [in] unsigned char[] extraInfo); + /** + * @brief defines the function for reporting info in process. + * + * @param code Indicates acquire info code, see {@link FaceTipsCode}. + * @param extraInfo Indicates extra info to report. + * + * @return Returns 0 if the operation is successful. + * @return Returns a non-zero value if the operation fails. + */ + OnAcquireInfo([in] int code, [in] unsigned char[] extraInfo); +} \ No newline at end of file diff --git a/faceauth/v1_0/IFaceAuthInterface.idl b/faceauth/v1_0/IFaceAuthInterface.idl new file mode 100644 index 0000000000000000000000000000000000000000..bca39be858feda9a8930f36ea78cc9cfc30fb51e --- /dev/null +++ b/faceauth/v1_0/IFaceAuthInterface.idl @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @addtogroup HdfFaceAuth + * @{ + * + * @brief Provides APIs for the face auth driver. + * + * The face auth driver provides a unified interface for the face auth service to access the face auth driver. + * After obtaining the face auth driver proxy, the service can call related APIs to obtain executors. + * After obtaining the face auth executors, the service can call related APIs to get executor info, get + * template info, enroll template, authenticate template, delete template, etc. + * + * @since 3.2 + */ + +/** + * @file IFaceAuthInterface.idl + * + * @brief Defines the get executor list API of the face auth driver. This API can be used to get executor list + * of driver. + * + * @since 3.2 + */ + +package ohos.hdi.faceauth.v1_0; + +import ohos.hdi.faceauth.v1_0.IExecutor; + +/** + * @brief Defines the get executor list API of the face auth driver. + * + * @since 3.2 + * @version 1.0 + */ +interface IFaceAuthInterface { + /** + * @brief Obtains executor list of driver. + * + * @param executorList Indicates executor list of driver. For details, see {@link IExecutor}. + * + * @return Returns 0 if the operation is successful. + * @return Returns a non-zero value if the operation fails. + */ + GetExecutorList([out] IExecutor[] executorList); +} \ No newline at end of file