remove patch

Signed-off-by: woohoa <wanghuan36@huawei.com>
This commit is contained in:
15950533375 2024-11-06 12:46:30 +08:00
parent 537f952a23
commit ba166a06a3

View File

@ -1,790 +0,0 @@
From e639d6628435d92067c75ff6473f42ca1a6e74c8 Mon Sep 17 00:00:00 2001
From: 15950533375 <wanghuan36@huawei.com>
Date: Wed, 6 Nov 2024 11:42:17 +0800
Subject: [PATCH] =?UTF-8?q?=E5=8E=BB=E6=8E=89napi?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: woohoa <wanghuan36@huawei.com>
---
BUILD.gn | 3 +-
.../kits/js/{app_domain_verify => }/BUILD.gn | 7 +-
interfaces/kits/js/deferred_link/BUILD.gn | 77 ------------
.../include/deferred_link_napi.h | 23 ----
.../deferred_link/src/deferred_link_napi.cpp | 116 ------------------
.../js/deferred_link/src/native_module.cpp | 44 -------
.../{event => }/include/api_event_reporter.h | 9 +-
.../include/app_domain_verify_manager_napi.h | 0
.../js/{event => }/include/config_parser.h | 0
.../js/napi_utils/include/napi_async_utils.h | 67 ----------
.../js/napi_utils/include/napi_value_utils.h | 30 -----
.../js/napi_utils/src/napi_async_utils.cpp | 33 -----
.../js/napi_utils/src/napi_value_utils.cpp | 60 ---------
.../js/{event => }/src/api_event_reporter.cpp | 9 --
.../src/app_domain_verify_manager_napi.cpp | 71 ++++++++---
.../kits/js/{event => }/src/config_parser.cpp | 0
.../src/native_module.cpp | 0
17 files changed, 61 insertions(+), 488 deletions(-)
rename interfaces/kits/js/{app_domain_verify => }/BUILD.gn (86%)
delete mode 100644 interfaces/kits/js/deferred_link/BUILD.gn
delete mode 100644 interfaces/kits/js/deferred_link/include/deferred_link_napi.h
delete mode 100644 interfaces/kits/js/deferred_link/src/deferred_link_napi.cpp
delete mode 100644 interfaces/kits/js/deferred_link/src/native_module.cpp
rename interfaces/kits/js/{event => }/include/api_event_reporter.h (84%)
rename interfaces/kits/js/{app_domain_verify => }/include/app_domain_verify_manager_napi.h (100%)
rename interfaces/kits/js/{event => }/include/config_parser.h (100%)
delete mode 100644 interfaces/kits/js/napi_utils/include/napi_async_utils.h
delete mode 100644 interfaces/kits/js/napi_utils/include/napi_value_utils.h
delete mode 100644 interfaces/kits/js/napi_utils/src/napi_async_utils.cpp
delete mode 100644 interfaces/kits/js/napi_utils/src/napi_value_utils.cpp
rename interfaces/kits/js/{event => }/src/api_event_reporter.cpp (95%)
rename interfaces/kits/js/{app_domain_verify => }/src/app_domain_verify_manager_napi.cpp (57%)
rename interfaces/kits/js/{event => }/src/config_parser.cpp (100%)
rename interfaces/kits/js/{app_domain_verify => }/src/native_module.cpp (100%)
diff --git a/BUILD.gn b/BUILD.gn
index 3b284ad..f6e0977 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -26,8 +26,7 @@ group("app_domain_verify_packages") {
"interfaces/inner_api/client:app_domain_verify_agent_client",
"interfaces/inner_api/client:app_domain_verify_mgr_client",
"interfaces/inner_api/common:app_domain_verify_common",
- "interfaces/kits/js/app_domain_verify:appdomainverify_napi",
- "interfaces/kits/js/deferred_link:deferredlink_napi",
+ "interfaces/kits/js:appdomainverify_napi",
"profile:bundlemanager_app_domain_verify_sa_profiles",
"services:app_domain_verify_agent_service",
"services:app_domain_verify_mgr_service",
diff --git a/interfaces/kits/js/app_domain_verify/BUILD.gn b/interfaces/kits/js/BUILD.gn
similarity index 86%
rename from interfaces/kits/js/app_domain_verify/BUILD.gn
rename to interfaces/kits/js/BUILD.gn
index 96246a8..00a186c 100644
--- a/interfaces/kits/js/app_domain_verify/BUILD.gn
+++ b/interfaces/kits/js/BUILD.gn
@@ -17,8 +17,6 @@ config("app_domain_verify_mgr_napi_config") {
visibility = [ ":*" ]
include_dirs = [
"include",
- "${app_domain_verify_kits_path}/event/include",
- "${app_domain_verify_kits_path}/napi_utils/include",
"${app_domain_verify_client_path}/include",
"${app_domain_verify_common_path}/include",
"${app_domain_verify_common_path}/include/zidl",
@@ -43,10 +41,9 @@ config("app_domain_verify_mgr_napi_config") {
ohos_shared_library("appdomainverify_napi") {
branch_protector_ret = "pac_ret"
sources = [
- "${app_domain_verify_kits_path}/event/src/api_event_reporter.cpp",
- "${app_domain_verify_kits_path}/event/src/config_parser.cpp",
- "${app_domain_verify_kits_path}/napi_utils/src/napi_value_utils.cpp",
+ "src/api_event_reporter.cpp",
"src/app_domain_verify_manager_napi.cpp",
+ "src/config_parser.cpp",
"src/native_module.cpp",
]
public_configs = [ ":app_domain_verify_mgr_napi_config" ]
diff --git a/interfaces/kits/js/deferred_link/BUILD.gn b/interfaces/kits/js/deferred_link/BUILD.gn
deleted file mode 100644
index 12d2573..0000000
--- a/interfaces/kits/js/deferred_link/BUILD.gn
+++ /dev/null
@@ -1,77 +0,0 @@
-# Copyright (C) 2024 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("//build/ohos.gni")
-import("//foundation/bundlemanager/app_domain_verify/app_domain_verify.gni")
-config("app_domain_verify_deferred_link_config") {
- visibility = [ ":*" ]
- include_dirs = [
- "include",
- "${app_domain_verify_kits_path}/event/include",
- "${app_domain_verify_kits_path}/napi_utils/include",
- "${app_domain_verify_client_path}/include",
- "${app_domain_verify_common_path}/include",
- "${app_domain_verify_common_path}/include/zidl",
- ]
- configs = [ "//build/config/compiler:exceptions" ]
- ldflags = [ "-Wl,--exclude-libs=ALL" ]
- cflags = [
- "-fvisibility=hidden",
- "-fdata-sections",
- "-ffunction-sections",
- "-fstack-protector-strong",
- "-D_FORTIFY_SOURCE=2",
- "-Os",
- ]
-
- cflags_cc = [
- "-fvisibility-inlines-hidden",
- "-Os",
- ]
-}
-
-ohos_shared_library("deferredlink_napi") {
- branch_protector_ret = "pac_ret"
- sources = [
- "${app_domain_verify_kits_path}/event/src/api_event_reporter.cpp",
- "${app_domain_verify_kits_path}/event/src/config_parser.cpp",
- "${app_domain_verify_kits_path}/napi_utils/src/napi_async_utils.cpp",
- "${app_domain_verify_kits_path}/napi_utils/src/napi_value_utils.cpp",
- "src/deferred_link_napi.cpp",
- "src/native_module.cpp",
- ]
- public_configs = [ ":app_domain_verify_deferred_link_config" ]
- deps = [
- "${app_domain_verify_client_path}:app_domain_verify_mgr_client",
- "${app_domain_verify_common_path}:app_domain_verify_common",
- ]
- external_deps = [
- "ability_base:want",
- "bundle_framework:appexecfwk_base",
- "c_utils:utils",
- "hiappevent:hiappevent_innerapi",
- "hilog:libhilog",
- "ipc:ipc_core",
- "napi:ace_napi",
- "safwk:system_ability_fwk",
- "samgr:samgr_proxy",
- ]
- defines = []
- if (build_variant == "user") {
- defines += [ "IS_RELEASE_VERSION" ]
- }
-
- relative_install_dir = "module/bundle"
- subsystem_name = "bundlemanager"
- part_name = "app_domain_verify"
-}
diff --git a/interfaces/kits/js/deferred_link/include/deferred_link_napi.h b/interfaces/kits/js/deferred_link/include/deferred_link_napi.h
deleted file mode 100644
index 1197778..0000000
--- a/interfaces/kits/js/deferred_link/include/deferred_link_napi.h
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright (C) 2024 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 APP_DOMAIN_VERIFY_DEFERRED_LINK_NAPI_H
-#define APP_DOMAIN_VERIFY_DEFERRED_LINK_NAPI_H
-#include "napi/native_api.h"
-#include "napi/native_node_api.h"
-namespace OHOS::AppDomainVerify {
-napi_value GetDeferredLink(napi_env env, napi_callback_info info);
-}
-#endif // APP_DOMAIN_VERIFY_DEFERRED_LINK_NAPI_H
diff --git a/interfaces/kits/js/deferred_link/src/deferred_link_napi.cpp b/interfaces/kits/js/deferred_link/src/deferred_link_napi.cpp
deleted file mode 100644
index d151734..0000000
--- a/interfaces/kits/js/deferred_link/src/deferred_link_napi.cpp
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Copyright (C) 2024 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 <memory>
-#include <map>
-#include "deferred_link_napi.h"
-#include "app_domain_verify_hilog.h"
-#include "app_domain_verify_mgr_client.h"
-#include "comm_define.h"
-#include "api_event_reporter.h"
-#include "napi_value_utils.h"
-#include "napi_async_utils.h"
-
-namespace OHOS::AppDomainVerify {
-using namespace Dfx;
-namespace {
-constexpr const char* GET_DEFERRED_LINK = "GetDeferredLink";
-}
-std::map<CommonErrorCode, const char*> g_ErrCodeMap = { { CommonErrorCode::E_INTERNAL_ERR, "Internal error." } };
-
-struct GetDeferredLinkCallbackInfo : public BaseCallbackInfo {
- GetDeferredLinkCallbackInfo(napi_env napiEnv, std::unique_ptr<Dfx::ApiEventReporter> reporter)
- : BaseCallbackInfo(napiEnv), apiReporter(std::move(reporter))
- {
- }
- std::unique_ptr<Dfx::ApiEventReporter> apiReporter;
- std::string deferred_link;
-};
-
-void GetDeferredLinkExec(napi_env env, void* data)
-{
- APP_DOMAIN_VERIFY_HILOGD(APP_DOMAIN_VERIFY_MGR_MODULE_SERVICE, "called");
- auto* asyncCallbackInfo = reinterpret_cast<GetDeferredLinkCallbackInfo*>(data);
- if (asyncCallbackInfo == nullptr) {
- APP_DOMAIN_VERIFY_HILOGE(APP_DOMAIN_VERIFY_MGR_MODULE_SERVICE, "asyncCallbackInfo is null");
- return;
- }
- std::string deferredLink;
- asyncCallbackInfo->err = AppDomainVerifyMgrClient::GetInstance()->GetDeferredLink(deferredLink);
- asyncCallbackInfo->deferred_link = deferredLink;
- APP_DOMAIN_VERIFY_HILOGD(APP_DOMAIN_VERIFY_MGR_MODULE_SERVICE, "called end");
-}
-
-void GetDeferredLinkComplete(napi_env env, napi_status status, void* data)
-{
- APP_DOMAIN_VERIFY_HILOGD(APP_DOMAIN_VERIFY_MGR_MODULE_SERVICE, "called");
- auto* asyncCallbackInfo = reinterpret_cast<GetDeferredLinkCallbackInfo*>(data);
- if (asyncCallbackInfo == nullptr) {
- APP_DOMAIN_VERIFY_HILOGE(
- APP_DOMAIN_VERIFY_MGR_MODULE_SERVICE, "asyncCallbackInfo is null in %{public}s", __func__);
- return;
- }
- std::unique_ptr<GetDeferredLinkCallbackInfo> callbackPtr{ asyncCallbackInfo };
- napi_value result[ARGS_SIZE_TWO] = { nullptr };
- if (asyncCallbackInfo->err == SUCCESS) {
- NAPI_CALL_RETURN_VOID(env, napi_get_null(env, &result[0]));
- result[ARGS_SIZE_ONE] = BuildString(env, asyncCallbackInfo->deferred_link);
- } else {
- asyncCallbackInfo->apiReporter->SetEvent(API_FAIL, CommonErrorCode::E_INTERNAL_ERR);
- result[0] = BuildError(env, CommonErrorCode::E_INTERNAL_ERR, g_ErrCodeMap[CommonErrorCode::E_INTERNAL_ERR]);
- }
- if (asyncCallbackInfo->deferred) {
- APP_DOMAIN_VERIFY_HILOGD(APP_DOMAIN_VERIFY_MGR_MODULE_SERVICE, "is deferred");
- if (asyncCallbackInfo->err == SUCCESS) {
- NAPI_CALL_RETURN_VOID(env, napi_resolve_deferred(env, asyncCallbackInfo->deferred, result[ARGS_SIZE_ONE]));
- } else {
- NAPI_CALL_RETURN_VOID(env, napi_reject_deferred(env, asyncCallbackInfo->deferred, result[0]));
- }
- } else {
- APP_DOMAIN_VERIFY_HILOGD(APP_DOMAIN_VERIFY_MGR_MODULE_SERVICE, "is callback");
- napi_value callback = nullptr;
- napi_value placeHolder = nullptr;
- NAPI_CALL_RETURN_VOID(env, napi_get_reference_value(env, asyncCallbackInfo->callback, &callback));
- NAPI_CALL_RETURN_VOID(
- env, napi_call_function(env, nullptr, callback, sizeof(result) / sizeof(result[0]), result, &placeHolder));
- }
- callbackPtr->apiReporter->SetEvent(API_SUCCESS, asyncCallbackInfo->err);
- APP_DOMAIN_VERIFY_HILOGD(APP_DOMAIN_VERIFY_MGR_MODULE_SERVICE, "called end");
-}
-
-napi_value GetDeferredLink(napi_env env, napi_callback_info info)
-{
- std::unique_ptr<Dfx::ApiEventReporter> reporter = std::make_unique<Dfx::ApiEventReporter>("GetDeferredLink");
- auto* asyncCallbackInfo = new (std::nothrow) GetDeferredLinkCallbackInfo(env, std::move(reporter));
- if (asyncCallbackInfo == nullptr) {
- return nullptr;
- }
- std::unique_ptr<GetDeferredLinkCallbackInfo> callbackPtr{ asyncCallbackInfo };
- size_t argc = 1;
- napi_value args[1] = { nullptr };
- NAPI_CALL_BASE(env, napi_get_cb_info(env, info, &argc, args, nullptr, nullptr), nullptr);
- napi_valuetype valueType = napi_undefined;
- napi_typeof(env, args[0], &valueType);
- if (valueType == napi_function) {
- APP_DOMAIN_VERIFY_HILOGD(APP_DOMAIN_VERIFY_MGR_MODULE_SERVICE, "is callback");
- NAPI_CALL(env, napi_create_reference(env, args[0], 1, &asyncCallbackInfo->callback));
- }
- auto promise = AsyncCallNativeMethod<GetDeferredLinkCallbackInfo>(
- env, asyncCallbackInfo, GET_DEFERRED_LINK, GetDeferredLinkExec, GetDeferredLinkComplete);
- callbackPtr.release();
- APP_DOMAIN_VERIFY_HILOGD(APP_DOMAIN_VERIFY_MGR_MODULE_SERVICE, "GetDeferredLink end");
- return promise;
-}
-}
\ No newline at end of file
diff --git a/interfaces/kits/js/deferred_link/src/native_module.cpp b/interfaces/kits/js/deferred_link/src/native_module.cpp
deleted file mode 100644
index b568f4e..0000000
--- a/interfaces/kits/js/deferred_link/src/native_module.cpp
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2024 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 "napi/native_api.h"
-#include "napi/native_node_api.h"
-#include "deferred_link_napi.h"
-namespace OHOS {
-namespace AppDomainVerify {
-static napi_value AppDomainVerifyExport(napi_env env, napi_value exports)
-{
- napi_property_descriptor desc[] = {
- { "getDeferredLink", nullptr, GetDeferredLink, nullptr, nullptr, nullptr, napi_default, nullptr },
- };
-
- NAPI_CALL(env, napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc));
- return exports;
-}
-
-static napi_module bundle_manager_module = { .nm_version = 1,
- .nm_flags = 0,
- .nm_filename = nullptr,
- .nm_register_func = AppDomainVerifyExport,
- .nm_modname = "bundle.deferredLink",
- .nm_priv = ((void*)0),
- .reserved = { 0 } };
-
-extern "C" __attribute__((constructor)) void BundleManagerRegister(void)
-{
- napi_module_register(&bundle_manager_module);
-}
-}
-}
\ No newline at end of file
diff --git a/interfaces/kits/js/event/include/api_event_reporter.h b/interfaces/kits/js/include/api_event_reporter.h
similarity index 84%
rename from interfaces/kits/js/event/include/api_event_reporter.h
rename to interfaces/kits/js/include/api_event_reporter.h
index 71f0cff..8bc95c4 100644
--- a/interfaces/kits/js/event/include/api_event_reporter.h
+++ b/interfaces/kits/js/include/api_event_reporter.h
@@ -17,24 +17,19 @@
#include <string>
namespace OHOS::AppDomainVerify::Dfx {
-constexpr int32_t API_SUCCESS = 0;
-constexpr int32_t API_FAIL = 1;
class ApiEventReporter {
public:
explicit ApiEventReporter(const std::string& apiName);
- ~ApiEventReporter();
- void SetEvent(const int result, const int32_t errCode);
+ ~ApiEventReporter() = default;
+ void WriteEndEvent(const int result, const int32_t errCode);
private:
- void WriteEndEvent(const int result, const int32_t errCode);
int64_t AddProcessor();
private:
std::string transId_;
std::string apiName_;
int64_t startTime_;
- int result_{ API_FAIL };
- int32_t errCode_{ -1 };
};
}
#endif // APP_DOMAIN_VERIFY_MANAGER_API_EVENT_REPORTER_H
diff --git a/interfaces/kits/js/app_domain_verify/include/app_domain_verify_manager_napi.h b/interfaces/kits/js/include/app_domain_verify_manager_napi.h
similarity index 100%
rename from interfaces/kits/js/app_domain_verify/include/app_domain_verify_manager_napi.h
rename to interfaces/kits/js/include/app_domain_verify_manager_napi.h
diff --git a/interfaces/kits/js/event/include/config_parser.h b/interfaces/kits/js/include/config_parser.h
similarity index 100%
rename from interfaces/kits/js/event/include/config_parser.h
rename to interfaces/kits/js/include/config_parser.h
diff --git a/interfaces/kits/js/napi_utils/include/napi_async_utils.h b/interfaces/kits/js/napi_utils/include/napi_async_utils.h
deleted file mode 100644
index a70d807..0000000
--- a/interfaces/kits/js/napi_utils/include/napi_async_utils.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (C) 2024 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 APP_DOMAIN_VERIFY_NAPI_ASYNC_UTILS_H
-#define APP_DOMAIN_VERIFY_NAPI_ASYNC_UTILS_H
-#include "napi/native_api.h"
-#include "napi/native_common.h"
-#include "napi/native_node_api.h"
-#include "app_domain_verify_hilog.h"
-namespace OHOS::AppDomainVerify {
-constexpr int SUCCESS = 0;
-constexpr int ARGS_SIZE_ZERO = 0;
-constexpr int ARGS_SIZE_ONE = 1;
-constexpr int ARGS_SIZE_TWO = 2;
-struct AsyncWorkData {
- explicit AsyncWorkData(napi_env napiEnv) : env(napiEnv){};
- virtual ~AsyncWorkData();
- napi_env env;
- napi_async_work asyncWork = nullptr;
- napi_deferred deferred = nullptr;
- napi_ref callback = nullptr;
-};
-
-struct BaseCallbackInfo : public AsyncWorkData {
- explicit BaseCallbackInfo(napi_env napiEnv) : AsyncWorkData(napiEnv)
- {
- }
- int32_t err = 0;
- std::string message;
-};
-
-template <typename T>
-static napi_value AsyncCallNativeMethod(napi_env env, T* asyncCallbackInfo, const std::string& methodName,
- void (*execFunc)(napi_env, void*), void (*completeFunc)(napi_env, napi_status, void*))
-{
- if (asyncCallbackInfo == nullptr) {
- APP_DOMAIN_VERIFY_HILOGE(APP_DOMAIN_VERIFY_MGR_MODULE_SERVICE, "asyncCallbackInfo is null");
- return nullptr;
- }
- napi_value promise = nullptr;
- if (asyncCallbackInfo->callback == nullptr) {
- NAPI_CALL(env, napi_create_promise(env, &asyncCallbackInfo->deferred, &promise));
- } else {
- NAPI_CALL(env, napi_get_undefined(env, &promise));
- }
- napi_value resource = nullptr;
- NAPI_CALL(env, napi_create_string_utf8(env, methodName.c_str(), NAPI_AUTO_LENGTH, &resource));
- NAPI_CALL(env,
- napi_create_async_work(env, nullptr, resource, execFunc, completeFunc,
- reinterpret_cast<void*>(asyncCallbackInfo), &asyncCallbackInfo->asyncWork));
- NAPI_CALL(env, napi_queue_async_work(env, asyncCallbackInfo->asyncWork));
- return promise;
-}
-}
-#endif // APP_DOMAIN_VERIFY_NAPI_ASYNC_UTILS_H
diff --git a/interfaces/kits/js/napi_utils/include/napi_value_utils.h b/interfaces/kits/js/napi_utils/include/napi_value_utils.h
deleted file mode 100644
index 52cdaca..0000000
--- a/interfaces/kits/js/napi_utils/include/napi_value_utils.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (C) 2024 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 APP_DOMAIN_VERIFY_NAPI_VALUE_UTIL_H
-#define APP_DOMAIN_VERIFY_NAPI_VALUE_UTIL_H
-#include <memory>
-#include "napi/native_api.h"
-#include "napi/native_node_api.h"
-#include "app_domain_verify_hilog.h"
-#include "comm_define.h"
-namespace OHOS::AppDomainVerify {
-std::string GetString(napi_env env, napi_value value);
-napi_value BuildString(const napi_env& env, const std::string& data);
-napi_value BuildStringArray(const napi_env& env, const std::vector<std::string>& data);
-bool CheckInput(const std::string& input);
-napi_value BuildError(const napi_env& env, uint32_t errorCode, const char* errorMsg);
-}
-#endif // APP_DOMAIN_VERIFY_NAPI_VALUE_UTIL_H
diff --git a/interfaces/kits/js/napi_utils/src/napi_async_utils.cpp b/interfaces/kits/js/napi_utils/src/napi_async_utils.cpp
deleted file mode 100644
index 739ac65..0000000
--- a/interfaces/kits/js/napi_utils/src/napi_async_utils.cpp
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (C) 2024 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 "napi_async_utils.h"
-namespace OHOS::AppDomainVerify {
-
-AsyncWorkData::~AsyncWorkData()
-{
- if (callback) {
- APP_DOMAIN_VERIFY_HILOGD(APP_DOMAIN_VERIFY_MGR_MODULE_SERVICE, "AsyncWorkData::~AsyncWorkData delete callback");
- napi_delete_reference(env, callback);
- callback = nullptr;
- }
- if (asyncWork) {
- APP_DOMAIN_VERIFY_HILOGD(
- APP_DOMAIN_VERIFY_MGR_MODULE_SERVICE, "AsyncWorkData::~AsyncWorkData delete asyncWork");
- napi_delete_async_work(env, asyncWork);
- asyncWork = nullptr;
- }
-}
-}
\ No newline at end of file
diff --git a/interfaces/kits/js/napi_utils/src/napi_value_utils.cpp b/interfaces/kits/js/napi_utils/src/napi_value_utils.cpp
deleted file mode 100644
index a7836d2..0000000
--- a/interfaces/kits/js/napi_utils/src/napi_value_utils.cpp
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (C) 2024 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 "napi_value_utils.h"
-namespace OHOS::AppDomainVerify {
-constexpr int32_t MAX_STR_INPUT_SIZE = 256;
-constexpr int32_t STRING_BUF_MAX_SIZE = 4096;
-std::string GetString(napi_env env, napi_value value)
-{
- std::unique_ptr<char[]> valueBuf = std::make_unique<char[]>(STRING_BUF_MAX_SIZE);
- size_t size = 0;
- NAPI_CALL_BASE(env, napi_get_value_string_utf8(env, value, valueBuf.get(), STRING_BUF_MAX_SIZE, &size), "");
- std::string result = std::string(valueBuf.get(), size);
- return result;
-}
-napi_value BuildString(const napi_env& env, const std::string& data)
-{
- napi_value result;
- NAPI_CALL_BASE(env, napi_create_string_utf8(env, data.c_str(), NAPI_AUTO_LENGTH, &result), nullptr);
- return result;
-}
-napi_value BuildStringArray(const napi_env& env, const std::vector<std::string>& data)
-{
- napi_value arr;
- NAPI_CALL_BASE(env, napi_create_array(env, &arr), nullptr);
- size_t index = 0;
- for (auto&& str : data) {
- napi_value value = BuildString(env, str);
- NAPI_CALL_BASE(env, napi_set_element(env, arr, index++, value), nullptr);
- }
- return arr;
-}
-bool CheckInput(const std::string& input)
-{
- if (input.empty() || input.size() > MAX_STR_INPUT_SIZE) {
- return false;
- }
- return true;
-}
-napi_value BuildError(const napi_env& env, uint32_t errorCode, const char* errorMsg)
-{
- auto ret = napi_throw_error(env, std::to_string(errorCode).c_str(), errorMsg);
- if (ret != napi_status::napi_ok) {
- APP_DOMAIN_VERIFY_HILOGE(APP_DOMAIN_VERIFY_MGR_MODULE_SERVICE, "throw err failed.");
- }
- return nullptr;
-}
-}
\ No newline at end of file
diff --git a/interfaces/kits/js/event/src/api_event_reporter.cpp b/interfaces/kits/js/src/api_event_reporter.cpp
similarity index 95%
rename from interfaces/kits/js/event/src/api_event_reporter.cpp
rename to interfaces/kits/js/src/api_event_reporter.cpp
index 60dca38..046f4ec 100644
--- a/interfaces/kits/js/event/src/api_event_reporter.cpp
+++ b/interfaces/kits/js/src/api_event_reporter.cpp
@@ -104,13 +104,4 @@ void ApiEventReporter::WriteEndEvent(const int result, const int32_t errCode)
"errCode:%{public}d, ret:%{public}d",
transId_.c_str(), apiName_.c_str(), SDK_NAME.c_str(), result, errCode, ret);
}
-void ApiEventReporter::SetEvent(const int result, const int errCode)
-{
- result_ = result;
- errCode_ = errCode;
-}
-ApiEventReporter::~ApiEventReporter()
-{
- WriteEndEvent(result_, errCode_);
-}
}
\ No newline at end of file
diff --git a/interfaces/kits/js/app_domain_verify/src/app_domain_verify_manager_napi.cpp b/interfaces/kits/js/src/app_domain_verify_manager_napi.cpp
similarity index 57%
rename from interfaces/kits/js/app_domain_verify/src/app_domain_verify_manager_napi.cpp
rename to interfaces/kits/js/src/app_domain_verify_manager_napi.cpp
index 39ddd40..7fdcf6c 100644
--- a/interfaces/kits/js/app_domain_verify/src/app_domain_verify_manager_napi.cpp
+++ b/interfaces/kits/js/src/app_domain_verify_manager_napi.cpp
@@ -20,14 +20,55 @@
#include "app_domain_verify_mgr_client.h"
#include "comm_define.h"
#include "api_event_reporter.h"
-#include "napi_value_utils.h"
namespace OHOS::AppDomainVerify {
-using namespace Dfx;
+constexpr int32_t API_SUCCESS = 0;
+constexpr int32_t API_FAIL = 1;
+constexpr int32_t MAX_STR_INPUT_SIZE = 256;
+constexpr int32_t STRING_BUF_MAX_SIZE = 4096;
std::map<CommonErrorCode, const char*> ErrCodeMap = { { CommonErrorCode::E_PERMISSION_DENIED, "Permission denied." },
{ CommonErrorCode::E_IS_NOT_SYS_APP, "System API accessed by non-system app." },
{ CommonErrorCode::E_PARAM_ERROR, "Parameter error." }, { CommonErrorCode::E_INTERNAL_ERR, "Internal error." } };
-
+static std::string GetString(napi_env env, napi_value value)
+{
+ std::unique_ptr<char[]> valueBuf = std::make_unique<char[]>(STRING_BUF_MAX_SIZE);
+ size_t size = 0;
+ NAPI_CALL_BASE(env, napi_get_value_string_utf8(env, value, valueBuf.get(), STRING_BUF_MAX_SIZE, &size), "");
+ std::string result = std::string(valueBuf.get(), size);
+ return result;
+}
+static napi_value BuildString(const napi_env& env, const std::string& data)
+{
+ napi_value result;
+ NAPI_CALL_BASE(env, napi_create_string_utf8(env, data.c_str(), NAPI_AUTO_LENGTH, &result), nullptr);
+ return result;
+}
+static napi_value BuildStringArray(const napi_env& env, const std::vector<std::string>& data)
+{
+ napi_value arr;
+ NAPI_CALL_BASE(env, napi_create_array(env, &arr), nullptr);
+ size_t index = 0;
+ for (auto&& str : data) {
+ napi_value value = BuildString(env, str);
+ NAPI_CALL_BASE(env, napi_set_element(env, arr, index++, value), nullptr);
+ }
+ return arr;
+}
+static bool CheckInput(const std::string& input)
+{
+ if (input.empty() || input.size() > MAX_STR_INPUT_SIZE) {
+ return false;
+ }
+ return true;
+}
+static napi_value BuildError(const napi_env& env, CommonErrorCode errorCode)
+{
+ auto ret = napi_throw_error(env, std::to_string(errorCode).c_str(), ErrCodeMap[errorCode]);
+ if (ret != napi_status::napi_ok) {
+ APP_DOMAIN_VERIFY_HILOGE(APP_DOMAIN_VERIFY_MGR_MODULE_SERVICE, "throw err failed.");
+ }
+ return nullptr;
+}
napi_value QueryAssociatedDomains(napi_env env, napi_callback_info info)
{
size_t argc = 1;
@@ -37,22 +78,22 @@ napi_value QueryAssociatedDomains(napi_env env, napi_callback_info info)
NAPI_CALL_BASE(env, napi_get_cb_info(env, info, &argc, args, nullptr, nullptr), nullptr);
std::string bundleName = GetString(env, args[0]);
if (!CheckInput(bundleName)) {
- reporter.SetEvent(API_FAIL, CommonErrorCode::E_PARAM_ERROR);
- return BuildError(env, CommonErrorCode::E_PARAM_ERROR, ErrCodeMap[CommonErrorCode::E_PARAM_ERROR]);
+ reporter.WriteEndEvent(API_FAIL, CommonErrorCode::E_PARAM_ERROR);
+ return BuildError(env, CommonErrorCode::E_PARAM_ERROR);
}
std::vector<std::string> domains;
auto ret = AppDomainVerifyMgrClient::GetInstance()->QueryAssociatedDomains(bundleName, domains);
if (ret != 0) {
if (ErrCodeMap.count(static_cast<CommonErrorCode>(ret)) != 0) {
- reporter.SetEvent(API_FAIL, static_cast<CommonErrorCode>(ret));
- return BuildError(env, static_cast<CommonErrorCode>(ret), ErrCodeMap[static_cast<CommonErrorCode>(ret)]);
+ reporter.WriteEndEvent(API_FAIL, static_cast<CommonErrorCode>(ret));
+ return BuildError(env, static_cast<CommonErrorCode>(ret));
} else {
APP_DOMAIN_VERIFY_HILOGE(APP_DOMAIN_VERIFY_MGR_MODULE_SERVICE, "unknown error:%{public}d.", ret);
- reporter.SetEvent(API_FAIL, ret);
+ reporter.WriteEndEvent(API_FAIL, ret);
return BuildStringArray(env, domains);
}
}
- reporter.SetEvent(API_SUCCESS, ret);
+ reporter.WriteEndEvent(API_SUCCESS, ret);
return BuildStringArray(env, domains);
}
napi_value QueryAssociatedBundleNames(napi_env env, napi_callback_info info)
@@ -64,22 +105,22 @@ napi_value QueryAssociatedBundleNames(napi_env env, napi_callback_info info)
NAPI_CALL_BASE(env, napi_get_cb_info(env, info, &argc, args, nullptr, nullptr), nullptr);
std::string domain = GetString(env, args[0]);
if (!CheckInput(domain)) {
- reporter.SetEvent(API_FAIL, CommonErrorCode::E_PARAM_ERROR);
- return BuildError(env, CommonErrorCode::E_PARAM_ERROR, ErrCodeMap[CommonErrorCode::E_PARAM_ERROR]);
+ reporter.WriteEndEvent(API_FAIL, CommonErrorCode::E_PARAM_ERROR);
+ return BuildError(env, CommonErrorCode::E_PARAM_ERROR);
}
std::vector<std::string> bundleNames;
auto ret = AppDomainVerifyMgrClient::GetInstance()->QueryAssociatedBundleNames(domain, bundleNames);
if (ret != 0) {
if (ErrCodeMap.count(static_cast<CommonErrorCode>(ret)) != 0) {
- reporter.SetEvent(API_FAIL, static_cast<CommonErrorCode>(ret));
- return BuildError(env, static_cast<CommonErrorCode>(ret), ErrCodeMap[static_cast<CommonErrorCode>(ret)]);
+ reporter.WriteEndEvent(API_FAIL, static_cast<CommonErrorCode>(ret));
+ return BuildError(env, static_cast<CommonErrorCode>(ret));
} else {
APP_DOMAIN_VERIFY_HILOGE(APP_DOMAIN_VERIFY_MGR_MODULE_SERVICE, "unknown error:%{public}d.", ret);
- reporter.SetEvent(API_FAIL, ret);
+ reporter.WriteEndEvent(API_FAIL, ret);
return BuildStringArray(env, bundleNames);
}
}
- reporter.SetEvent(API_SUCCESS, ret);
+ reporter.WriteEndEvent(API_SUCCESS, ret);
return BuildStringArray(env, bundleNames);
}
}
\ No newline at end of file
diff --git a/interfaces/kits/js/event/src/config_parser.cpp b/interfaces/kits/js/src/config_parser.cpp
similarity index 100%
rename from interfaces/kits/js/event/src/config_parser.cpp
rename to interfaces/kits/js/src/config_parser.cpp
diff --git a/interfaces/kits/js/app_domain_verify/src/native_module.cpp b/interfaces/kits/js/src/native_module.cpp
similarity index 100%
rename from interfaces/kits/js/app_domain_verify/src/native_module.cpp
rename to interfaces/kits/js/src/native_module.cpp
--
2.36.1.windows.1