diff --git a/interfaces/taihe/BUILD.gn b/interfaces/taihe/BUILD.gn index 74433019dbd065ff61c2faca4df51814f04b56ba..8bb20df00efa94f938598d8c1337ca1936a3cf46 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 0000000000000000000000000000000000000000..543e1bba6dc8e265c61fb3f5b94a71497b2bd114 --- /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 0000000000000000000000000000000000000000..4118a6476489e235fcc4826fa1f671ad88686834 --- /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 0000000000000000000000000000000000000000..a90c1c3863443f569185c05e6afbdf969a4e97bf --- /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 0000000000000000000000000000000000000000..e1f25df80cd06df681a1db8186d7d08caa700850 --- /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 diff --git a/services/param/adapter/param_persistadp.c b/services/param/adapter/param_persistadp.c index 7dba4798c8ccaecc8c0d0a9f95e4fc833841d34f..ffd4a85f58d24267f86bc38a0ca109a59b002aa9 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 63f03e55aafedd99bf51fadb6f952feab79ce2eb..5cab8b711ea22b870469dae0d631f896784d6037 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