diff --git a/README_ZH.md b/README_ZH.md index 11b7af309b6463d201f3362fc69227fa3aceeb84..c211b100299d1ecf7646fe2094976c442ac6f4fe 100644 --- a/README_ZH.md +++ b/README_ZH.md @@ -27,6 +27,7 @@ ├── camera #camera HDI接口定义 ├── codec #codec HDI接口定义 ├── display #display HDI接口定义 +├── faceauth #faceauth HDI接口定义 ├── format #format HDI接口定义 ├── input #input HDI接口定义 ├── misc #misc HDI接口定义 diff --git a/faceauth/v1_0/BUILD.gn b/faceauth/v1_0/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..28f17e9414d354b177eb0a15c5dfb3d707723509 --- /dev/null +++ b/faceauth/v1_0/BUILD.gn @@ -0,0 +1,26 @@ +# 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. + +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..be9db0e7446759715efdcd0ea12b0d757ad031ce --- /dev/null +++ b/faceauth/v1_0/FaceAuthTypes.idl @@ -0,0 +1,138 @@ +/* + * 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, 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 : 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 : int { + COLLECTOR = 1, /**< Indicates executor role is collector. */ + VERIFIER = 2, /**< Indicates executor role is verifier. */ + ALL_IN_ONE = 3, /**< Indicates executor role is combination of collector and verifier, cannot be used as collector or verifier. */ +}; + +/** + * Enumerates executor secure level. + * + * @since 3.2 + * @version 1.0 + */ +enum ExecutorSecureLevel : 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 : int { + LOCK_TEMPLATE = 1, /**< Indicates lock template command id. */ + UNLOCK_TEMPLATE = 2, /**< Indicates unlock template command id. */ + VENDOR_COMMAND_BEGIN = 10000 /**< Vendor may add custom command id after this. */ +}; + +/** + * Enumerates prompt codes. + * + * @since 3.2 + * @version 1.0 + */ +enum FaceTipsCode : 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 much during facial information collection. */ + FACE_AUTH_TIP_POOR_GAZE = 10, /**< Indicates the user is not gazing at the device. */ + FACE_AUTH_TIP_NOT_DETECTED = 11, /**< Indicates that no face is detected. */ + 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 short 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..b3e8d90430693cf3679ef038f73de799828b8f30 --- /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 executorInfo 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 templateInfo 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..8829ccf3b67b9f10d030afb3a389083f1b5e5607 --- /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 result Indicates result code. + * @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 result, [in] unsigned char[] extraInfo); + /** + * @brief defines the function for reporting info in process. + * + * @param acquire 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 acquire, [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