From f0ae0cd318a5b7b4283c8795d2152b08616b3929 Mon Sep 17 00:00:00 2001 From: "https://gitee.com/WALL_EYE" Date: Wed, 18 May 2022 11:29:40 +0800 Subject: [PATCH] feat:fingerprintauth HDI Signed-off-by: https://gitee.com/WALL_EYE Change-Id: I01591edc5dab4281901003350f3632ea11d68fd7 --- README_ZH.md | 1 + face_auth/bundle.json | 1 - fingerprint_auth/bundle.json | 41 +++++ fingerprint_auth/v1_0/BUILD.gn | 26 ++++ .../v1_0/FingerprintAuthTypes.idl | 133 ++++++++++++++++ fingerprint_auth/v1_0/IExecutor.idl | 145 ++++++++++++++++++ fingerprint_auth/v1_0/IExecutorCallback.idl | 69 +++++++++ .../v1_0/IFingerprintAuthInterface.idl | 59 +++++++ 8 files changed, 474 insertions(+), 1 deletion(-) create mode 100644 fingerprint_auth/bundle.json create mode 100644 fingerprint_auth/v1_0/BUILD.gn create mode 100644 fingerprint_auth/v1_0/FingerprintAuthTypes.idl create mode 100644 fingerprint_auth/v1_0/IExecutor.idl create mode 100644 fingerprint_auth/v1_0/IExecutorCallback.idl create mode 100644 fingerprint_auth/v1_0/IFingerprintAuthInterface.idl diff --git a/README_ZH.md b/README_ZH.md index 6274f7df..b91e98ef 100644 --- a/README_ZH.md +++ b/README_ZH.md @@ -33,6 +33,7 @@ ├── misc #misc HDI接口定义 ├── pinauth #pinauth HDI接口定义 ├── usb #usb HDI接口定义 +├── fingerprint_auth #fingerprintauth HDI接口定义 └── wlan #wlan HDI接口定义 ``` diff --git a/face_auth/bundle.json b/face_auth/bundle.json index b19ed1c6..e12bf4d0 100644 --- a/face_auth/bundle.json +++ b/face_auth/bundle.json @@ -18,7 +18,6 @@ "utils_base" ], "third_part": [ - "bounds_checking_function" ] }, "build": { diff --git a/fingerprint_auth/bundle.json b/fingerprint_auth/bundle.json new file mode 100644 index 00000000..9c2b54bf --- /dev/null +++ b/fingerprint_auth/bundle.json @@ -0,0 +1,41 @@ +{ + "name": "fingerprint_auth_device_driver_interface", + "description": "fingerprint_auth device driver interface", + "version": "3.2", + "license": "Apache License 2.0", + "component": { + "name": "fingerprint_auth_device_driver_interface", + "subsystem": "hdf", + "syscap": [""], + "adapter_system_type": ["standard"], + "rom": "675KB", + "ram": "1024KB", + "deps": { + "components": [ + "ipc", + "device_driver_framework", + "hiviewdfx_hilog_native", + "utils_base" + ], + "third_part": [ + ] + }, + "build": { + "sub_component": [ + "//drivers/interface/fingerprint_auth/v1_0:libfingerprint_auth_proxy_1.0" + ], + "test": [ + ], + "inner_kits": [ + { + "name": "//drivers/interface/fingerprint_auth/v1_0:libfingerprint_auth_proxy_1.0", + "header": { + "header_files": [ + ], + "header_base": "//drivers/interface/fingerprint_auth" + } + } + ] + } + } + } diff --git a/fingerprint_auth/v1_0/BUILD.gn b/fingerprint_auth/v1_0/BUILD.gn new file mode 100644 index 00000000..55abb99d --- /dev/null +++ b/fingerprint_auth/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("fingerprint_auth") { + module_name = "fingerprint_auth" + sources = [ + "FingerprintAuthTypes.idl", + "IExecutor.idl", + "IExecutorCallback.idl", + "IFingerprintAuthInterface.idl", + ] + language = "cpp" + subsystem_name = "hdf" + part_name = "fingerprint_auth_device_driver" +} diff --git a/fingerprint_auth/v1_0/FingerprintAuthTypes.idl b/fingerprint_auth/v1_0/FingerprintAuthTypes.idl new file mode 100644 index 00000000..f04cade5 --- /dev/null +++ b/fingerprint_auth/v1_0/FingerprintAuthTypes.idl @@ -0,0 +1,133 @@ +/* + * 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 HdfFingerprintAuth + * @{ + * + * @brief Provides APIs for the fingerprint auth driver. + * + * The fingerprint auth driver provides a unified interface for the fingerprint auth service to access the fingerprint auth driver. + * After obtaining the fingerprint auth driver proxy, the service can call related APIs to obtain executors. + * After obtaining the fingerprint 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 FingerprintAuthTypes.idl + * + * @brief Defines fingerprint auth driver enumeration and data structure, including AuthType, ExecutorRole, ExecutorSecureLevel, + * CommandId, FingerprintTipsCode, ExecutorInfo and TemplateInfo. + * + * @since 3.2 + */ + +package ohos.hdi.fingerprint_auth.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 FingerprintTipsCode : int { + FINGERPRINT_AUTH_TIP_GOOD = 0, /**< Indicates that the image acquired is good. */ + FINGERPRINT_AUTH_TIP_DIRTY = 1, /**< Indicates that the fingerprint image is too noisy due to suspected or detected dirt on sensor. */ + FINGERPRINT_AUTH_TIP_INSUFFICIENT = 2, /**< Indicates that only a partial fingerprint image is detected. */ + FINGERPRINT_AUTH_TIP_PARTIAL = 3, /**< Indicates that only a partial fingerprint image is detected. */ + FINGERPRINT_AUTH_TIP_TOO_FAST = 4, /**< Indicates that the fingerprint image is incomplete due to quick motion. */ + FINGERPRINT_AUTH_TIP_TOO_SLOW = 5, /**< Indicates that the fingerprint image is unreadable due to lack of motion. */ + VENDOR_FINGERPRINT_AUTH_TIP_BEGIN = 10000 /**< Vendor may add custom fingerprint 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/fingerprint_auth/v1_0/IExecutor.idl b/fingerprint_auth/v1_0/IExecutor.idl new file mode 100644 index 00000000..e11e38c0 --- /dev/null +++ b/fingerprint_auth/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 HdfFingerprintAuth + * @{ + * + * @brief Provides APIs for the fingerprint auth driver. + * + * The fingerprint auth driver provides a unified interface for the fingerprint auth service to access the fingerprint auth driver. + * After obtaining the fingerprint auth driver proxy, the service can call related APIs to obtain executors. + * After obtaining the fingerprint 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.fingerprint_auth.v1_0; + +import ohos.hdi.fingerprint_auth.v1_0.FingerprintAuthTypes; +import ohos.hdi.fingerprint_auth.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/fingerprint_auth/v1_0/IExecutorCallback.idl b/fingerprint_auth/v1_0/IExecutorCallback.idl new file mode 100644 index 00000000..23333872 --- /dev/null +++ b/fingerprint_auth/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 HdfFingerprintAuth + * @{ + * + * @brief Provides APIs for the fingerprint auth driver. + * + * The fingerprint auth driver provides a unified interface for the fingerprint auth service to access the fingerprint auth driver. + * After obtaining the fingerprint auth driver proxy, the service can call related APIs to obtain executors. + * After obtaining the fingerprint 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.fingerprint_auth.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 FingerprintTipsCode}. + * @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/fingerprint_auth/v1_0/IFingerprintAuthInterface.idl b/fingerprint_auth/v1_0/IFingerprintAuthInterface.idl new file mode 100644 index 00000000..0b1d88fe --- /dev/null +++ b/fingerprint_auth/v1_0/IFingerprintAuthInterface.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 HdfFingerprintAuth + * @{ + * + * @brief Provides APIs for the fingerprint auth driver. + * + * The fingerprint auth driver provides a unified interface for the fingerprint auth service to access the fingerprint auth driver. + * After obtaining the fingerprint auth driver proxy, the service can call related APIs to obtain executors. + * After obtaining the fingerprint 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 IFingerprintAuthInterface.idl + * + * @brief Defines the get executor list API of the fingerprint auth driver. This API can be used to get executor list + * of driver. + * + * @since 3.2 + */ + +package ohos.hdi.fingerprint_auth.v1_0; + +import ohos.hdi.fingerprint_auth.v1_0.IExecutor; + +/** + * @brief Defines the get executor list API of the fingerprint auth driver. + * + * @since 3.2 + * @version 1.0 + */ +interface IFingerprintAuthInterface { + /** + * @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 -- Gitee