From cba0e5c48f0c3224c6c618b3aba88189f2271ed4 Mon Sep 17 00:00:00 2001 From: cat Date: Thu, 14 Aug 2025 21:57:20 +0800 Subject: [PATCH 1/2] dd 1.2 syscap Signed-off-by: cat --- interfaces/taihe/BUILD.gn | 2 + interfaces/taihe/syscap/BUILD.gn | 69 +++++++++++++++++++ interfaces/taihe/syscap/idl/global.taihe | 18 +++++ .../taihe/syscap/src/ani_constructor.cpp | 29 ++++++++ interfaces/taihe/syscap/src/global.impl.cpp | 36 ++++++++++ 5 files changed, 154 insertions(+) create mode 100644 interfaces/taihe/syscap/BUILD.gn create mode 100644 interfaces/taihe/syscap/idl/global.taihe create mode 100644 interfaces/taihe/syscap/src/ani_constructor.cpp create mode 100644 interfaces/taihe/syscap/src/global.impl.cpp diff --git a/interfaces/taihe/BUILD.gn b/interfaces/taihe/BUILD.gn index 74433019d..8bb20df00 100644 --- a/interfaces/taihe/BUILD.gn +++ b/interfaces/taihe/BUILD.gn @@ -17,6 +17,8 @@ group("taihe_group") { deps = [ "deviceInfo:deviceInfo_etc", "deviceInfo:deviceInfo_taihe_native", + "syscap:global_etc", + "syscap:global_taihe_native", "systemParameterEnhance:systemParamterEnhance_etc", "systemParameterEnhance:systemParameterEnhance_taihe_native", ] diff --git a/interfaces/taihe/syscap/BUILD.gn b/interfaces/taihe/syscap/BUILD.gn new file mode 100644 index 000000000..543e1bba6 --- /dev/null +++ b/interfaces/taihe/syscap/BUILD.gn @@ -0,0 +1,69 @@ +# Copyright (c) 2025 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("//base/startup/init/begetd.gni") +import("//build/config/components/ets_frontend/ets2abc_config.gni") +import("//build/ohos.gni") +import("//build/ohos/taihe_idl/taihe.gni") + +copy_taihe_idl("copy_global") { + sources = [ "idl/global.taihe" ] +} +subsystem_name = "startup" +part_name = "init" +taihe_generated_file_path = "$taihe_file_path/out/$subsystem_name/$part_name" + +ohos_taihe("run_taihe") { + taihe_generated_file_path = "$taihe_generated_file_path" + deps = [ ":copy_global" ] + outputs = [ + "$taihe_generated_file_path/src/global.ani.cpp", + "$taihe_generated_file_path/src/global.abi.c", + ] +} + +taihe_shared_library("global_taihe_native") { + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + } + taihe_generated_file_path = "$taihe_generated_file_path" + part_name = "$part_name" + subsystem_name = "$subsystem_name" + sources = get_target_outputs(":run_taihe") + include_dirs = [ "//base/startup/init/interfaces/innerkits/include" ] + sources += [ + "src/ani_constructor.cpp", + "src/global.impl.cpp", + ] + deps = [ + ":run_taihe", + "${init_innerkits_path}:libbegetutil", + ] +} + +generate_static_abc("global") { + base_url = "$taihe_generated_file_path" + files = [ "$taihe_generated_file_path/global.ets" ] + is_boot_abc = "True" + device_dst_file = "/system/framework/global.abc" + dependencies = [ ":run_taihe" ] +} + +ohos_prebuilt_etc("global_etc") { + source = "$target_out_dir/global.abc" + module_install_dir = "framework" + part_name = "$part_name" + subsystem_name = "$subsystem_name" + deps = [ ":global" ] +} diff --git a/interfaces/taihe/syscap/idl/global.taihe b/interfaces/taihe/syscap/idl/global.taihe new file mode 100644 index 000000000..4118a6476 --- /dev/null +++ b/interfaces/taihe/syscap/idl/global.taihe @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2025 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. + */ +@!sts_inject(""" +loadLibrary("global_taihe_native") +""") +function canIUse(syscap: String): bool; \ No newline at end of file diff --git a/interfaces/taihe/syscap/src/ani_constructor.cpp b/interfaces/taihe/syscap/src/ani_constructor.cpp new file mode 100644 index 000000000..a90c1c386 --- /dev/null +++ b/interfaces/taihe/syscap/src/ani_constructor.cpp @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 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 "taihe/runtime.hpp" +#include "global.ani.hpp" +ANI_EXPORT ani_status ANI_Constructor(ani_vm *vm, uint32_t *result) +{ + ani_env *env; + if (ANI_OK != vm->GetEnv(ANI_VERSION_1, &env)) { + return ANI_ERROR; + } + if (ANI_OK != global::ANIRegister(env)) { + std::cerr << "Error from global::ANIRegister" << std::endl; + return ANI_ERROR; + } + *result = ANI_VERSION_1; + return ANI_OK; +} diff --git a/interfaces/taihe/syscap/src/global.impl.cpp b/interfaces/taihe/syscap/src/global.impl.cpp new file mode 100644 index 000000000..e1f25df80 --- /dev/null +++ b/interfaces/taihe/syscap/src/global.impl.cpp @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 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 "global.proj.hpp" +#include "global.impl.hpp" +#include "taihe/runtime.hpp" +#include "stdexcept" +#include "systemcapability.h" +#include "beget_ext.h" + +using namespace taihe; +namespace { +// To be implemented. + +bool canIUse(string_view syscap) +{ + bool ret = HasSystemCapability(std::string(syscap).c_str()); + return ret; +} +} // namespace + +// Since these macros are auto-generate, lint will cause false positive. +// NOLINTBEGIN +TH_EXPORT_CPP_API_canIUse(canIUse); +// NOLINTEND -- Gitee From 3e7cd1355c8d0616bd2fdee41cb0540a1b1ee06f Mon Sep 17 00:00:00 2001 From: cat Date: Tue, 19 Aug 2025 09:19:29 +0800 Subject: [PATCH 2/2] Signedt persist param file when public dir exit-off-by: cat --- services/param/adapter/param_persistadp.c | 10 +++++++--- services/param/include/param_utils.h | 1 + 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/services/param/adapter/param_persistadp.c b/services/param/adapter/param_persistadp.c index 7dba4798c..ffd4a85f5 100644 --- a/services/param/adapter/param_persistadp.c +++ b/services/param/adapter/param_persistadp.c @@ -21,7 +21,7 @@ #include "param_manager.h" #include "param_persist.h" #include "param_utils.h" -#if !(defined __LITEOS_A__ || defined __LITEOS_M__) +#if !(defined __LITEOFS_A__ || defined __LITEOS_M__) #include "trigger_manager.h" #endif @@ -60,7 +60,7 @@ static int LoadOnePersistParam_(const uint32_t *context, const char *name, const result = WriteParam(name, value, &dataIndex, mode); } } while (0); -#if !(defined __LITEOS_A__ || defined __LITEOS_M__) +#if !(defined __LITEOFS_A__ || defined __LITEOS_M__) if (result == 0) { PostParamTrigger(EVENT_TRIGGER_PARAM_WATCH, name, value); } @@ -164,7 +164,11 @@ static bool GetPersistFilePath(char **path, char **tmpPath, int fileType) PARAM_LOGE("rename failed %s", PARAM_OLD_PERSIST_SAVE_PATH); } } else { - CheckAndCreateDir(PARAM_PRIVATE_PERSIST_SAVE_PATH); + if (access(PUBLIC_DIR, F_OK) == 0) { + CheckAndCreateDir(PARAM_PRIVATE_PERSIST_SAVE_PATH); + } else { + PARAM_LOGE("public dir not exit, creat param file fail"); + } } *path = PARAM_PRIVATE_PERSIST_SAVE_PATH; *tmpPath = PARAM_PRIVATE_PERSIST_SAVE_TMP_PATH; diff --git a/services/param/include/param_utils.h b/services/param/include/param_utils.h index 63f03e55a..5cab8b711 100644 --- a/services/param/include/param_utils.h +++ b/services/param/include/param_utils.h @@ -87,6 +87,7 @@ typedef enum { #define PARAM_PUBLIC_PERSIST_SAVE_TMP_PATH DATA_PATH "tmp_public_persist_parameters" #define PARAM_PRIVATE_PERSIST_SAVE_PATH PRIVATE_DATA_PATH "private_persist_parameters" #define PARAM_PRIVATE_PERSIST_SAVE_TMP_PATH PRIVATE_DATA_PATH "tmp_private_persist_parameters" +#define PUBLIC_DIR "/data/service/el1/public" #define PERSIST_HANDLE_MAX 2 #define WORKSPACE_FLAGS_INIT 0x01 -- Gitee