From 8a9c4624f3f09a76caa48e9bcb4c7d0644ac6817 Mon Sep 17 00:00:00 2001 From: kirby Date: Thu, 30 May 2024 10:12:52 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9B=9E=E9=80=80beta=E5=88=86=E6=94=AFcj?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: kirby --- BUILD.gn | 1 - interfaces/kits/cj/BUILD.gn | 54 ------- interfaces/kits/cj/src/config_policy_ffi.cpp | 134 ------------------ interfaces/kits/cj/src/config_policy_ffi.h | 28 ---- interfaces/kits/cj/src/config_policy_log.h | 41 ------ interfaces/kits/cj/src/config_policy_mock.cpp | 22 --- 6 files changed, 280 deletions(-) delete mode 100644 interfaces/kits/cj/BUILD.gn delete mode 100644 interfaces/kits/cj/src/config_policy_ffi.cpp delete mode 100644 interfaces/kits/cj/src/config_policy_ffi.h delete mode 100644 interfaces/kits/cj/src/config_policy_log.h delete mode 100644 interfaces/kits/cj/src/config_policy_mock.cpp diff --git a/BUILD.gn b/BUILD.gn index 85822f7..0a8f478 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -17,7 +17,6 @@ group("config_policy_components") { if (os_level == "standard" && support_config_policy_napi && support_jsapi) { deps = [ "./frameworks/config_policy:configpolicy_util", - "./interfaces/kits/cj:cj_config_policy_ffi", "./interfaces/kits/js:configpolicy", ] } else { diff --git a/interfaces/kits/cj/BUILD.gn b/interfaces/kits/cj/BUILD.gn deleted file mode 100644 index 31cbee1..0000000 --- a/interfaces/kits/cj/BUILD.gn +++ /dev/null @@ -1,54 +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") - -ohos_shared_library("cj_config_policy_ffi") { - include_dirs = [ - "include", - "../../../interfaces/inner_api/include", - "../../../frameworks/dfx/hisysevent_adapter", - ] - if (!defined(defines)) { - defines = [] - } - - if (product_name != "ohos-sdk") { - deps = [ "../../../frameworks/config_policy:configpolicy_util" ] - external_deps = [ - "bounds_checking_function:libsec_shared", - "hilog:libhilog", - "hisysevent:libhisysevent", - "napi:cj_bind_ffi", - "napi:cj_bind_native", - ] - sources = [ - "../../../frameworks/dfx/hisysevent_adapter/hisysevent_adapter.cpp", - "src/config_policy_ffi.cpp", - ] - } else { - defines += [ "PREVIEWER" ] - sources = [ "src/config_policy_mock.cpp" ] - } - - if (current_os == "ohos") { - defines += [ "OHOS_PLATFORM" ] - } - - if (current_os == "mingw") { - defines += [ "WINDOWS_PLATFORM" ] - } - innerapi_tags = [ "platformsdk" ] - subsystem_name = "customization" - part_name = "config_policy" -} diff --git a/interfaces/kits/cj/src/config_policy_ffi.cpp b/interfaces/kits/cj/src/config_policy_ffi.cpp deleted file mode 100644 index 3af9e30..0000000 --- a/interfaces/kits/cj/src/config_policy_ffi.cpp +++ /dev/null @@ -1,134 +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 "config_policy_ffi.h" - -#include -#include -#include "config_policy_utils.h" -#include "hisysevent_adapter.h" -#include "config_policy_log.h" - -namespace OHOS::Customization::ConfigPolicy { - -static constexpr int MAX_MALLOC_LEN = 1024; - -char** MallocCStringArr(const std::vector& origin) -{ - if (origin.empty()) { - return nullptr; - } - auto size = origin.size(); - if (size == 0 || size > MAX_MALLOC_LEN) { - return nullptr; - } - auto arr = static_cast(malloc(sizeof(char*) * size)); - if (arr == nullptr) { - return nullptr; - } - for (size_t i = 0; i < size; i++) { - size_t len = strlen(origin[i]) + 1; - arr[i] = static_cast(malloc(sizeof(char) * len)); - if (arr[i] == nullptr) { - continue; - } - errno_t ret = strcpy_s(arr[i], len, origin[i]); - if (ret != 0) { - free(arr[i]); - arr[i] = nullptr; - } - } - return arr; -} - -extern "C" { - RetDataCArrString CJ_GetCfgDirList() - { - LOGI("CJ_GetCfgDirList start"); - RetDataCArrString ret = { .code = SUCCESS_CODE, .data = { .head = nullptr, .size = 0 } }; - CfgDir *cfgDir = GetCfgDirList(); - - std::vector dirList; - if (cfgDir != nullptr) { - for (size_t i = 0; i < MAX_CFG_POLICY_DIRS_CNT; i++) { - if (cfgDir->paths[i] != nullptr) { - dirList.push_back(cfgDir->paths[i]); - } - } - } - - ret.data.head = MallocCStringArr(dirList); - ret.data.size = static_cast(ret.data.head == nullptr ? 0 : dirList.size()); - - FreeCfgDirList(cfgDir); - ReportConfigPolicyEvent(ReportType::CONFIG_POLICY_EVENT, "getCfgDirList", ""); - LOGI("CJ_GetCfgDirList ok"); - return ret; - } - - RetDataCArrString CJ_GetCfgFiles(const char* relPath) - { - LOGI("CJ_GetCfgFiles start"); - RetDataCArrString ret = { .code = SUCCESS_CODE, .data = { .head = nullptr, .size = 0 } }; - LOGI("input path: [%{public}s]", relPath) - std::string extra(""); - CfgFiles *cfgFiles = GetCfgFilesEx(relPath, FOLLOWX_MODE_DEFAULT, extra.c_str()); - - std::vector fileList; - if (cfgFiles != nullptr) { - for (size_t i = 0; i < MAX_CFG_POLICY_DIRS_CNT; i++) { - if (cfgFiles->paths[i] != nullptr) { - fileList.push_back(cfgFiles->paths[i]); - } - } - } - - ret.data.head = MallocCStringArr(fileList); - ret.data.size = static_cast(ret.data.head == nullptr ? 0 : fileList.size()); - - FreeCfgFiles(cfgFiles); - ReportConfigPolicyEvent(ReportType::CONFIG_POLICY_EVENT, "getCfgFiles", ""); - return ret; - } - - RetDataCString CJ_GetOneCfgFile(const char* relPath) - { - LOGI("CJ_GetOneCfgFile start"); - RetDataCString ret = { .code = SUCCESS_CODE, .data = nullptr }; - char outBuf[MAX_PATH_LEN] = {0}; - std::string extra(""); - char* filePath = GetOneCfgFileEx(relPath, outBuf, MAX_PATH_LEN, FOLLOWX_MODE_DEFAULT, extra.c_str()); - - if (filePath == nullptr) { - LOGI("GetOneCfgFileEx result is nullptr."); - return ret; - } else { - LOGI("GetOneCfgFile return [%{public}s]", filePath); - } - ReportConfigPolicyEvent(ReportType::CONFIG_POLICY_EVENT, "getOneCfgFile", ""); - size_t pathLen = strlen(filePath) + 1; - ret.data = static_cast(malloc(sizeof(char) * pathLen)); - if (ret.data == nullptr) { - return ret; - } - errno_t err = strcpy_s(ret.data, pathLen, filePath); - if (err != 0) { - free(ret.data); - ret.data = nullptr; - } - return ret; - } -} -} // namespace OHOS::Customization::ConfigPolicy diff --git a/interfaces/kits/cj/src/config_policy_ffi.h b/interfaces/kits/cj/src/config_policy_ffi.h deleted file mode 100644 index 17ffea9..0000000 --- a/interfaces/kits/cj/src/config_policy_ffi.h +++ /dev/null @@ -1,28 +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 CONFIG_POLICY_FFI_H -#define CONFIG_POLICY_FFI_H - -#include "ffi_remote_data.h" -#include "cj_common_ffi.h" - -extern "C" { - FFI_EXPORT RetDataCArrString CJ_GetCfgDirList(); - FFI_EXPORT RetDataCArrString CJ_GetCfgFiles(const char* relPath); - FFI_EXPORT RetDataCString CJ_GetOneCfgFile(const char* relPath); -} - -#endif \ No newline at end of file diff --git a/interfaces/kits/cj/src/config_policy_log.h b/interfaces/kits/cj/src/config_policy_log.h deleted file mode 100644 index afe7002..0000000 --- a/interfaces/kits/cj/src/config_policy_log.h +++ /dev/null @@ -1,41 +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 CONFIG_POLICY_LOG_H -#define CONFIG_POLICY_LOG_H - -#include "hilog/log.h" - -#ifdef LOG_DOMAIN -#undef LOG_DOMAIN -#endif -#ifdef LOG_TAG -#undef LOG_TAG -#endif - -#define LOG_DOMAIN 0xD001E00 -#define LOG_TAG "ConfigPolicyFFI" - -#define LOGI(...) \ -if (HiLogIsLoggable(LOG_DOMAIN, LOG_TAG, LOG_INFO)) { \ - HILOG_INFO(LOG_CORE, ##__VA_ARGS__); \ -} - -#define LOGE(...) \ -if (HiLogIsLoggable(LOG_DOMAIN, LOG_TAG, LOG_ERROR)) { \ - HILOG_ERROR(LOG_CORE, ##__VA_ARGS__); \ -} - -#endif diff --git a/interfaces/kits/cj/src/config_policy_mock.cpp b/interfaces/kits/cj/src/config_policy_mock.cpp deleted file mode 100644 index a0791c1..0000000 --- a/interfaces/kits/cj/src/config_policy_mock.cpp +++ /dev/null @@ -1,22 +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. - */ - -#define FFI_EXPORT __attribute__((visibility("default"))) - -extern "C" { -FFI_EXPORT int CJ_GetCfgDirList = 0; -FFI_EXPORT int CJ_GetCfgFiles = 0; -FFI_EXPORT int CJ_GetOneCfgFile = 0; -} \ No newline at end of file -- Gitee