1 /* 2 * Copyright (c) 2022-2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef OHOS_USERAUTH_COMMON_H 17 #define OHOS_USERAUTH_COMMON_H 18 19 #include <map> 20 #include <vector> 21 22 #include "napi/native_api.h" 23 #include "napi/native_common.h" 24 25 #include "iam_common_defines.h" 26 27 namespace OHOS { 28 namespace UserIam { 29 namespace UserAuth { 30 constexpr size_t ARGS_ZERO = 0; 31 constexpr size_t ARGS_ONE = 1; 32 constexpr size_t ARGS_TWO = 2; 33 constexpr size_t ARGS_THREE = 3; 34 constexpr size_t ARGS_FOUR = 4; 35 36 constexpr size_t PARAM0 = 0; 37 constexpr size_t PARAM1 = 1; 38 constexpr size_t PARAM2 = 2; 39 constexpr size_t PARAM3 = 3; 40 41 constexpr int32_t API_VERSION_6 = 6; 42 constexpr int32_t API_VERSION_8 = 8; 43 constexpr int32_t API_VERSION_9 = 9; 44 constexpr int32_t API_VERSION_10 = 10; 45 46 constexpr const char *NOTICE_EVENT_AUTH_READY = "EVENT_AUTH_TYPE_READY"; 47 constexpr const char *NOTICE_EVENT_CANCEL_AUTH = "EVENT_AUTH_USER_CANCEL"; 48 constexpr const char *NOTICE_EVENT_USER_NAVIGATION = "EVENT_AUTH_USER_NAVIGATION"; 49 constexpr const char *NOTICE_EVENT_WIDGET_PARA_INVALID = "EVENT_AUTH_WIDGET_PARA_INVALID"; 50 51 // For API6 52 enum class AuthenticationResult : int32_t { 53 NO_SUPPORT = -1, 54 SUCCESS = 0, 55 COMPARE_FAILURE = 1, 56 CANCELED = 2, 57 TIMEOUT = 3, 58 CAMERA_FAIL = 4, 59 BUSY = 5, 60 INVALID_PARAMETERS = 6, 61 LOCKED = 7, 62 NOT_ENROLLED = 8, 63 GENERAL_ERROR = 100, 64 }; 65 66 enum class UserAuthResultCode : int32_t { 67 OHOS_CHECK_PERMISSION_FAILED = 201, 68 OHOS_CHECK_SYSTEM_APP_FAILED = 202, 69 OHOS_INVALID_PARAM = 401, 70 RESULT_CODE_V9_MIN = 12500000, 71 RESULT_CODE_V10_MIN = 12500000, 72 SUCCESS = 12500000, 73 FAIL = 12500001, 74 GENERAL_ERROR = 12500002, 75 CANCELED = 12500003, 76 TIMEOUT = 12500004, 77 TYPE_NOT_SUPPORT = 12500005, 78 TRUST_LEVEL_NOT_SUPPORT = 12500006, 79 BUSY = 12500007, 80 LOCKED = 12500009, 81 NOT_ENROLLED = 12500010, 82 RESULT_CODE_V9_MAX = 12500010, 83 CANCELED_FROM_WIDGET = 12500011, 84 RESULT_CODE_V10_MAX = 12500011, 85 }; 86 87 enum FaceTipsCode { 88 FACE_AUTH_TIP_TOO_BRIGHT = 1, 89 FACE_AUTH_TIP_TOO_DARK = 2, 90 FACE_AUTH_TIP_TOO_CLOSE = 3, 91 FACE_AUTH_TIP_TOO_FAR = 4, 92 FACE_AUTH_TIP_TOO_HIGH = 5, 93 FACE_AUTH_TIP_TOO_LOW = 6, 94 FACE_AUTH_TIP_TOO_RIGHT = 7, 95 FACE_AUTH_TIP_TOO_LEFT = 8, 96 FACE_AUTH_TIP_TOO_MUCH_MOTION = 9, 97 FACE_AUTH_TIP_POOR_GAZE = 10, 98 FACE_AUTH_TIP_NOT_DETECTED = 11, 99 FACE_AUTH_TIP_MAX = FACE_AUTH_TIP_NOT_DETECTED, 100 }; 101 102 enum FingerprintTips { 103 FINGERPRINT_AUTH_TIP_GOOD = 0, 104 FINGERPRINT_AUTH_TIP_IMAGER_DIRTY = 1, 105 FINGERPRINT_AUTH_TIP_INSUFFICIENT = 2, 106 FINGERPRINT_AUTH_TIP_PARTIAL = 3, 107 FINGERPRINT_AUTH_TIP_TOO_FAST = 4, 108 FINGERPRINT_AUTH_TIP_TOO_SLOW = 5, 109 FINGERPRINT_AUTH_TIP_MAX = FINGERPRINT_AUTH_TIP_TOO_SLOW, 110 }; 111 } // namespace UserAuth 112 } // namespace UserIam 113 } // namespace OHOS 114 #endif /* OHOS_USERAUTH_COMMON_H */ 115