From 628e7c1fad6e9b6d080259aacf699fd621490aad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9F=A9=E9=9C=87?= Date: Fri, 18 Feb 2022 17:55:13 +0800 Subject: [PATCH] fix code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 韩震 --- bundle.json | 2 - frameworks/kitsimpl/src/userauth.cpp | 30 +++- .../kitsimpl/src/userauth_async_stub.cpp | 11 +- frameworks/kitsimpl/src/userauth_proxy.cpp | 31 ++-- interfaces/innerkits/napi/BUILD.gn | 2 - .../innerkits/napi/include/auth_common.h | 2 +- .../napi/include/auth_hilog_wrapper.h | 61 ------- .../innerkits/napi/include/auth_object.h | 2 +- .../innerkits/napi/include/user_auth_helper.h | 2 +- interfaces/innerkits/napi/src/auth_build.cpp | 24 +-- .../innerkits/napi/src/auth_native_module.cpp | 45 ----- .../innerkits/napi/src/authapi_callback.cpp | 139 ++++++++-------- .../innerkits/napi/src/result_convert.cpp | 38 ++--- .../innerkits/napi/src/user_auth_helper.cpp | 26 +-- .../innerkits/napi/src/user_auth_impl.cpp | 157 ++++++++++-------- interfaces/kits/napi/BUILD.gn | 4 +- .../napi/include/user_auth_helper_north.h | 1 + .../kits/napi/src/auth_native_module.cpp | 41 ----- .../kits/napi/src/user_auth_helper_north.cpp | 26 ++- services/src/userauth_adapter.cpp | 4 +- services/src/userauth_excallback_impl.cpp | 3 +- services/src/userauth_service.cpp | 3 +- utils/native/include/userauth_errors.h | 36 ---- 23 files changed, 280 insertions(+), 410 deletions(-) delete mode 100755 interfaces/innerkits/napi/include/auth_hilog_wrapper.h delete mode 100755 interfaces/innerkits/napi/src/auth_native_module.cpp delete mode 100755 interfaces/kits/napi/src/auth_native_module.cpp delete mode 100644 utils/native/include/userauth_errors.h diff --git a/bundle.json b/bundle.json index 0c3e3fb18..7be6d0733 100644 --- a/bundle.json +++ b/bundle.json @@ -63,7 +63,6 @@ "header_files": [ "auth_build.h", "auth_common.h", - "auth_hilog_wrapper.h", "auth_object.h", "authapi_callback.h", "result_convert.h", @@ -80,7 +79,6 @@ "header_files": [ "auth_build.h", "auth_common.h", - "auth_hilog_wrapper.h", "auth_object.h", "authapi_callback.h", "result_convert.h", diff --git a/frameworks/kitsimpl/src/userauth.cpp b/frameworks/kitsimpl/src/userauth.cpp index 796592ab0..88ad3c87b 100644 --- a/frameworks/kitsimpl/src/userauth.cpp +++ b/frameworks/kitsimpl/src/userauth.cpp @@ -12,6 +12,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include + #include #include #include @@ -107,9 +109,13 @@ void UserAuth::GetProperty(const GetPropertyRequest request, std::shared_ptronGetProperty(result); - return ; + return; + } + sptr asyncStub = new (std::nothrow) UserAuthAsyncStub(callback); + if (asyncStub == nullptr) { + USERAUTH_HILOGE(MODULE_INNERKIT, "UserAuthAsyncStub failed, GetProperty IUserAuthCallback is nullptr"); + return; } - sptr asyncStub = new UserAuthAsyncStub(callback); proxy_->GetProperty(request, asyncStub); } void UserAuth::SetProperty(const SetPropertyRequest request, std::shared_ptr callback) @@ -122,9 +128,13 @@ void UserAuth::SetProperty(const SetPropertyRequest request, std::shared_ptronSetProperty(E_RET_NOSERVER); - return ; + return; + } + sptr asyncStub = new (std::nothrow) UserAuthAsyncStub(callback); + if (asyncStub == nullptr) { + USERAUTH_HILOGE(MODULE_INNERKIT, "UserAuthAsyncStub failed, SetProperty IUserAuthCallback is nullptr"); + return; } - sptr asyncStub = new UserAuthAsyncStub(callback); proxy_->SetProperty(request, asyncStub); } uint64_t UserAuth::Auth(const uint64_t challenge, const AuthType authType, const AuthTurstLevel authTurstLevel, @@ -139,7 +149,11 @@ uint64_t UserAuth::Auth(const uint64_t challenge, const AuthType authType, const if (proxy == nullptr) { return E_RET_NOSERVER; } - sptr asyncStub = new UserAuthAsyncStub(callback); + sptr asyncStub = new (std::nothrow) UserAuthAsyncStub(callback); + if (asyncStub == nullptr) { + USERAUTH_HILOGE(MODULE_INNERKIT, "UserAuthAsyncStub failed, Auth IUserAuthCallback is nullptr"); + return GENERAL_ERROR; + } uint64_t ret = proxy_->Auth(challenge, authType, authTurstLevel, asyncStub); return ret; } @@ -155,7 +169,11 @@ uint64_t UserAuth::AuthUser(const int32_t userId, const uint64_t challenge, cons if (proxy == nullptr) { return E_RET_NOSERVER; } - sptr asyncStub = new UserAuthAsyncStub(callback); + sptr asyncStub = new (std::nothrow) UserAuthAsyncStub(callback); + if (asyncStub == nullptr) { + USERAUTH_HILOGE(MODULE_INNERKIT, "UserAuthAsyncStub failed, AuthUser IUserAuthCallback is nullptr"); + return GENERAL_ERROR; + } uint64_t ret = proxy_->AuthUser(userId, challenge, authType, authTurstLevel, asyncStub); return ret; } diff --git a/frameworks/kitsimpl/src/userauth_async_stub.cpp b/frameworks/kitsimpl/src/userauth_async_stub.cpp index 4a7ee0545..6d1832fa5 100644 --- a/frameworks/kitsimpl/src/userauth_async_stub.cpp +++ b/frameworks/kitsimpl/src/userauth_async_stub.cpp @@ -13,6 +13,7 @@ * limitations under the License. */ +#include #include #include "userauth_hilog_wrapper.h" @@ -201,7 +202,7 @@ void UserAuthAsyncStub::onAcquireInfo(const int32_t module, const uint32_t acqui if (authCallback_ == nullptr) { USERAUTH_HILOGE(MODULE_INNERKIT, "userauthAsyncStub onAcquireInfo callback is Null"); - return ; + return; } USERAUTH_HILOGD(MODULE_INNERKIT, "userauthAsyncStub module:%{public}d, acquireInfo:%{public}u", @@ -216,7 +217,7 @@ void UserAuthAsyncStub::onResult(const int32_t result, const AuthResult extraInf if (authCallback_ == nullptr) { USERAUTH_HILOGE(MODULE_INNERKIT, "userauthAsyncStub onResult callback is Null"); - return ; + return; } USERAUTH_HILOGD(MODULE_INNERKIT, "userauthAsyncStub result:%{public}d, remain:%{public}u, freeze:%{public}u", @@ -230,11 +231,11 @@ void UserAuthAsyncStub::onExecutorPropertyInfo(const ExecutorProperty result) if (getPropCallback_ == nullptr) { USERAUTH_HILOGE(MODULE_INNERKIT, "UserAuthAsyncStub onExecutorPropertyInfo callback is Null"); - return ; + return; } USERAUTH_HILOGD(MODULE_INNERKIT, - "userauthAsyncStub result:%{public}d, sub:%{public}llu, remain:%{public}u, freeze:%{public}u", + "userauthAsyncStub result:%{public}d, sub:%{public}" PRIu64 ", remain:%{public}u, freeze:%{public}u", result.result, result.authSubType, result.remainTimes, result.freezingTime); getPropCallback_->onGetProperty(result); } @@ -245,7 +246,7 @@ void UserAuthAsyncStub::onSetExecutorProperty(const int32_t result) if (setPropCallback_ == nullptr) { USERAUTH_HILOGE(MODULE_INNERKIT, "UserAuthAsyncStub onSetExecutorProperty callback is Null"); - return ; + return; } USERAUTH_HILOGD(MODULE_INNERKIT, "userauthAsyncStub result:%{public}d", result); setPropCallback_->onSetProperty(result); diff --git a/frameworks/kitsimpl/src/userauth_proxy.cpp b/frameworks/kitsimpl/src/userauth_proxy.cpp index 65c9093ac..cbab77709 100644 --- a/frameworks/kitsimpl/src/userauth_proxy.cpp +++ b/frameworks/kitsimpl/src/userauth_proxy.cpp @@ -12,6 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include #include #include #include "userauth_hilog_wrapper.h" @@ -44,7 +45,7 @@ int32_t UserAuthProxy::GetAvailableStatus(const AuthType authType, const AuthTur } bool ret = SendRequest(static_cast(IUserAuth::USER_AUTH_GET_AVAILABLE_STATUS), data, reply, option); if (!ret) { - USERAUTH_HILOGE(MODULE_INNERKIT, "userauth SendRequest is failed, error code: %d", ret); + USERAUTH_HILOGE(MODULE_INNERKIT, "userauth SendRequest is failed, error code: %{public}d", ret); return IPC_ERROR; } if (!reply.ReadInt32(result)) { @@ -63,7 +64,7 @@ void UserAuthProxy::GetProperty(const GetPropertyRequest request, sptr(request.authType))) { USERAUTH_HILOGE(MODULE_INNERKIT, "failed to WriteUint32(static_cast(request.authType))."); @@ -82,8 +83,8 @@ void UserAuthProxy::GetProperty(const GetPropertyRequest request, sptronExecutorPropertyInfo(result); - USERAUTH_HILOGE(MODULE_INNERKIT, "userauth SendRequest is failed, error code: %d", ret); - return ; + USERAUTH_HILOGE(MODULE_INNERKIT, "userauth SendRequest is failed, error code: %{public}d", ret); + return; } } void UserAuthProxy::SetProperty(const SetPropertyRequest request, sptr& callback) @@ -95,7 +96,7 @@ void UserAuthProxy::SetProperty(const SetPropertyRequest request, sptr(request.authType))) { USERAUTH_HILOGE(MODULE_INNERKIT, "failed to WriteUint32(static_cast(request.authType))."); @@ -117,8 +118,8 @@ void UserAuthProxy::SetProperty(const SetPropertyRequest request, sptronSetExecutorProperty(result); - USERAUTH_HILOGE(MODULE_INNERKIT, "userauth SendRequest is failed, error code: %d", ret); - return ; + USERAUTH_HILOGE(MODULE_INNERKIT, "userauth SendRequest is failed, error code: %{public}d", ret); + return; } } @@ -129,13 +130,13 @@ uint64_t UserAuthProxy::Auth(const uint64_t challenge, const AuthType authType, u_int64_t result = SUCCESS; MessageParcel data; MessageParcel reply; - MessageOption option; + MessageOption option(MessageOption::TF_SYNC); if (!data.WriteInterfaceToken(UserAuthProxy::GetDescriptor())) { USERAUTH_HILOGE(MODULE_INNERKIT, "userauth write descriptor failed!"); return result; } - USERAUTH_HILOGE(MODULE_SERVICE, "UserAuthProxy::Auth challenge = %{public}llu", challenge); + USERAUTH_HILOGE(MODULE_SERVICE, "UserAuthProxy::Auth challenge = %{public}" PRIu64 "", challenge); if (!data.WriteUint64(challenge)) { USERAUTH_HILOGE(MODULE_INNERKIT, "failed to WriteUint64(challenge)."); return E_READ_PARCEL_ERROR; @@ -154,12 +155,11 @@ uint64_t UserAuthProxy::Auth(const uint64_t challenge, const AuthType authType, } bool ret = SendRequest(IUserAuth::USER_AUTH_AUTH, data, reply, option); if (!ret) { - USERAUTH_HILOGE(MODULE_INNERKIT, "userauth SendRequest is failed, error code: %d", ret); + USERAUTH_HILOGE(MODULE_INNERKIT, "userauth SendRequest is failed, error code: %{public}d", ret); return result; } if (!reply.ReadUint64(result)) { USERAUTH_HILOGE(MODULE_INNERKIT, "userauth Readback fail!"); - return result; } return result; @@ -172,7 +172,7 @@ uint64_t UserAuthProxy::AuthUser(const int32_t userId, const uint64_t challenge, u_int64_t result = SUCCESS; MessageParcel data; MessageParcel reply; - MessageOption option; + MessageOption option(MessageOption::TF_SYNC); if (!data.WriteInterfaceToken(UserAuthProxy::GetDescriptor())) { USERAUTH_HILOGE(MODULE_INNERKIT, "write descriptor failed!"); @@ -200,12 +200,11 @@ uint64_t UserAuthProxy::AuthUser(const int32_t userId, const uint64_t challenge, } bool ret = SendRequest(IUserAuth::USER_AUTH_AUTH_USER, data, reply, option); if (!ret) { - USERAUTH_HILOGE(MODULE_INNERKIT, "SendRequest is failed, error code: %d", ret); + USERAUTH_HILOGE(MODULE_INNERKIT, "SendRequest is failed, error code: %{public}d", ret); return result; } if (!reply.ReadUint64(result)) { USERAUTH_HILOGE(MODULE_INNERKIT, "userauth Readback fail!"); - return result; } return result; @@ -229,7 +228,7 @@ int32_t UserAuthProxy::CancelAuth(const uint64_t contextId) } bool ret = SendRequest(IUserAuth::USER_AUTH_CANCEL_AUTH, data, reply, option); if (!ret) { - USERAUTH_HILOGE(MODULE_INNERKIT, "SendRequest is failed, error code: %d", ret); + USERAUTH_HILOGE(MODULE_INNERKIT, "SendRequest is failed, error code: %{public}d", ret); return IPC_ERROR; } if (!reply.ReadInt32(result)) { @@ -254,7 +253,7 @@ int32_t UserAuthProxy::GetVersion() bool ret = SendRequest(IUserAuth::USER_AUTH_GET_VERSION, data, reply, option); if (!ret) { - USERAUTH_HILOGE(MODULE_INNERKIT, "SendRequest is failed, error code: %d", ret); + USERAUTH_HILOGE(MODULE_INNERKIT, "SendRequest is failed, error code: %{public}d", ret); return IPC_ERROR; } if (!reply.ReadInt32(result)) { diff --git a/interfaces/innerkits/napi/BUILD.gn b/interfaces/innerkits/napi/BUILD.gn index a9a5e15fc..2e616129e 100755 --- a/interfaces/innerkits/napi/BUILD.gn +++ b/interfaces/innerkits/napi/BUILD.gn @@ -29,7 +29,6 @@ ohos_shared_library("userauth") { sources = [ "src/auth_build.cpp", - "src/auth_native_module.cpp", "src/authapi_callback.cpp", "src/result_convert.cpp", "src/user_auth_helper.cpp", @@ -69,7 +68,6 @@ ohos_shared_library("userauth_napi") { sources = [ "src/auth_build.cpp", - "src/auth_native_module.cpp", "src/authapi_callback.cpp", "src/result_convert.cpp", "src/user_auth_helper.cpp", diff --git a/interfaces/innerkits/napi/include/auth_common.h b/interfaces/innerkits/napi/include/auth_common.h index 7ea72267b..3f76f1a93 100755 --- a/interfaces/innerkits/napi/include/auth_common.h +++ b/interfaces/innerkits/napi/include/auth_common.h @@ -76,7 +76,7 @@ struct SetPropertyInfo { napi_async_work asyncWork; napi_value result; int32_t authType; - int32_t key; + uint32_t key; std::vector setInfo; int32_t setResult; }; diff --git a/interfaces/innerkits/napi/include/auth_hilog_wrapper.h b/interfaces/innerkits/napi/include/auth_hilog_wrapper.h deleted file mode 100755 index f8e944e1c..000000000 --- a/interfaces/innerkits/napi/include/auth_hilog_wrapper.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (C) 2021 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. - */ - -#ifndef HILOG_WRAPPER_H -#define HILOG_WRAPPER_H - -#define CONFIG_HILOG -#ifdef CONFIG_HILOG - -#include "hilog/log.h" - -#ifdef HILOG_FATAL -#undef HILOG_FATAL -#endif - -#ifdef HILOG_ERROR -#undef HILOG_ERROR -#endif - -#ifdef HILOG_WARN -#undef HILOG_WARN -#endif - -#ifdef HILOG_INFO -#undef HILOG_INFO -#endif - -#ifdef HILOG_DEBUG -#undef HILOG_DEBUG -#endif - -static constexpr OHOS::HiviewDFX::HiLogLabel LOG_LABEL = {LOG_CORE, 0, "UserAuthNapi===>"}; - -#define HILOG_FATAL(...) (void)OHOS::HiviewDFX::HiLog::Fatal(LOG_LABEL, __VA_ARGS__) -#define HILOG_ERROR(...) (void)OHOS::HiviewDFX::HiLog::Error(LOG_LABEL, __VA_ARGS__) -#define HILOG_WARN(...) (void)OHOS::HiviewDFX::HiLog::Warn(LOG_LABEL, __VA_ARGS__) -#define HILOG_INFO(...) (void)OHOS::HiviewDFX::HiLog::Info(LOG_LABEL, __VA_ARGS__) -#define HILOG_DEBUG(...) (void)OHOS::HiviewDFX::HiLog::Debug(LOG_LABEL, __VA_ARGS__) -#else - -#define HILOG_FATAL(...) -#define HILOG_ERROR(...) -#define HILOG_WARN(...) -#define HILOG_INFO(...) -#define HILOG_DEBUG(...) - -#endif // CONFIG_HILOG - -#endif // HILOG_WRAPPER_H \ No newline at end of file diff --git a/interfaces/innerkits/napi/include/auth_object.h b/interfaces/innerkits/napi/include/auth_object.h index c1fbf65c9..a132515b8 100755 --- a/interfaces/innerkits/napi/include/auth_object.h +++ b/interfaces/innerkits/napi/include/auth_object.h @@ -32,7 +32,7 @@ public: class Napi_SetPropertyRequest { public: int32_t authType_ = 0; - int32_t key_ = 0; + uint32_t key_ = 0; std::vector setInfo_; }; diff --git a/interfaces/innerkits/napi/include/user_auth_helper.h b/interfaces/innerkits/napi/include/user_auth_helper.h index ebe0b46e1..fefa29bca 100755 --- a/interfaces/innerkits/napi/include/user_auth_helper.h +++ b/interfaces/innerkits/napi/include/user_auth_helper.h @@ -50,7 +50,7 @@ napi_value Constructor(napi_env env, napi_callback_info info); * * @param env * @param info - * @return napi_value Instance + * @return napi_value UserAuth Instance */ napi_value UserAuthServiceConstructor(napi_env env, napi_callback_info info); diff --git a/interfaces/innerkits/napi/src/auth_build.cpp b/interfaces/innerkits/napi/src/auth_build.cpp index cd5c85bda..dfaca0fc4 100755 --- a/interfaces/innerkits/napi/src/auth_build.cpp +++ b/interfaces/innerkits/napi/src/auth_build.cpp @@ -12,11 +12,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include #include "auth_build.h" - #include "auth_common.h" -#include "auth_hilog_wrapper.h" +#include "userauth_hilog_wrapper.h" #include "auth_object.h" namespace OHOS { @@ -33,14 +33,14 @@ Napi_SetPropertyRequest AuthBuild::SetPropertyRequestBuild(napi_env env, napi_va { Napi_SetPropertyRequest request; if (object == nullptr) { - HILOG_ERROR("SetPropertyRequestBuild object is null "); + USERAUTH_HILOGE(MODULE_JS_NAPI, "SetPropertyRequestBuild object is null"); return request; } request.authType_ = convert.GetInt32ValueByKey(env, object, "authType"); request.key_ = convert.GetInt32ValueByKey(env, object, "key"); request.setInfo_ = convert.NapiGetValueUint8Array(env, object, "setInfo"); - HILOG_INFO(" AuthBuild::SetPropertyRequestBuild authType = %{public}d", request.authType_); - HILOG_INFO(" AuthBuild::SetPropertyRequestBuild key = %{public}d", request.key_); + USERAUTH_HILOGI(MODULE_JS_NAPI, "AuthBuild::SetPropertyRequestBuild authType = %{public}d, key = %{public}d", + request.authType_, request.key_); return request; } @@ -48,12 +48,12 @@ Napi_GetPropertyRequest AuthBuild::GetPropertyRequestBuild(napi_env env, napi_va { Napi_GetPropertyRequest request; if (object == nullptr) { - HILOG_ERROR("GetPropertyRequestBuild object is null "); + USERAUTH_HILOGE(MODULE_JS_NAPI, "GetPropertyRequestBuild object is null"); return request; } request.authType_ = convert.GetInt32ValueByKey(env, object, "authType"); request.keys_ = convert.GetInt32ArrayValueByKey(env, object, "keys"); - HILOG_INFO(" AuthBuild::GetPropertyRequestBuild authType = %{public}d", request.authType_); + USERAUTH_HILOGI(MODULE_JS_NAPI, "AuthBuild::GetPropertyRequestBuild authType = %{public}d", request.authType_); return request; } @@ -91,26 +91,26 @@ uint64_t AuthBuild::GetUint8ArrayTo64(napi_env env, napi_value value) bool isTypedArray = false; napi_is_typedarray(env, value, &isTypedArray); if (!isTypedArray) { - HILOG_ERROR("GetUint8ArrayTo64 value is not typedarray"); + USERAUTH_HILOGE(MODULE_JS_NAPI, "GetUint8ArrayTo64 value is not typedarray"); return 0; } napi_get_typedarray_info(env, value, &arraytype, &length, reinterpret_cast(&data), &buffer, &offset); if (arraytype != napi_uint8_array) { - HILOG_ERROR("GetUint8ArrayTo64 js value is not uint8Array"); + USERAUTH_HILOGE(MODULE_JS_NAPI, "GetUint8ArrayTo64 js value is not uint8Array"); return 0; } if (offset != 0) { - HILOG_ERROR("offset is %{public}d", offset); + USERAUTH_HILOGE(MODULE_JS_NAPI, "offset is %{public}zu", offset); return 0; } std::vector result(data, data + length); uint8_t tmp[sizeof(uint64_t)]; for (uint32_t i = 0; i < sizeof(uint64_t); i++) { tmp[i] = result[i]; - HILOG_INFO("GetUint8ArrayTo64 result is %{public}d", (unsigned)result[i]); + USERAUTH_HILOGI(MODULE_JS_NAPI, "GetUint8ArrayTo64 result is %{public}u", (unsigned)result[i]); } uint64_t *re = static_cast(static_cast(tmp)); - HILOG_INFO("GetUint8ArrayTo64 resultUint64 is %{public}llu", *re); + USERAUTH_HILOGI(MODULE_JS_NAPI, "GetUint8ArrayTo64 resultUint64 is %{public}" PRIu64 "", *re); return *re; } diff --git a/interfaces/innerkits/napi/src/auth_native_module.cpp b/interfaces/innerkits/napi/src/auth_native_module.cpp deleted file mode 100755 index 4b9b1abb0..000000000 --- a/interfaces/innerkits/napi/src/auth_native_module.cpp +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2021 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. - */ - -#include - -#include "user_auth_helper.h" - -namespace OHOS { -namespace UserIAM { -namespace UserAuth { -static napi_value ModuleInit(napi_env env, napi_value exports) -{ - OHOS::UserIAM::UserAuth::Init(env, exports); - return exports; -} -extern "C" __attribute__((constructor)) void RegisterModule(void) -{ - napi_module module = {.nm_version = 1, // NAPI v1 - .nm_flags = 0, // normal - .nm_filename = nullptr, - .nm_register_func = ModuleInit, -#ifdef USER_AUTH_FOR_API6 - .nm_modname = "userIAM.userAuth", -#else - .nm_modname = "UserAuth", -#endif - .nm_priv = nullptr, - .reserved = {}}; - napi_module_register(&module); -} -} // namespace UserAuth -} // namespace UserIAM -} // namespace OHOS diff --git a/interfaces/innerkits/napi/src/authapi_callback.cpp b/interfaces/innerkits/napi/src/authapi_callback.cpp index 80bd4459b..f78b589e0 100755 --- a/interfaces/innerkits/napi/src/authapi_callback.cpp +++ b/interfaces/innerkits/napi/src/authapi_callback.cpp @@ -13,12 +13,12 @@ * limitations under the License. */ -#include "authapi_callback.h" - +#include #include -#include "securec.h" -#include "auth_hilog_wrapper.h" +#include "authapi_callback.h" +#include "securec.h" +#include "userauth_hilog_wrapper.h" namespace OHOS { namespace UserIAM { @@ -51,13 +51,13 @@ AuthApiCallback::~AuthApiCallback() napi_value AuthApiCallback::Uint8ArrayToNapi(napi_env env, std::vector value) { int size = value.size(); - HILOG_INFO("Uint8ArrayToNapi size = %{public}d", size); + USERAUTH_HILOGI(MODULE_JS_NAPI, "Uint8ArrayToNapi size = %{public}d", size); napi_value out = nullptr; void *data = nullptr; napi_value buffer = nullptr; NAPI_CALL(env, napi_create_arraybuffer(env, value.size(), &data, &buffer)); if (memcpy_s(data, value.size(), value.data(), value.size()) != 0) { - HILOG_ERROR("AuthApiCallback Uint8ArrayToNapi error"); + USERAUTH_HILOGE(MODULE_JS_NAPI, "AuthApiCallback Uint8ArrayToNapi error"); } NAPI_CALL(env, napi_create_typedarray(env, napi_uint8_array, value.size(), buffer, 0, &out)); return out; @@ -84,26 +84,26 @@ napi_value AuthApiCallback::BuildOnResult( void AuthApiCallback::OnAuthAcquireInfo(AcquireInfoInner *acquireInfoInner) { - HILOG_INFO("AuthApiCallback OnAuthAcquireInfo start"); + USERAUTH_HILOGI(MODULE_JS_NAPI, "AuthApiCallback OnAuthAcquireInfo start"); uv_loop_s *loop(nullptr); napi_get_uv_event_loop(authInfo_->callBackInfo.env, &loop); if (loop == nullptr) { - HILOG_ERROR("loop is null"); + USERAUTH_HILOGE(MODULE_JS_NAPI, "loop is null"); delete acquireInfoInner; return; } uv_work_t *work = new (std::nothrow) uv_work_t; if (work == nullptr) { - HILOG_ERROR("work is null"); + USERAUTH_HILOGE(MODULE_JS_NAPI, "work is null"); delete acquireInfoInner; return; } work->data = reinterpret_cast(acquireInfoInner); uv_queue_work(loop, work, [] (uv_work_t *work) {}, [] (uv_work_t *work, int status) { - HILOG_INFO("Do OnAuthAcquireInfo work"); + USERAUTH_HILOGI(MODULE_JS_NAPI, "Do OnAuthAcquireInfo work"); AcquireInfoInner *acquireInfoInner = reinterpret_cast(work->data); if (acquireInfoInner == nullptr) { - HILOG_ERROR("authInfo is null"); + USERAUTH_HILOGE(MODULE_JS_NAPI, "authInfo is null"); delete work; return; } @@ -112,7 +112,7 @@ void AuthApiCallback::OnAuthAcquireInfo(AcquireInfoInner *acquireInfoInner) napi_value callback; napi_status napiStatus = napi_get_reference_value(env, acquireInfoInner->onAcquireInfo, &callback); if (napiStatus != napi_ok) { - HILOG_INFO("napi_get_reference_value faild "); + USERAUTH_HILOGE(MODULE_JS_NAPI, "napi_get_reference_value faild"); delete acquireInfoInner; delete work; return; @@ -123,7 +123,7 @@ void AuthApiCallback::OnAuthAcquireInfo(AcquireInfoInner *acquireInfoInner) napi_create_int32(env, acquireInfoInner->extraInfo, ¶ms[PARAM2]); napiStatus = napi_call_function(env, acquireInfoInner->jsFunction, callback, PARAM3, params, &returnOnAcquire); if (napiStatus != napi_ok) { - HILOG_ERROR("napi_call_function faild"); + USERAUTH_HILOGE(MODULE_JS_NAPI, "napi_call_function faild"); } delete acquireInfoInner; delete work; @@ -135,7 +135,7 @@ void AuthApiCallback::onAcquireInfo(const int32_t module, const uint32_t acquire if (userInfo_ != nullptr) { AcquireInfoInner *acquireInfoInner = new (std::nothrow) AcquireInfoInner(); if (acquireInfoInner == nullptr) { - HILOG_ERROR("acquireInfoInner is null"); + USERAUTH_HILOGE(MODULE_JS_NAPI, "acquireInfoInner is null"); return; } acquireInfoInner->env = userInfo_->callBackInfo.env; @@ -146,13 +146,13 @@ void AuthApiCallback::onAcquireInfo(const int32_t module, const uint32_t acquire acquireInfoInner->extraInfo = extraInfo; OnAuthAcquireInfo(acquireInfoInner); } else { - HILOG_INFO("AuthApiCallback onAcquireInfo userInfo_ is nullptr "); + USERAUTH_HILOGE(MODULE_JS_NAPI, "AuthApiCallback onAcquireInfo userInfo_ is nullptr"); } if (authInfo_ != nullptr) { AcquireInfoInner *acquireInfoInner = new (std::nothrow) AcquireInfoInner(); if (acquireInfoInner == nullptr) { - HILOG_ERROR("acquireInfoInner is null"); + USERAUTH_HILOGE(MODULE_JS_NAPI, "acquireInfoInner is null"); return; } acquireInfoInner->env = authInfo_->callBackInfo.env; @@ -163,17 +163,17 @@ void AuthApiCallback::onAcquireInfo(const int32_t module, const uint32_t acquire acquireInfoInner->extraInfo = extraInfo; OnAuthAcquireInfo(acquireInfoInner); } else { - HILOG_INFO("AuthApiCallback onAcquireInfo authInfo_ is nullptr "); + USERAUTH_HILOGE(MODULE_JS_NAPI, "AuthApiCallback onAcquireInfo authInfo_ is nullptr"); } - HILOG_INFO("AuthApiCallback onAcquireInfo end"); + USERAUTH_HILOGI(MODULE_JS_NAPI, "AuthApiCallback onAcquireInfo end"); } static void OnUserAuthResultWork(uv_work_t *work, int status) { - HILOG_INFO("Do OnUserAuthResult work"); + USERAUTH_HILOGI(MODULE_JS_NAPI, "Do OnUserAuthResult work"); AuthUserInfo *userInfo = reinterpret_cast(work->data); if (userInfo == nullptr) { - HILOG_ERROR("authInfo is null"); + USERAUTH_HILOGE(MODULE_JS_NAPI, "authInfo is null"); delete work; return; } @@ -181,7 +181,7 @@ static void OnUserAuthResultWork(uv_work_t *work, int status) napi_value callback; napi_status napiStatus = napi_get_reference_value(env, userInfo->onResult, &callback); if (napiStatus != napi_ok) { - HILOG_INFO("napi_get_reference_value faild "); + USERAUTH_HILOGE(MODULE_JS_NAPI, "napi_get_reference_value faild"); delete userInfo; delete work; return; @@ -198,18 +198,18 @@ static void OnUserAuthResultWork(uv_work_t *work, int status) void AuthApiCallback::OnUserAuthResult(const int32_t result, const AuthResult extraInfo) { - HILOG_INFO("AuthApiCallback OnUserAuthResult start"); + USERAUTH_HILOGI(MODULE_JS_NAPI, "AuthApiCallback OnUserAuthResult start"); uv_loop_s *loop(nullptr); napi_get_uv_event_loop(userInfo_->callBackInfo.env, &loop); if (loop == nullptr) { - HILOG_ERROR("loop is null"); + USERAUTH_HILOGE(MODULE_JS_NAPI, "loop is null"); delete userInfo_; userInfo_ = nullptr; return; } uv_work_t *work = new (std::nothrow) uv_work_t; if (work == nullptr) { - HILOG_ERROR("work is null"); + USERAUTH_HILOGE(MODULE_JS_NAPI, "work is null"); delete userInfo_; userInfo_ = nullptr; return; @@ -225,10 +225,10 @@ void AuthApiCallback::OnUserAuthResult(const int32_t result, const AuthResult ex static void OnAuthResultWork(uv_work_t *work, int status) { - HILOG_INFO("Do OnAuthResult work"); + USERAUTH_HILOGI(MODULE_JS_NAPI, "Do OnAuthResult work"); AuthInfo *authInfo = reinterpret_cast(work->data); if (authInfo == nullptr) { - HILOG_ERROR("authInfo is null"); + USERAUTH_HILOGE(MODULE_JS_NAPI, "authInfo is null"); delete work; return; } @@ -236,7 +236,7 @@ static void OnAuthResultWork(uv_work_t *work, int status) napi_value callback; napi_status napiStatus = napi_get_reference_value(env, authInfo->onResult, &callback); if (napiStatus != napi_ok) { - HILOG_INFO("napi_get_reference_value faild "); + USERAUTH_HILOGE(MODULE_JS_NAPI, "napi_get_reference_value faild"); delete authInfo; delete work; return; @@ -253,18 +253,18 @@ static void OnAuthResultWork(uv_work_t *work, int status) void AuthApiCallback::OnAuthResult(const int32_t result, const AuthResult extraInfo) { - HILOG_INFO("AuthApiCallback OnAuthResult start"); + USERAUTH_HILOGI(MODULE_JS_NAPI, "AuthApiCallback OnAuthResult start"); uv_loop_s *loop(nullptr); napi_get_uv_event_loop(authInfo_->callBackInfo.env, &loop); if (loop == nullptr) { - HILOG_ERROR("loop is null"); + USERAUTH_HILOGE(MODULE_JS_NAPI, "loop is null"); delete authInfo_; authInfo_ = nullptr; return; } uv_work_t *work = new (std::nothrow) uv_work_t; if (work == nullptr) { - HILOG_ERROR("work is null"); + USERAUTH_HILOGE(MODULE_JS_NAPI, "work is null"); delete authInfo_; authInfo_ = nullptr; return; @@ -280,17 +280,17 @@ void AuthApiCallback::OnAuthResult(const int32_t result, const AuthResult extraI static void OnExecuteResultWork(uv_work_t *work, int status) { - HILOG_INFO("Do OnExecuteResultWork"); + USERAUTH_HILOGI(MODULE_JS_NAPI, "Do OnExecuteResultWork"); ExecuteInfo *executeInfo = reinterpret_cast(work->data); if (executeInfo == nullptr) { - HILOG_ERROR("executeInfo is null"); + USERAUTH_HILOGE(MODULE_JS_NAPI, "executeInfo is null"); delete work; return; } napi_env env = executeInfo->env; napi_value result; if (napi_create_int32(env, executeInfo->result, &result) != napi_ok) { - HILOG_ERROR("napi_create_int32 faild"); + USERAUTH_HILOGE(MODULE_JS_NAPI, "napi_create_int32 faild"); delete work; delete executeInfo; return; @@ -298,12 +298,12 @@ static void OnExecuteResultWork(uv_work_t *work, int status) napi_value undefined; napi_get_undefined(env, &undefined); if (executeInfo->isPromise) { - HILOG_INFO("do promise %{public}d", napi_resolve_deferred(env, executeInfo->deferred, result)); + USERAUTH_HILOGE(MODULE_JS_NAPI, "do promise %{public}d", napi_resolve_deferred(env, executeInfo->deferred, result)); } else { napi_value callback; napi_get_reference_value(env, executeInfo->callbackRef, &callback); napi_value callResult = nullptr; - HILOG_INFO("do callback %{public}d", napi_call_function(env, undefined, callback, 1, &result, &callResult)); + USERAUTH_HILOGI(MODULE_JS_NAPI, "do callback %{public}d", napi_call_function(env, undefined, callback, 1, &result, &callResult)); } delete executeInfo; delete work; @@ -311,18 +311,18 @@ static void OnExecuteResultWork(uv_work_t *work, int status) void AuthApiCallback::OnExecuteResult(const int32_t result) { - HILOG_INFO("AuthApiCallback OnExecuteResult start"); + USERAUTH_HILOGI(MODULE_JS_NAPI, "AuthApiCallback OnExecuteResult start"); uv_loop_s *loop(nullptr); napi_get_uv_event_loop(executeInfo_->env, &loop); if (loop == nullptr) { - HILOG_ERROR("loop is null"); + USERAUTH_HILOGE(MODULE_JS_NAPI, "loop is null"); delete executeInfo_; executeInfo_ = nullptr; return; } uv_work_t *work = new (std::nothrow) uv_work_t; if (work == nullptr) { - HILOG_ERROR("work is null"); + USERAUTH_HILOGE(MODULE_JS_NAPI, "work is null"); delete executeInfo_; executeInfo_ = nullptr; return; @@ -335,26 +335,23 @@ void AuthApiCallback::OnExecuteResult(const int32_t result) void AuthApiCallback::onResult(const int32_t result, const AuthResult extraInfo) { - HILOG_INFO("AuthApiCallback onResult start result = %{public}d", result); - HILOG_INFO("AuthApiCallback onResult start token.length = %{public}d", extraInfo.token.size()); - HILOG_INFO("AuthApiCallback onResult start extraInfo.remainTimes = %{public}u", extraInfo.remainTimes); - HILOG_INFO("AuthApiCallback onResult start extraInfo.freezingTime = %{public}u", extraInfo.freezingTime); + USERAUTH_HILOGI(MODULE_JS_NAPI, "AuthApiCallback onResult start result = %{public}d", result); if (userInfo_ != nullptr) { OnUserAuthResult(result, extraInfo); } else { - HILOG_ERROR("AuthApiCallback onResult userInfo_ is nullptr "); + USERAUTH_HILOGE(MODULE_JS_NAPI, "AuthApiCallback onResult userInfo_ is nullptr"); } if (authInfo_ != nullptr) { OnAuthResult(result, extraInfo); } else { - HILOG_ERROR("AuthApiCallback onResult authInfo_ is nullptr "); + USERAUTH_HILOGE(MODULE_JS_NAPI, "AuthApiCallback onResult authInfo_ is nullptr"); } if (executeInfo_ != nullptr) { OnExecuteResult(result); } else { - HILOG_ERROR("AuthApiCallback onResult executeInfo_ is nullptr "); + USERAUTH_HILOGE(MODULE_JS_NAPI, "AuthApiCallback onResult executeInfo_ is nullptr "); } - HILOG_INFO("AuthApiCallback onResult end"); + USERAUTH_HILOGI(MODULE_JS_NAPI, "AuthApiCallback onResult end"); } GetPropApiCallback::GetPropApiCallback(GetPropertyInfo *getPropertyInfo) @@ -368,10 +365,10 @@ GetPropApiCallback::~GetPropApiCallback() static void GetPropertyInfoCallback(uv_work_t* work, int status) { - HILOG_INFO("Do OnAuthAcquireInfo work"); + USERAUTH_HILOGI(MODULE_JS_NAPI, "Do OnAuthAcquireInfo work"); GetPropertyInfo *getPropertyInfo = reinterpret_cast(work->data); if (getPropertyInfo == nullptr) { - HILOG_ERROR("getPropertyInfo is null"); + USERAUTH_HILOGE(MODULE_JS_NAPI, "getPropertyInfo is null"); delete work; return; } @@ -380,32 +377,32 @@ static void GetPropertyInfoCallback(uv_work_t* work, int status) resultData[PARAM0] = GetPropApiCallback::BuildExecutorProperty(env, getPropertyInfo->getResult, getPropertyInfo->remainTimes, getPropertyInfo->freezingTime, getPropertyInfo->authSubType); if (getPropertyInfo->callBackInfo.callBack != nullptr) { - HILOG_INFO("onExecutorPropertyInfo async"); + USERAUTH_HILOGI(MODULE_JS_NAPI, "onExecutorPropertyInfo async"); napi_value global = nullptr; napi_status napiStatus = napi_get_global(env, &global); if (napiStatus != napi_ok) { - HILOG_INFO("napi_get_global faild "); + USERAUTH_HILOGE(MODULE_JS_NAPI, "napi_get_global faild"); goto EXIT; } napi_value resultValue = nullptr; napi_value callBack = nullptr; napiStatus = napi_get_reference_value(env, getPropertyInfo->callBackInfo.callBack, &callBack); if (napiStatus != napi_ok) { - HILOG_INFO("napi_get_reference_value faild "); + USERAUTH_HILOGE(MODULE_JS_NAPI, "napi_get_reference_value faild"); goto EXIT; } napiStatus = napi_call_function(env, global, callBack, PARAM1, resultData, &resultValue); if (napiStatus != napi_ok) { - HILOG_INFO("napi_call_function faild "); + USERAUTH_HILOGE(MODULE_JS_NAPI, "napi_call_function faild"); goto EXIT; } } else { - HILOG_INFO("onExecutorPropertyInfo promise"); + USERAUTH_HILOGI(MODULE_JS_NAPI, "onExecutorPropertyInfo promise"); napi_value resultValue = resultData[PARAM0]; napi_deferred deferred = getPropertyInfo->callBackInfo.deferred; napi_status napiStatus = napi_resolve_deferred(env, deferred, resultValue); if (napiStatus != napi_ok) { - HILOG_INFO("napi_resolve_deferred faild "); + USERAUTH_HILOGE(MODULE_JS_NAPI, "napi_resolve_deferred faild"); goto EXIT; } } @@ -440,25 +437,21 @@ napi_value GetPropApiCallback::BuildExecutorProperty( void GetPropApiCallback::onGetProperty(const ExecutorProperty result) { - HILOG_INFO("GetPropApiCallback onGetProperty 1 = %{public}d", result.result); - HILOG_INFO("GetPropApiCallback onGetProperty 2 = %{public}llu", result.authSubType); - HILOG_INFO("GetPropApiCallback onGetProperty 3 = %{public}u", result.remainTimes); - HILOG_INFO("GetPropApiCallback onGetProperty 4 = %{public}u", result.freezingTime); if (getPropertyInfo_ == nullptr) { - HILOG_ERROR("GetPropApiCallback onGetProperty getPropertyInfo_ is nullptr"); + USERAUTH_HILOGE(MODULE_JS_NAPI, "GetPropApiCallback onGetProperty getPropertyInfo_ is nullptr"); return; } uv_loop_s *loop(nullptr); napi_get_uv_event_loop(getPropertyInfo_->callBackInfo.env, &loop); if (loop == nullptr) { - HILOG_ERROR("loop is null"); + USERAUTH_HILOGE(MODULE_JS_NAPI, "loop is null"); delete getPropertyInfo_; getPropertyInfo_ = nullptr; return; } uv_work_t *work = new (std::nothrow) uv_work_t; if (work == nullptr) { - HILOG_ERROR("work is null"); + USERAUTH_HILOGE(MODULE_JS_NAPI, "work is null"); delete getPropertyInfo_; getPropertyInfo_ = nullptr; return; @@ -469,7 +462,7 @@ void GetPropApiCallback::onGetProperty(const ExecutorProperty result) getPropertyInfo_->freezingTime = result.freezingTime; work->data = reinterpret_cast(getPropertyInfo_); getPropertyInfo_ = nullptr; - HILOG_INFO("Before GetPropertyInfoCallback"); + USERAUTH_HILOGI(MODULE_JS_NAPI, "Before GetPropertyInfoCallback"); uv_queue_work(loop, work, [] (uv_work_t *work) {}, GetPropertyInfoCallback); } @@ -484,24 +477,24 @@ SetPropApiCallback::~SetPropApiCallback() static void SetExecutorPropertyCallback(uv_work_t *work, int status) { - HILOG_INFO("Do SetExecutorPropertyCallback work"); + USERAUTH_HILOGI(MODULE_JS_NAPI, "Do SetExecutorPropertyCallback work"); SetPropertyInfo *setPropertyInfo = reinterpret_cast(work->data); if (setPropertyInfo == nullptr) { - HILOG_ERROR("authInfo is null"); + USERAUTH_HILOGE(MODULE_JS_NAPI, "authInfo is null"); delete work; return; } napi_env env = setPropertyInfo->callBackInfo.env; napi_status napiStatus = napi_create_int32(env, setPropertyInfo->setResult, &setPropertyInfo->result); if (napiStatus != napi_ok) { - HILOG_ERROR("napi_create_int32 faild"); + USERAUTH_HILOGE(MODULE_JS_NAPI, "napi_create_int32 faild"); goto EXIT; } if (setPropertyInfo->callBackInfo.callBack != nullptr) { napi_value global = nullptr; napiStatus = napi_get_global(env, &global); if (napiStatus != napi_ok) { - HILOG_ERROR("napi_get_global faild"); + USERAUTH_HILOGE(MODULE_JS_NAPI, "napi_get_global faild"); goto EXIT; } napi_value resultData[PARAM1]; @@ -511,12 +504,12 @@ static void SetExecutorPropertyCallback(uv_work_t *work, int status) napi_value callBack = nullptr; napiStatus = napi_get_reference_value(env, setPropertyInfo->callBackInfo.callBack, &callBack); if (napiStatus != napi_ok) { - HILOG_ERROR("napi_get_reference_value faild"); + USERAUTH_HILOGE(MODULE_JS_NAPI, "napi_get_reference_value faild"); goto EXIT; } napiStatus = napi_call_function(env, global, callBack, PARAM1, resultData, &result); if (napiStatus != napi_ok) { - HILOG_ERROR("napi_call_function faild"); + USERAUTH_HILOGE(MODULE_JS_NAPI, "napi_call_function faild"); goto EXIT; } } else { @@ -524,7 +517,7 @@ static void SetExecutorPropertyCallback(uv_work_t *work, int status) napi_deferred deferred = setPropertyInfo->callBackInfo.deferred; napiStatus = napi_resolve_deferred(env, deferred, result); if (napiStatus != napi_ok) { - HILOG_ERROR("napi_call_function faild"); + USERAUTH_HILOGE(MODULE_JS_NAPI, "napi_call_function faild"); goto EXIT; } } @@ -535,22 +528,22 @@ EXIT: void SetPropApiCallback::onSetProperty(const int32_t result) { - HILOG_INFO("onSetProperty start = %{public}d", result); + USERAUTH_HILOGI(MODULE_JS_NAPI, "onSetProperty start = %{public}d", result); if (setPropertyInfo_ != nullptr) { - HILOG_ERROR("setPropertyInfo is null"); + USERAUTH_HILOGE(MODULE_JS_NAPI, "setPropertyInfo is null"); return; } uv_loop_s *loop(nullptr); napi_get_uv_event_loop(setPropertyInfo_->callBackInfo.env, &loop); if (loop == nullptr) { - HILOG_ERROR("loop is null"); + USERAUTH_HILOGE(MODULE_JS_NAPI, "loop is null"); delete setPropertyInfo_; setPropertyInfo_ = nullptr; return; } uv_work_t *work = new (std::nothrow) uv_work_t; if (work == nullptr) { - HILOG_ERROR("work is null"); + USERAUTH_HILOGE(MODULE_JS_NAPI, "work is null"); delete setPropertyInfo_; setPropertyInfo_ = nullptr; return; diff --git a/interfaces/innerkits/napi/src/result_convert.cpp b/interfaces/innerkits/napi/src/result_convert.cpp index 77abb2f6d..90d0c4e32 100644 --- a/interfaces/innerkits/napi/src/result_convert.cpp +++ b/interfaces/innerkits/napi/src/result_convert.cpp @@ -13,11 +13,11 @@ * limitations under the License. */ -#include "result_convert.h" +#include +#include "result_convert.h" #include "securec.h" - -#include "auth_hilog_wrapper.h" +#include "userauth_hilog_wrapper.h" namespace OHOS { namespace UserIAM { @@ -32,7 +32,7 @@ ResultConvert::~ResultConvert() napi_value ResultConvert::Uint64ToUint8Napi(napi_env env, uint64_t value) { - HILOG_INFO("ResultConvert Uint64ToUint8Napi uint64_t %{public}llu", value); + USERAUTH_HILOGI(MODULE_JS_NAPI, "ResultConvert Uint64ToUint8Napi uint64_t %{public}" PRIu64 "", value); size_t length = sizeof(value); void *data = nullptr; napi_value arrayBuffer = nullptr; @@ -59,16 +59,16 @@ std::vector ResultConvert::NapiGetValueUint8Array(napi_env env, napi_va bool isTypedArray = false; napi_is_typedarray(env, jsValue, &isTypedArray); if (!isTypedArray) { - HILOG_ERROR("NapiGetValueUint8Array jsValue is not typedarray"); + USERAUTH_HILOGE(MODULE_JS_NAPI, "NapiGetValueUint8Array jsValue is not typedarray"); return RetNull; } napi_get_typedarray_info(env, jsValue, &arraytype, &length, reinterpret_cast(&data), &buffer, &offset); if (arraytype != napi_uint8_array) { - HILOG_ERROR("NapiGetValueUint8Array js jsValue is not uint8Array"); + USERAUTH_HILOGE(MODULE_JS_NAPI, "NapiGetValueUint8Array js jsValue is not uint8Array"); return RetNull; } if (offset != 0) { - HILOG_ERROR("offset is %{public}d", offset); + USERAUTH_HILOGE(MODULE_JS_NAPI, "offset is %{public}zu", offset); return RetNull; } std::vector result(data, data + length); @@ -84,7 +84,7 @@ napi_valuetype ResultConvert::GetType(napi_env env, napi_value value) napi_valuetype type; status = napi_typeof(env, value, &type); if (status != napi_ok) { - HILOG_ERROR("napi_typeof faild"); + USERAUTH_HILOGE(MODULE_JS_NAPI, "napi_typeof faild"); } return type; } @@ -108,7 +108,7 @@ std::vector ResultConvert::GetCppArrayUint32(napi_env env, napi_value uint32_t arrayLength = 0; napi_get_array_length(env, value, &arrayLength); if (arrayLength <= 0) { - HILOG_ERROR("%{public}s The array is empty.", __func__); + USERAUTH_HILOGE(MODULE_JS_NAPI, "%{public}s The array is empty.", __func__); return std::vector(); } std::vector paramArrays; @@ -118,7 +118,7 @@ std::vector ResultConvert::GetCppArrayUint32(napi_env env, napi_value napi_valuetype napiValueType = napi_undefined; napi_typeof(env, napiElement, &napiValueType); if (napiValueType != napi_number) { - HILOG_ERROR("%{public}s Wrong argument type. Numbers expected.", __func__); + USERAUTH_HILOGE(MODULE_JS_NAPI, "%{public}s Wrong argument type. Numbers expected.", __func__); return std::vector(); } uint32_t napiValue = 0; @@ -141,13 +141,13 @@ std::vector ResultConvert::GetInt32ArrayValueByKey(napi_env env, napi_ bool isArray = false; status = napi_is_array(env, array, &isArray); if (status != napi_ok) { - HILOG_INFO("napi_is_array is failed"); + USERAUTH_HILOGI(MODULE_JS_NAPI, "napi_is_array is failed"); return std::vector(); } if (isArray) { - HILOG_INFO("args[PIN_PARAMS_ONE] is a array"); + USERAUTH_HILOGI(MODULE_JS_NAPI, "args[PIN_PARAMS_ONE] is a array"); } else { - HILOG_INFO("args[PIN_PARAMS_ONE] is not a array"); + USERAUTH_HILOGI(MODULE_JS_NAPI, "args[PIN_PARAMS_ONE] is not a array"); return std::vector(); } return GetCppArrayUint32(env, array); @@ -157,7 +157,7 @@ std::string ResultConvert::NapiGetValueString(napi_env env, napi_value value) { napi_status status; if (value == nullptr) { - HILOG_ERROR("AuthBuild NapiGetValueString value is nullptr"); + USERAUTH_HILOGE(MODULE_JS_NAPI, "AuthBuild NapiGetValueString value is nullptr"); return ""; } std::string resultValue = ""; @@ -166,11 +166,11 @@ std::string ResultConvert::NapiGetValueString(napi_env env, napi_value value) size_t resultSize = 0; status = napi_get_value_string_utf8(env, value, valueString, valueSize, &resultSize); if (status != napi_ok) { - HILOG_ERROR("napi_get_value_string_utf8 faild"); + USERAUTH_HILOGE(MODULE_JS_NAPI, "napi_get_value_string_utf8 faild"); } resultValue = valueString; if (resultValue == "") { - HILOG_ERROR("ContactsBuild NapiGetValueString Data error"); + USERAUTH_HILOGE(MODULE_JS_NAPI, "ContactsBuild NapiGetValueString Data error"); return ""; } return resultValue; @@ -181,8 +181,8 @@ int32_t ResultConvert::NapiGetValueInt32(napi_env env, napi_value value) if (value == nullptr) { return GET_VALUE_ERROR; } - int32_t result; - napi_status status = napi_get_value_int32(env, value, &result); + uint32_t result; + napi_status status = napi_get_value_uint32(env, value, &result); if (status != napi_ok) { return GET_VALUE_ERROR; } @@ -206,7 +206,7 @@ int ResultConvert::NapiGetValueInt(napi_env env, napi_value value) napi_value ResultConvert::GetNapiValue(napi_env env, const std::string keyChar, napi_value object) { if (object == nullptr) { - HILOG_ERROR("ResultConvert::GetNapiValue object is nullptr"); + USERAUTH_HILOGE(MODULE_JS_NAPI, "ResultConvert::GetNapiValue object is nullptr"); return nullptr; } napi_value key = nullptr; diff --git a/interfaces/innerkits/napi/src/user_auth_helper.cpp b/interfaces/innerkits/napi/src/user_auth_helper.cpp index 2d656c160..ec320197a 100755 --- a/interfaces/innerkits/napi/src/user_auth_helper.cpp +++ b/interfaces/innerkits/napi/src/user_auth_helper.cpp @@ -12,10 +12,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include #include "user_auth_helper.h" - -#include "auth_hilog_wrapper.h" +#include "userauth_hilog_wrapper.h" #include "user_auth_impl.h" namespace OHOS { @@ -30,6 +30,7 @@ namespace UserAuth { */ napi_value UserAuthServiceConstructor(napi_env env, napi_callback_info info) { + USERAUTH_HILOGI(MODULE_JS_NAPI, "%{public}s, start.", __func__); std::shared_ptr userAuthImpl; userAuthImpl.reset(new UserAuthImpl()); napi_value thisVar = nullptr; @@ -63,7 +64,7 @@ napi_value GetVersion(napi_env env, napi_callback_info info) NAPI_CALL(env, napi_get_cb_info(env, info, &argcAsync, args, &thisVar, nullptr)); UserAuthImpl *userAuthImpl = nullptr; NAPI_CALL(env, napi_unwrap(env, thisVar, (void **)&userAuthImpl)); - HILOG_INFO("UserAuthHelper, GetVersion"); + USERAUTH_HILOGI(MODULE_JS_NAPI, "UserAuthHelper, GetVersion"); return userAuthImpl->GetVersion(env, info); } @@ -82,7 +83,7 @@ napi_value GetAvailableStatus(napi_env env, napi_callback_info info) NAPI_CALL(env, napi_get_cb_info(env, info, &argcAsync, args, &thisVar, nullptr)); UserAuthImpl *userAuthImpl = nullptr; NAPI_CALL(env, napi_unwrap(env, thisVar, (void **)&userAuthImpl)); - HILOG_INFO("UserAuthHelper, getAvailableStatus"); + USERAUTH_HILOGI(MODULE_JS_NAPI, "UserAuthHelper, getAvailableStatus"); return userAuthImpl->GetAvailableStatus(env, info); } @@ -101,7 +102,7 @@ napi_value GetProperty(napi_env env, napi_callback_info info) NAPI_CALL(env, napi_get_cb_info(env, info, &argcAsync, args, &thisVar, nullptr)); UserAuthImpl *userAuthImpl = nullptr; NAPI_CALL(env, napi_unwrap(env, thisVar, (void **)&userAuthImpl)); - HILOG_INFO("UserAuthHelper, GetProperty"); + USERAUTH_HILOGI(MODULE_JS_NAPI, "UserAuthHelper, GetProperty"); return userAuthImpl->GetProperty(env, info); } @@ -120,7 +121,7 @@ napi_value SetProperty(napi_env env, napi_callback_info info) NAPI_CALL(env, napi_get_cb_info(env, info, &argcAsync, args, &thisVar, nullptr)); UserAuthImpl *userAuthImpl = nullptr; NAPI_CALL(env, napi_unwrap(env, thisVar, (void **)&userAuthImpl)); - HILOG_INFO("UserAuthHelper, SetProperty"); + USERAUTH_HILOGI(MODULE_JS_NAPI, "UserAuthHelper, SetProperty"); return userAuthImpl->SetProperty(env, info); } @@ -140,7 +141,7 @@ napi_value Auth(napi_env env, napi_callback_info info) NAPI_CALL(env, napi_get_cb_info(env, info, &argcAsync, args, &thisVar, nullptr)); UserAuthImpl *userAuthImpl = nullptr; NAPI_CALL(env, napi_unwrap(env, thisVar, (void **)&userAuthImpl)); - HILOG_INFO("UserAuthHelper, Auth"); + USERAUTH_HILOGI(MODULE_JS_NAPI, "UserAuthHelper, Auth"); return userAuthImpl->Auth(env, info); } @@ -152,7 +153,7 @@ napi_value Execute(napi_env env, napi_callback_info info) NAPI_CALL(env, napi_get_cb_info(env, info, &argcAsync, args, &thisVar, nullptr)); UserAuthImpl *userAuthImpl = nullptr; NAPI_CALL(env, napi_unwrap(env, thisVar, (void **)&userAuthImpl)); - HILOG_INFO("UserAuthHelper, Execute"); + USERAUTH_HILOGI(MODULE_JS_NAPI, "UserAuthHelper, Execute"); return userAuthImpl->Execute(env, info); } @@ -172,7 +173,7 @@ napi_value AuthUser(napi_env env, napi_callback_info info) NAPI_CALL(env, napi_get_cb_info(env, info, &argcAsync, args, &thisVar, nullptr)); UserAuthImpl *userAuthImpl = nullptr; NAPI_CALL(env, napi_unwrap(env, thisVar, (void **)&userAuthImpl)); - HILOG_INFO("UserAuthHelper, AuthUser"); + USERAUTH_HILOGI(MODULE_JS_NAPI, "UserAuthHelper, AuthUser"); return userAuthImpl->AuthUser(env, info); } @@ -191,7 +192,7 @@ napi_value CancelAuth(napi_env env, napi_callback_info info) NAPI_CALL(env, napi_get_cb_info(env, info, &argcAsync, args, &thisVar, nullptr)); UserAuthImpl *userAuthImpl = nullptr; NAPI_CALL(env, napi_unwrap(env, thisVar, (void **)&userAuthImpl)); - HILOG_INFO("UserAuthHelper, CancelAuth"); + USERAUTH_HILOGI(MODULE_JS_NAPI, "UserAuthHelper, CancelAuth"); return userAuthImpl->CancelAuth(env, info); } @@ -203,6 +204,7 @@ napi_value CancelAuth(napi_env env, napi_callback_info info) */ void Init(napi_env env, napi_value exports) { + USERAUTH_HILOGI(MODULE_JS_NAPI, "%{public}s, start.", __func__); napi_status status; napi_property_descriptor exportFuncs[] = { DECLARE_NAPI_FUNCTION("constructor", UserAuth::Constructor), @@ -210,12 +212,13 @@ void Init(napi_env env, napi_value exports) }; status = napi_define_properties(env, exports, sizeof(exportFuncs) / sizeof(*exportFuncs), exportFuncs); if (status != napi_ok) { - HILOG_ERROR("napi_define_properties faild"); + USERAUTH_HILOGE(MODULE_JS_NAPI, "napi_define_properties faild"); } } napi_value Constructor(napi_env env, napi_callback_info info) { + USERAUTH_HILOGI(MODULE_JS_NAPI, "%{public}s, start.", __func__); napi_value thisVar = nullptr; napi_value userAuth = nullptr; NAPI_CALL(env, napi_new_instance(env, GetCtor(env), 0, nullptr, &userAuth)); @@ -225,6 +228,7 @@ napi_value Constructor(napi_env env, napi_callback_info info) napi_value GetCtor(napi_env env) { + USERAUTH_HILOGI(MODULE_JS_NAPI, "%{public}s, start.", __func__); napi_value cons = nullptr; napi_property_descriptor clzDes[] = { DECLARE_NAPI_FUNCTION("getVersion", UserAuth::GetVersion), diff --git a/interfaces/innerkits/napi/src/user_auth_impl.cpp b/interfaces/innerkits/napi/src/user_auth_impl.cpp index 06e504a47..a13b803bd 100755 --- a/interfaces/innerkits/napi/src/user_auth_impl.cpp +++ b/interfaces/innerkits/napi/src/user_auth_impl.cpp @@ -13,6 +13,8 @@ * limitations under the License. */ +#include + #include "user_auth_impl.h" #include @@ -20,9 +22,9 @@ #include "user_auth.h" #include "userauth_callback.h" #include "userauth_info.h" - -#include "auth_hilog_wrapper.h" +#include "userauth_hilog_wrapper.h" #include "authapi_callback.h" +#include "user_auth_helper.h" namespace OHOS { namespace UserIAM { @@ -38,7 +40,7 @@ UserAuthImpl::~UserAuthImpl() napi_value UserAuthImpl::GetVersion(napi_env env, napi_callback_info info) { int32_t result = UserAuth::GetInstance().GetVersion(); - HILOG_INFO("GetVersion result = %{public}d ", result); + USERAUTH_HILOGI(MODULE_JS_NAPI, "GetVersion result = %{public}d", result); napi_value version = 0; NAPI_CALL(env, napi_create_int32(env, result, &version)); return version; @@ -50,23 +52,23 @@ napi_value UserAuthImpl::GetAvailableStatus(napi_env env, napi_callback_info inf size_t argc = ARGS_MAX_COUNT; NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr)); if (argc != ARGS_TWO) { - HILOG_ERROR("%{public}s, parms error.", __func__); + USERAUTH_HILOGE(MODULE_JS_NAPI, "%{public}s, parms error.", __func__); return nullptr; } int type = authBuild.NapiGetValueInt(env, argv[PARAM0]); if (type == GET_VALUE_ERROR) { - HILOG_ERROR("%{public}s, argv[PARAM0] error.", __func__); + USERAUTH_HILOGE(MODULE_JS_NAPI, "%{public}s, argv[PARAM0] error.", __func__); return nullptr; } int level = authBuild.NapiGetValueInt(env, argv[PARAM1]); if (level == GET_VALUE_ERROR) { - HILOG_ERROR("%{public}s, argv[PARAM1] error.", __func__); + USERAUTH_HILOGE(MODULE_JS_NAPI, "%{public}s, argv[PARAM1] error.", __func__); return nullptr; } AuthType authType = AuthType(type); AuthTurstLevel authTurstLevel = AuthTurstLevel(level); int32_t result = UserAuth::GetInstance().GetAvailableStatus(authType, authTurstLevel); - HILOG_INFO("GetAvailableStatus result = %{public}d", result); + USERAUTH_HILOGI(MODULE_JS_NAPI, "GetAvailabeStatus result = %{public}d", result); napi_value ret = 0; NAPI_CALL(env, napi_create_int32(env, result, &ret)); return ret; @@ -76,20 +78,20 @@ napi_value UserAuthImpl::GetProperty(napi_env env, napi_callback_info info) { AsyncHolder *asyncHolder = new (std::nothrow) AsyncHolder(); if (asyncHolder == nullptr) { - HILOG_ERROR("%{public}s asyncHolder nullptr", __func__); + USERAUTH_HILOGE(MODULE_JS_NAPI, "%{public}s asyncHolder nullptr", __func__); return nullptr; } GetPropertyInfo *getPropertyInfo = new (std::nothrow) GetPropertyInfo(); if (getPropertyInfo == nullptr) { delete asyncHolder; - HILOG_ERROR("%{public}s getPropertyInfo nullptr", __func__); + USERAUTH_HILOGE(MODULE_JS_NAPI, "%{public}s getPropertyInfo nullptr", __func__); return nullptr; } getPropertyInfo->callBackInfo.env = env; asyncHolder->data = getPropertyInfo; napi_value ret = GetPropertyWrap(env, info, asyncHolder); if (ret == nullptr) { - HILOG_ERROR("%{public}s GetPropertyWrap fail", __func__); + USERAUTH_HILOGE(MODULE_JS_NAPI, "%{public}s GetPropertyWrap fail", __func__); delete getPropertyInfo; delete asyncHolder; if (asyncHolder->asyncWork != nullptr) { @@ -101,7 +103,7 @@ napi_value UserAuthImpl::GetProperty(napi_env env, napi_callback_info info) napi_value UserAuthImpl::GetPropertyWrap(napi_env env, napi_callback_info info, AsyncHolder *asyncHolder) { - HILOG_INFO("%{public}s, called", __func__); + USERAUTH_HILOGI(MODULE_JS_NAPI, "%{public}s, called", __func__); GetPropertyInfo *getPropertyInfo = reinterpret_cast(asyncHolder->data); size_t argcAsync = ARGS_TWO; const size_t argcPromise = ARGS_ONE; @@ -109,7 +111,7 @@ napi_value UserAuthImpl::GetPropertyWrap(napi_env env, napi_callback_info info, napi_value args[ARGS_MAX_COUNT] = {nullptr}; NAPI_CALL(env, napi_get_cb_info(env, info, &argcAsync, args, nullptr, nullptr)); if (argcAsync > argCountWithAsync || argcAsync > ARGS_MAX_COUNT) { - HILOG_ERROR("%{public}s, Wrong argument count.", __func__); + USERAUTH_HILOGE(MODULE_JS_NAPI, "%{public}s, Wrong argument count.", __func__); return nullptr; } if (argcAsync > PARAM1) { @@ -130,21 +132,21 @@ napi_value UserAuthImpl::GetPropertyWrap(napi_env env, napi_callback_info info, } else { ret = GetPropertyPromise(env, asyncHolder); } - HILOG_INFO("%{public}s,end.", __func__); + USERAUTH_HILOGI(MODULE_JS_NAPI, "%{public}s,end.", __func__); return ret; } void UserAuthImpl::GetPropertyExecute(napi_env env, void *data) { - HILOG_INFO("GetPropertyExecute, worker pool thread execute."); + USERAUTH_HILOGI(MODULE_JS_NAPI, "GetPropertyExecute, worker pool thread execute."); AsyncHolder *asyncHolder = reinterpret_cast(data); if (asyncHolder == nullptr) { - HILOG_ERROR("GetPropertyExecute, asyncHolder == nullptr"); + USERAUTH_HILOGE(MODULE_JS_NAPI, "GetPropertyExecute, asyncHolder == nullptr"); return; } GetPropertyInfo *getPropertyInfo = reinterpret_cast(asyncHolder->data); if (getPropertyInfo == nullptr) { - HILOG_ERROR("GetPropertyExecute, getPropertyInfo == nullptr"); + USERAUTH_HILOGE(MODULE_JS_NAPI, "GetPropertyExecute, getPropertyInfo == nullptr"); return; } AuthType authTypeGet = AuthType(getPropertyInfo->authType); @@ -152,35 +154,35 @@ void UserAuthImpl::GetPropertyExecute(napi_env env, void *data) GetPropertyRequest request; request.authType = authTypeGet; request.keys = getPropertyInfo->keys; - HILOG_INFO("GetPropertyExecute start 1"); + USERAUTH_HILOGI(MODULE_JS_NAPI, "GetPropertyExecute start 1"); GetPropApiCallback *object = new GetPropApiCallback(getPropertyInfo); std::shared_ptr callback; callback.reset(object); UserAuth::GetInstance().GetProperty(request, callback); - HILOG_INFO("GetPropertyExecute, worker pool thread execute end."); + USERAUTH_HILOGI(MODULE_JS_NAPI, "GetPropertyExecute, worker pool thread execute end."); } void UserAuthImpl::GetPropertyPromiseExecuteDone(napi_env env, napi_status status, void *data) { - HILOG_INFO("GetPropertyPromiseExecuteDone, start"); + USERAUTH_HILOGI(MODULE_JS_NAPI, "GetPropertyPromiseExecuteDone, start"); AsyncHolder *asyncHolder = reinterpret_cast(data); napi_delete_async_work(env, asyncHolder->asyncWork); delete asyncHolder; - HILOG_INFO("GetPropertyPromiseExecuteDone, end"); + USERAUTH_HILOGI(MODULE_JS_NAPI, "GetPropertyPromiseExecuteDone, end"); } void UserAuthImpl::GetPropertyAsyncExecuteDone(napi_env env, napi_status status, void *data) { - HILOG_INFO("GetPropertyAsyncExecuteDone, start"); + USERAUTH_HILOGI(MODULE_JS_NAPI, "GetPropertyAsyncExecuteDone, start"); AsyncHolder *asyncHolder = reinterpret_cast(data); napi_delete_async_work(env, asyncHolder->asyncWork); delete asyncHolder; - HILOG_INFO("GetPropertyAsyncExecuteDone, end"); + USERAUTH_HILOGI(MODULE_JS_NAPI, "GetPropertyAsyncExecuteDone, end"); } napi_value UserAuthImpl::GetPropertyAsync(napi_env env, AsyncHolder *asyncHolder) { - HILOG_INFO("%{public}s, asyncCallback.", __func__); + USERAUTH_HILOGI(MODULE_JS_NAPI, "%{public}s, asyncCallback.", __func__); napi_value result = nullptr; NAPI_CALL(env, napi_get_null(env, &result)); napi_value resourceName = nullptr; @@ -188,13 +190,13 @@ napi_value UserAuthImpl::GetPropertyAsync(napi_env env, AsyncHolder *asyncHolder NAPI_CALL(env, napi_create_async_work(env, nullptr, resourceName, GetPropertyExecute, GetPropertyAsyncExecuteDone, (void *)asyncHolder, &asyncHolder->asyncWork)); NAPI_CALL(env, napi_queue_async_work(env, asyncHolder->asyncWork)); - HILOG_INFO("%{public}s, asyncCallback end.", __func__); + USERAUTH_HILOGI(MODULE_JS_NAPI, "%{public}s, asyncCallback end.", __func__); return result; } napi_value UserAuthImpl::GetPropertyPromise(napi_env env, AsyncHolder *asyncHolder) { - HILOG_INFO("%{public}s, promise.", __func__); + USERAUTH_HILOGI(MODULE_JS_NAPI, "%{public}s, promise.", __func__); GetPropertyInfo *getPropertyInfo = reinterpret_cast(asyncHolder->data); napi_value resourceName = 0; NAPI_CALL(env, napi_create_string_latin1(env, __func__, NAPI_AUTO_LENGTH, &resourceName)); @@ -206,7 +208,7 @@ napi_value UserAuthImpl::GetPropertyPromise(napi_env env, AsyncHolder *asyncHold NAPI_CALL(env, napi_create_async_work(env, nullptr, resourceName, GetPropertyExecute, GetPropertyPromiseExecuteDone, (void *)asyncHolder, &asyncHolder->asyncWork)); NAPI_CALL(env, napi_queue_async_work(env, asyncHolder->asyncWork)); - HILOG_INFO("%{public}s, promise end.", __func__); + USERAUTH_HILOGI(MODULE_JS_NAPI, "%{public}s, promise end.", __func__); return promise; } @@ -214,20 +216,20 @@ napi_value UserAuthImpl::SetProperty(napi_env env, napi_callback_info info) { AsyncHolder *asyncHolder = new (std::nothrow) AsyncHolder(); if (asyncHolder == nullptr) { - HILOG_ERROR("%{public}s asyncHolder nullptr", __func__); + USERAUTH_HILOGE(MODULE_JS_NAPI, "%{public}s asyncHolder nullptr", __func__); return nullptr; } SetPropertyInfo *setPropertyInfo = new (std::nothrow) SetPropertyInfo(); if (setPropertyInfo == nullptr) { delete asyncHolder; - HILOG_ERROR("%{public}s setPropertyInfo nullptr", __func__); + USERAUTH_HILOGE(MODULE_JS_NAPI, "%{public}s setPropertyInfo nullptr", __func__); return nullptr; } setPropertyInfo->callBackInfo.env = env; asyncHolder->data = setPropertyInfo; napi_value ret = SetPropertyWrap(env, info, asyncHolder); if (ret == nullptr) { - HILOG_ERROR("%{public}s SetPropertyWrap fail", __func__); + USERAUTH_HILOGE(MODULE_JS_NAPI, "%{public}s SetPropertyWrap fail", __func__); delete setPropertyInfo; delete asyncHolder; if (asyncHolder->asyncWork != nullptr) { @@ -239,7 +241,7 @@ napi_value UserAuthImpl::SetProperty(napi_env env, napi_callback_info info) napi_value UserAuthImpl::SetPropertyWrap(napi_env env, napi_callback_info info, AsyncHolder *asyncHolder) { - HILOG_INFO("%{public}s, called", __func__); + USERAUTH_HILOGI(MODULE_JS_NAPI, "%{public}s, called", __func__); SetPropertyInfo *setPropertyInfo = reinterpret_cast(asyncHolder->data); size_t argcAsync = ARGS_TWO; const size_t argcPromise = ARGS_ONE; @@ -247,7 +249,7 @@ napi_value UserAuthImpl::SetPropertyWrap(napi_env env, napi_callback_info info, napi_value args[ARGS_MAX_COUNT] = {nullptr}; NAPI_CALL(env, napi_get_cb_info(env, info, &argcAsync, args, nullptr, nullptr)); if (argcAsync > argCountWithAsync || argcAsync > ARGS_MAX_COUNT) { - HILOG_ERROR("%{public}s, Wrong argument count.", __func__); + USERAUTH_HILOGE(MODULE_JS_NAPI, "%{public}s, Wrong argument count.", __func__); return nullptr; } if (argcAsync > PARAM1) { @@ -271,21 +273,21 @@ napi_value UserAuthImpl::SetPropertyWrap(napi_env env, napi_callback_info info, } else { ret = SetPropertyPromise(env, asyncHolder); } - HILOG_INFO("%{public}s,end.", __func__); + USERAUTH_HILOGI(MODULE_JS_NAPI, "%{public}s,end.", __func__); return ret; } void UserAuthImpl::SetPropertyExecute(napi_env env, void *data) { - HILOG_INFO("setPropertyExecute, worker pool thread execute."); + USERAUTH_HILOGI(MODULE_JS_NAPI, "setPropertyExecute, worker pool thread execute."); AsyncHolder *asyncHolder = reinterpret_cast(data); if (asyncHolder == nullptr) { - HILOG_ERROR("SetPropertyExecute, asyncHolder == nullptr"); + USERAUTH_HILOGE(MODULE_JS_NAPI, "SetPropertyExecute, asyncHolder == nullptr"); return; } SetPropertyInfo *setPropertyInfo = reinterpret_cast(asyncHolder->data); if (setPropertyInfo == nullptr) { - HILOG_ERROR("SetPropertyExecute, setPropertyInfo == nullptr"); + USERAUTH_HILOGE(MODULE_JS_NAPI, "SetPropertyExecute, setPropertyInfo == nullptr"); return; } AuthType authTypeGet = AuthType(setPropertyInfo->authType); @@ -297,30 +299,30 @@ void UserAuthImpl::SetPropertyExecute(napi_env env, void *data) std::shared_ptr callback; callback.reset(object); UserAuth::GetInstance().SetProperty(request, callback); - HILOG_INFO("setPropertyExecute, worker pool thread execute end."); + USERAUTH_HILOGI(MODULE_JS_NAPI, "setPropertyExecute, worker pool thread execute end."); } void UserAuthImpl::SetPropertyPromiseExecuteDone(napi_env env, napi_status status, void *data) { - HILOG_INFO("SetPropertyPromiseExecuteDone, start"); + USERAUTH_HILOGI(MODULE_JS_NAPI, "SetPropertyPromiseExecuteDone, start"); AsyncHolder *asyncHolder = reinterpret_cast(data); napi_delete_async_work(env, asyncHolder->asyncWork); delete asyncHolder; - HILOG_INFO("SetPropertyPromiseExecuteDone, end"); + USERAUTH_HILOGI(MODULE_JS_NAPI, "SetPropertyPromiseExecuteDone, end"); } void UserAuthImpl::SetPropertyAsyncExecuteDone(napi_env env, napi_status status, void *data) { - HILOG_INFO("SetPropertyAsyncExecuteDone, start"); + USERAUTH_HILOGI(MODULE_JS_NAPI, "SetPropertyAsyncExecuteDone, start"); AsyncHolder *asyncHolder = reinterpret_cast(data); napi_delete_async_work(env, asyncHolder->asyncWork); delete asyncHolder; - HILOG_INFO("SetPropertyAsyncExecuteDone, end"); + USERAUTH_HILOGI(MODULE_JS_NAPI, "SetPropertyAsyncExecuteDone, end"); } napi_value UserAuthImpl::SetPropertyAsync(napi_env env, AsyncHolder *asyncHolder) { - HILOG_INFO("%{public}s, asyncCallback.", __func__); + USERAUTH_HILOGI(MODULE_JS_NAPI, "%{public}s, asyncCallback.", __func__); napi_value result = nullptr; NAPI_CALL(env, napi_get_null(env, &result)); napi_value resourceName = nullptr; @@ -328,13 +330,13 @@ napi_value UserAuthImpl::SetPropertyAsync(napi_env env, AsyncHolder *asyncHolder NAPI_CALL(env, napi_create_async_work(env, nullptr, resourceName, SetPropertyExecute, SetPropertyAsyncExecuteDone, (void *)asyncHolder, &asyncHolder->asyncWork)); NAPI_CALL(env, napi_queue_async_work(env, asyncHolder->asyncWork)); - HILOG_INFO("%{public}s, asyncCallback end.", __func__); + USERAUTH_HILOGI(MODULE_JS_NAPI, "%{public}s, asyncCallback end.", __func__); return result; } napi_value UserAuthImpl::SetPropertyPromise(napi_env env, AsyncHolder *asyncHolder) { - HILOG_INFO("%{public}s, promise.", __func__); + USERAUTH_HILOGI(MODULE_JS_NAPI, "%{public}s, promise.", __func__); SetPropertyInfo *setPropertyInfo = reinterpret_cast(asyncHolder->data); napi_value resourceName = 0; NAPI_CALL(env, napi_create_string_latin1(env, __func__, NAPI_AUTO_LENGTH, &resourceName)); @@ -346,7 +348,7 @@ napi_value UserAuthImpl::SetPropertyPromise(napi_env env, AsyncHolder *asyncHold NAPI_CALL(env, napi_create_async_work(env, nullptr, resourceName, SetPropertyExecute, SetPropertyPromiseExecuteDone, (void *)asyncHolder, &asyncHolder->asyncWork)); NAPI_CALL(env, napi_queue_async_work(env, asyncHolder->asyncWork)); - HILOG_INFO("%{public}s, promise end.", __func__); + USERAUTH_HILOGI(MODULE_JS_NAPI, "%{public}s, promise end.", __func__); return promise; } @@ -359,7 +361,7 @@ napi_value UserAuthImpl::BuildAuthInfo(napi_env env, AuthInfo *authInfo) napi_value argv[ARGS_MAX_COUNT] = {nullptr}; NAPI_CALL(env, napi_get_cb_info(env, authInfo->info, &argc, argv, nullptr, nullptr)); if (argc != ARGS_FOUR) { - HILOG_ERROR("%{public}s, parms error.", __func__); + USERAUTH_HILOGE(MODULE_JS_NAPI, "%{public}s, parms error.", __func__); return nullptr; } authInfo->challenge = authBuild.GetUint8ArrayTo64(env, argv[0]); @@ -402,7 +404,7 @@ napi_value UserAuthImpl::DoExecute(ExecuteInfo* executeInfo) { "S4", ATL4 }, }; if (convertAuthTurstLevel.count(executeInfo->level) == 0) { - HILOG_ERROR("execute convertAuthTurstLevel is 0"); + USERAUTH_HILOGE(MODULE_JS_NAPI, "execute convertAuthTurstLevel is 0"); delete executeInfo; return nullptr; } @@ -418,10 +420,10 @@ napi_value UserAuthImpl::DoExecute(ExecuteInfo* executeInfo) napi_value UserAuthImpl::Execute(napi_env env, napi_callback_info info) { - HILOG_INFO("%{public}s, start", __func__); + USERAUTH_HILOGI(MODULE_JS_NAPI, "%{public}s, start", __func__); ExecuteInfo *executeInfo = new (std::nothrow) ExecuteInfo(); if (executeInfo == nullptr) { - HILOG_ERROR("%{public}s executeInfo nullptr", __func__); + USERAUTH_HILOGE(MODULE_JS_NAPI, "%{public}s executeInfo nullptr", __func__); return nullptr; } executeInfo->env = env; @@ -430,12 +432,12 @@ napi_value UserAuthImpl::Execute(napi_env env, napi_callback_info info) napi_value argv[ARGS_MAX_COUNT] = {nullptr}; NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr)); if (argc < PARAM2) { - HILOG_ERROR("%{public}s argc check fail", __func__); + USERAUTH_HILOGE(MODULE_JS_NAPI, "%{public}s argc check fail", __func__); delete executeInfo; return nullptr; } if (!GetExecuteInfo(env, argv, executeInfo)) { - HILOG_ERROR("%{public}s GetExecuteInfo fail", __func__); + USERAUTH_HILOGE(MODULE_JS_NAPI, "%{public}s GetExecuteInfo fail", __func__); delete executeInfo; return nullptr; } @@ -454,7 +456,7 @@ napi_value UserAuthImpl::Execute(napi_env env, napi_callback_info info) bool UserAuthImpl::GetExecuteInfo(napi_env env, napi_value* argv, ExecuteInfo* executeInfo) { - HILOG_INFO("%{public}s, start.", __func__); + USERAUTH_HILOGI(MODULE_JS_NAPI, "%{public}s, start.", __func__); napi_valuetype valuetype; napi_typeof(env, argv[PARAM0], &valuetype); if (valuetype != napi_string) { @@ -481,7 +483,7 @@ bool UserAuthImpl::GetExecuteInfo(napi_env env, napi_value* argv, ExecuteInfo* e delete[] str; } if (executeInfo->type.compare("FACE_ONLY") != 0) { - HILOG_ERROR("%{public}s check type fail.", __func__); + USERAUTH_HILOGE(MODULE_JS_NAPI, "%{public}s check type fail.", __func__); return false; } return true; @@ -489,16 +491,16 @@ bool UserAuthImpl::GetExecuteInfo(napi_env env, napi_value* argv, ExecuteInfo* e napi_value UserAuthImpl::Auth(napi_env env, napi_callback_info info) { - HILOG_INFO("%{public}s, start", __func__); + USERAUTH_HILOGI(MODULE_JS_NAPI, "%{public}s, start", __func__); AuthInfo *authInfo = new (std::nothrow) AuthInfo(); if (authInfo == nullptr) { - HILOG_INFO("%{public}s authInfo nullptr", __func__); + USERAUTH_HILOGI(MODULE_JS_NAPI, "%{public}s authInfo nullptr", __func__); return nullptr; } authInfo->info = info; napi_value ret = BuildAuthInfo(env, authInfo); if (ret == nullptr) { - HILOG_INFO("%{public}s BuildAuthInfo fail", __func__); + USERAUTH_HILOGI(MODULE_JS_NAPI, "%{public}s BuildAuthInfo fail", __func__); delete authInfo; return ret; } @@ -507,31 +509,31 @@ napi_value UserAuthImpl::Auth(napi_env env, napi_callback_info info) napi_value UserAuthImpl::AuthWrap(napi_env env, AuthInfo *authInfo) { - HILOG_INFO("%{public}s, start.", __func__); + USERAUTH_HILOGI(MODULE_JS_NAPI, "%{public}s, start.", __func__); AuthApiCallback *object = new AuthApiCallback(authInfo); std::shared_ptr callback; callback.reset(object); uint64_t result = UserAuth::GetInstance().Auth( authInfo->challenge, AuthType(authInfo->authType), AuthTurstLevel(authInfo->authTrustLevel), callback); - HILOG_INFO("UserAuth::GetInstance().Auth.result = %{public}llu", result); + USERAUTH_HILOGI(MODULE_JS_NAPI, "UserAuth::GetInstance().Auth.result = %{public}" PRIu64 "", result); napi_value key = authBuild.Uint64ToUint8Array(env, result); - HILOG_INFO("%{public}s, end.", __func__); + USERAUTH_HILOGI(MODULE_JS_NAPI, "%{public}s, end.", __func__); return key; } napi_value UserAuthImpl::AuthUser(napi_env env, napi_callback_info info) { - HILOG_INFO("%{public}s, start.", __func__); + USERAUTH_HILOGI(MODULE_JS_NAPI, "%{public}s, start.", __func__); AuthUserInfo *userInfo = new (std::nothrow) AuthUserInfo(); if (userInfo == nullptr) { - HILOG_INFO("%{public}s userInfo nullptr", __func__); + USERAUTH_HILOGI(MODULE_JS_NAPI, "%{public}s userInfo nullptr", __func__); return nullptr; } userInfo->callBackInfo.env = env; userInfo->info = info; napi_value ret = BuildAuthUserInfo(env, userInfo); if (ret == nullptr) { - HILOG_INFO("%{public}s BuildAuthUserInfo fail", __func__); + USERAUTH_HILOGI(MODULE_JS_NAPI, "%{public}s BuildAuthUserInfo fail", __func__); delete userInfo; return ret; } @@ -546,7 +548,7 @@ napi_value UserAuthImpl::BuildAuthUserInfo(napi_env env, AuthUserInfo *userInfo) napi_value argv[ARGS_MAX_COUNT] = {nullptr}; NAPI_CALL(env, napi_get_cb_info(env, userInfo->info, &argc, argv, nullptr, nullptr)); if (argc != ARGS_FIVE) { - HILOG_ERROR("%{public}s, parms error.", __func__); + USERAUTH_HILOGE(MODULE_JS_NAPI, "%{public}s, parms error.", __func__); return nullptr; } if (authBuild.NapiTypeNumber(env, argv[PARAM0])) { @@ -566,7 +568,7 @@ napi_value UserAuthImpl::BuildAuthUserInfo(napi_env env, AuthUserInfo *userInfo) userInfo->authTrustLevel = level; } if (authBuild.NapiTypeObject(env, argv[PARAM4])) { - HILOG_INFO("AuthUser is Object"); + USERAUTH_HILOGI(MODULE_JS_NAPI, "AuthUser is Object"); userInfo->jsFunction = argv[PARAM4]; NAPI_CALL(env, napi_get_named_property(env, argv[PARAM4], "onResult", &userInfo->onResultCallBack)); NAPI_CALL(env, napi_create_reference(env, userInfo->onResultCallBack, PARAM1, &userInfo->onResult)); @@ -578,15 +580,15 @@ napi_value UserAuthImpl::BuildAuthUserInfo(napi_env env, AuthUserInfo *userInfo) napi_value UserAuthImpl::AuthUserWrap(napi_env env, AuthUserInfo *userInfo) { - HILOG_INFO("%{public}s, start.", __func__); + USERAUTH_HILOGI(MODULE_JS_NAPI, "%{public}s, start.", __func__); AuthApiCallback *object = new AuthApiCallback(userInfo); std::shared_ptr callback; callback.reset(object); uint64_t result = UserAuth::GetInstance().AuthUser(userInfo->userId, userInfo->challenge, AuthType(userInfo->authType), AuthTurstLevel(userInfo->authTrustLevel), callback); - HILOG_INFO("UserAuth::GetInstance().AuthUser. result = %{public}llu", result); + USERAUTH_HILOGI(MODULE_JS_NAPI, "UserAuth::GetInstance().AuthUser. result = %{public}" PRIu64 "", result); napi_value key = authBuild.Uint64ToUint8Array(env, result); - HILOG_INFO("%{public}s, end.", __func__); + USERAUTH_HILOGI(MODULE_JS_NAPI, "%{public}s, end.", __func__); return key; } @@ -597,16 +599,35 @@ napi_value UserAuthImpl::CancelAuth(napi_env env, napi_callback_info info) NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr)); uint64_t contextId = authBuild.GetUint8ArrayTo64(env, argv[0]); - HILOG_INFO("CancelAuth contextId = %{public}llu", contextId); + USERAUTH_HILOGI(MODULE_JS_NAPI, "CancelAuth contextId = %{public}" PRIu64 "", contextId); if (contextId == 0) { return nullptr; } int32_t result = UserAuth::GetInstance().CancelAuth(contextId); - HILOG_INFO("CancelAuth result = %{public}d", result); + USERAUTH_HILOGI(MODULE_JS_NAPI, "CancelAuth result = %{public}d", result); napi_value key = 0; NAPI_CALL(env, napi_create_int32(env, result, &key)); return key; } + +static napi_value ModuleInit(napi_env env, napi_value exports) +{ + OHOS::UserIAM::UserAuth::Init(env, exports); + return exports; +} +extern "C" __attribute__((constructor)) void RegisterModule(void) +{ + napi_module module = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = ModuleInit, + .nm_modname = "UserAuth", + .nm_priv = nullptr, + .reserved = {} + }; + napi_module_register(&module); +} } // namespace UserAuth } // namespace UserIAM } // namespace OHOS diff --git a/interfaces/kits/napi/BUILD.gn b/interfaces/kits/napi/BUILD.gn index a84551cd3..777be8efe 100755 --- a/interfaces/kits/napi/BUILD.gn +++ b/interfaces/kits/napi/BUILD.gn @@ -24,7 +24,6 @@ config("userauth_public_config") { ohos_shared_library("userauthnorth") { sources = [ - "src/auth_native_module.cpp", "src/user_auth_helper_north.cpp", ] @@ -36,6 +35,7 @@ ohos_shared_library("userauthnorth") { "//foundation/ace/napi:ace_napi", ] + configs = [ "${userauth_utils_path}:utils_config" ] public_configs = [ ":userauth_public_config" ] external_deps = [ "ipc:ipc_core" ] @@ -48,5 +48,5 @@ ohos_shared_library("userauthnorth") { public_deps = [] relative_install_dir = "module" part_name = "user_auth" - subsystem_name = "useriam" + subsystem_name = "user_iam" } diff --git a/interfaces/kits/napi/include/user_auth_helper_north.h b/interfaces/kits/napi/include/user_auth_helper_north.h index c6434c206..4f203d767 100755 --- a/interfaces/kits/napi/include/user_auth_helper_north.h +++ b/interfaces/kits/napi/include/user_auth_helper_north.h @@ -17,6 +17,7 @@ #include "napi/native_api.h" #include "napi/native_common.h" +#include "napi/native_node_api.h" namespace OHOS { namespace UserAuthNorth { diff --git a/interfaces/kits/napi/src/auth_native_module.cpp b/interfaces/kits/napi/src/auth_native_module.cpp deleted file mode 100755 index b826a2a11..000000000 --- a/interfaces/kits/napi/src/auth_native_module.cpp +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2021 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. - */ - -#include - -#include "user_auth_helper_north.h" - -namespace OHOS { -namespace UserAuthNorth { -static napi_value ModuleInit(napi_env env, napi_value exports) -{ - OHOS::UserAuthNorth::Init(env, exports); - return exports; -} -extern "C" __attribute__((constructor)) void RegisterModule(void) -{ - napi_module module = { - .nm_version = 1, // NAPI v1 - .nm_flags = 0, // normal - .nm_filename = nullptr, - .nm_register_func = ModuleInit, - .nm_modname = "UserAuthNorth", - .nm_priv = nullptr, - .reserved = {} - }; - napi_module_register(&module); -} -} // namespace UserAuthNorth -} // namespace OHOS diff --git a/interfaces/kits/napi/src/user_auth_helper_north.cpp b/interfaces/kits/napi/src/user_auth_helper_north.cpp index 3ccc72517..ed0a34fe7 100755 --- a/interfaces/kits/napi/src/user_auth_helper_north.cpp +++ b/interfaces/kits/napi/src/user_auth_helper_north.cpp @@ -15,10 +15,11 @@ #include "user_auth_helper_north.h" -#include "auth_hilog_wrapper.h" #include "user_auth_impl.h" #include "user_auth_helper.h" +#include "userauth_hilog_wrapper.h" +using namespace OHOS::UserIAM::UserAuth; namespace OHOS { namespace UserAuthNorth { napi_value Constructor(napi_env env, napi_callback_info info) @@ -27,7 +28,7 @@ napi_value Constructor(napi_env env, napi_callback_info info) napi_value userAuth = nullptr; NAPI_CALL(env, napi_new_instance(env, GetCtor(env), 0, nullptr, &userAuth)); NAPI_CALL(env, napi_get_cb_info(env, info, nullptr, nullptr, &thisVar, nullptr)); - HILOG_INFO("UserAuthNorth, Constructor start"); + USERAUTH_HILOGI(MODULE_JS_NAPI, "UserAuthNorth, Constructor start"); return userAuth; } @@ -53,8 +54,27 @@ void Init(napi_env env, napi_value exports) }; status = napi_define_properties(env, exports, sizeof(exportFuncs) / sizeof(*exportFuncs), exportFuncs); if (status != napi_ok) { - HILOG_ERROR("napi_define_properties faild"); + USERAUTH_HILOGE(MODULE_JS_NAPI, "napi_define_properties faild"); } } + +static napi_value ModuleInit(napi_env env, napi_value exports) +{ + OHOS::UserAuthNorth::Init(env, exports); + return exports; +} +extern "C" __attribute__((constructor)) void RegisterModule(void) +{ + napi_module module = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = ModuleInit, + .nm_modname = "UserAuthNorth", + .nm_priv = nullptr, + .reserved = {} + }; + napi_module_register(&module); +} } // namespace UserAuthNorth } // namespace OHOS \ No newline at end of file diff --git a/services/src/userauth_adapter.cpp b/services/src/userauth_adapter.cpp index f6a412183..d3847843b 100644 --- a/services/src/userauth_adapter.cpp +++ b/services/src/userauth_adapter.cpp @@ -12,8 +12,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include +#include +#include "userauth_adapter.h" #include "userauth_hilog_wrapper.h" #include "userauth_info.h" #include "auth_attributes.h" @@ -22,7 +23,6 @@ #include "useridm_info.h" #include "userauth_datamgr.h" #include "userauth_excallback_impl.h" -#include "userauth_adapter.h" namespace OHOS { namespace UserIAM { diff --git a/services/src/userauth_excallback_impl.cpp b/services/src/userauth_excallback_impl.cpp index 39c267202..26556452f 100644 --- a/services/src/userauth_excallback_impl.cpp +++ b/services/src/userauth_excallback_impl.cpp @@ -20,7 +20,7 @@ #include "userauth_async_proxy.h" #include "securec.h" -#include +#include #include #include @@ -184,6 +184,7 @@ void UserAuthCallbackImplCoAuth::OnFinishHandle(uint32_t resultCode, std::vector } int32_t ret = UserAuthAdapter::GetInstance().RequestAuthResult(callbackContextID_, scheduleToken, authToken, sessionIds); + USERAUTH_HILOGD(MODULE_SERVICE, "RequestAuthResult ret:%{public}d", ret); if (ret == E_RET_UNDONE) { if (callbackNowCount_ == callbackCount_) { USERAUTH_HILOGD(MODULE_SERVICE, "UserAuthCallbackImplCoAuth E_RET_UNDONE"); diff --git a/services/src/userauth_service.cpp b/services/src/userauth_service.cpp index 8d0fad5b3..c584614f4 100644 --- a/services/src/userauth_service.cpp +++ b/services/src/userauth_service.cpp @@ -20,11 +20,10 @@ #include "accesstoken_kit.h" #include "userauth_service.h" +#define AUTHTURSTLEVEL_SYS 1 namespace OHOS { namespace UserIAM { namespace UserAuth { -const static int AUTHTURSTLEVEL_SYS = 1; - REGISTER_SYSTEM_ABILITY_BY_ID(UserAuthService, SUBSYS_USERIAM_SYS_ABILITY_USERAUTH, true); UserAuthService::UserAuthService(int32_t systemAbilityId, bool runOnCreate) diff --git a/utils/native/include/userauth_errors.h b/utils/native/include/userauth_errors.h deleted file mode 100644 index ebe2c4547..000000000 --- a/utils/native/include/userauth_errors.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2021 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. - */ - -#ifndef USERAUTH_ERRORS_H -#define USERAUTH_ERRORS_H - -#include - -namespace OHOS { -namespace UserIAM { -namespace UserAuth { -enum { - E_WRITE_PARCEL_ERROR = 0, - E_READ_PARCEL_ERROR, - E_GET_SYSTEM_ABILITY_MANAGER_FAILED, - E_GET_POWER_SERVICE_FAILED, - E_ADD_DEATH_RECIPIENT_FAILED, - E_INNER_ERR -}; -} // namespace UserAuth -} // namespace UserIam -} // namespace OHOS - -#endif // USERAUTH_ERRORS_H -- Gitee