diff --git a/bundle.json b/bundle.json index 4ea02f8e9b566009ca9cc16208cfee33ea59ab1a..2efe0d3bad5424e9aa06561763f4294576cfb293 100755 --- a/bundle.json +++ b/bundle.json @@ -66,6 +66,7 @@ "hiprofiler", "bounds_checking_function", "bundle_framework", + "runtime_core", "selinux", "selinux_adapter", "storage_service", diff --git a/interfaces/taihe/deviceInfo/idl/ohos.deviceInfo.taihe b/interfaces/taihe/deviceInfo/idl/ohos.deviceInfo.taihe index df8e87eecf09d75f54d60e78dec18a87ddb8312d..f9b87a1cd39da91e44f58ccbaed748cdb20a8c5f 100644 --- a/interfaces/taihe/deviceInfo/idl/ohos.deviceInfo.taihe +++ b/interfaces/taihe/deviceInfo/idl/ohos.deviceInfo.taihe @@ -99,4 +99,4 @@ function getfirstApiVersion(): i32; @static("deviceInfo") @get function getdistributionOSApiVersion(): i32; @static("deviceInfo") @get -function getbootCount(): i32; \ No newline at end of file +function getbootCount(): i32; diff --git a/interfaces/taihe/deviceInfo/src/ohos.deviceInfo.impl.cpp b/interfaces/taihe/deviceInfo/src/ohos.deviceInfo.impl.cpp index 16bb09cbf74c7484f1f04cd4d2dfb69eebf4f475..0cd1200b6334f4802fa165d04fc1e15a0836ff9f 100644 --- a/interfaces/taihe/deviceInfo/src/ohos.deviceInfo.impl.cpp +++ b/interfaces/taihe/deviceInfo/src/ohos.deviceInfo.impl.cpp @@ -465,4 +465,4 @@ TH_EXPORT_CPP_API_getbuildVersion(getbuildVersion); TH_EXPORT_CPP_API_getfirstApiVersion(getfirstApiVersion); TH_EXPORT_CPP_API_getdistributionOSApiVersion(getdistributionOSApiVersion); TH_EXPORT_CPP_API_getbootCount(getbootCount); -TH_EXPORT_CPP_API_getchipType(getchipType); \ No newline at end of file +TH_EXPORT_CPP_API_getchipType(getchipType); diff --git a/interfaces/taihe/syscap/src/ani_constructor.cpp b/interfaces/taihe/syscap/src/ani_constructor.cpp index 4d73d3eafc7442bf8064c2bc308449c69bc44ade..c6a9fad38e452f3815bdca0483d9ecddbcfd24b6 100644 --- a/interfaces/taihe/syscap/src/ani_constructor.cpp +++ b/interfaces/taihe/syscap/src/ani_constructor.cpp @@ -12,7 +12,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include "taihe.platform.ani.ani.hpp" #include "internal.full.global.ani.hpp" #if __has_include() #include diff --git a/interfaces/taihe/systemParameterEnhance/idl/ohos.systemParameterEnhance.systemParameterEnhance.taihe b/interfaces/taihe/systemParameterEnhance/idl/ohos.systemParameterEnhance.systemParameterEnhance.taihe new file mode 100644 index 0000000000000000000000000000000000000000..5237ba1c4d788afec91a5e99594cc78ddf25fca9 --- /dev/null +++ b/interfaces/taihe/systemParameterEnhance/idl/ohos.systemParameterEnhance.systemParameterEnhance.taihe @@ -0,0 +1,35 @@ +/* + * 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. + */ +@!namespace("@ohos.systemParameterEnhance.systemParameterEnhance", "systemParameterEnhance") + +@!sts_inject(""" +static { loadLibrary("systemParameterEnhance_taihe_native.z") } +""") + +function getSync(key: String, def: Optional): String; + +@gen_async("get") +@gen_promise("get") +function getParam(key: String, def: Optional): String; + +@gen_async("get") +function getParamNodef(key: String): String; + +function setSync(key: String, value: String): void; + +@gen_async("set") +@gen_promise("set") +function setParam(key: String, value: String): void; + diff --git a/interfaces/taihe/systemParameterEnhance/src/ohos.systemParameterEnhance.systemParameterEnhance.impl.cpp b/interfaces/taihe/systemParameterEnhance/src/ohos.systemParameterEnhance.systemParameterEnhance.impl.cpp new file mode 100644 index 0000000000000000000000000000000000000000..8fd7ca1d6e3b68dd8fcbde90d1bad1d1c8e987f4 --- /dev/null +++ b/interfaces/taihe/systemParameterEnhance/src/ohos.systemParameterEnhance.systemParameterEnhance.impl.cpp @@ -0,0 +1,90 @@ +/* + * 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 "ohos.systemParameterEnhance.systemParameterEnhance.proj.hpp" +#include "ohos.systemParameterEnhance.systemParameterEnhance.impl.hpp" +#include "taihe/runtime.hpp" +#include "stdexcept" + +#include "beget_ext.h" +#include "parameter.h" +#include "sysparam_errno.h" + +static constexpr int MAX_VALUE_LENGTH = PARAM_CONST_VALUE_LEN_MAX; + +using namespace taihe; +// using namespace ohos::systemParameterEnhance::systemParameterEnhance; + +namespace { +// To be implemented. +string GetParam(std::string key, std::string def) +{ + if (key.empty()) { + taihe::set_business_error(SYSPARAM_INVALID_INPUT, "input is invalid"); + } + char value[MAX_VALUE_LENGTH] = {0}; + int result = GetParameter(key.c_str(), def.c_str(), value, MAX_VALUE_LENGTH); + if (result < 0) { + taihe::set_business_error(result, "getSync failed"); + } + return value; +} + +string getSync(string_view key, optional_view def) +{ + string defValue = def.value_or(""); + return GetParam(std::string(key), std::string(defValue)); +} + +string getParam(string_view key, optional_view def) +{ + string defValue = def.value_or(""); + return GetParam(std::string(key), std::string(defValue)); +} + +string getParamNodef(string_view key) +{ + return GetParam(std::string(key), nullptr); +} + +void SetParam(std::string key, std::string value) +{ + if (key.empty() || value.empty()) { + taihe::set_business_error(SYSPARAM_INVALID_INPUT, "input is invalid"); + } + if (value.size() >= MAX_VALUE_LENGTH) { + taihe::set_business_error(SYSPARAM_INVALID_VALUE, "input value is invalid"); + } + int result = SetParameter(key.c_str(), value.c_str()); + if (result < 0) { + taihe::set_business_error(result, "set failed"); + } + return; +} +void setSync(string_view key, string_view value) +{ + SetParam(std::string(key), std::string(value)); +} + +void setParam(string_view key, string_view value) +{ + SetParam(std::string(key), std::string(value)); +} +} // namespace + +TH_EXPORT_CPP_API_getSync(getSync); +TH_EXPORT_CPP_API_getParam(getParam); +TH_EXPORT_CPP_API_getParamNodef(getParamNodef); +TH_EXPORT_CPP_API_setSync(setSync); +TH_EXPORT_CPP_API_setParam(setParam); diff --git a/services/etc/param/ohos_const/ohos.para b/services/etc/param/ohos_const/ohos.para index bb949c8c928d87dfce4377eee8dbabaf28a42f08..e243145a738052255148810d493de0e38fad2381 100755 --- a/services/etc/param/ohos_const/ohos.para +++ b/services/etc/param/ohos_const/ohos.para @@ -15,4 +15,4 @@ const.ohos.releasetype=Beta2 const.ohos.apiversion=20 const.ohos.apiminorversion=0 const.ohos.apipatchversion=0 -const.ohos.fullname=OpenHarmony-6.0.0.49 \ No newline at end of file +const.ohos.fullname=OpenHarmony-6.0.0.49 diff --git a/services/etc_lite/param/ohos_const/ohos.para b/services/etc_lite/param/ohos_const/ohos.para index f56d957dba957c43826d64fe202a8cac2f4fce5e..faae93ecc550a7783ee35522e32220bb4cd6227d 100755 --- a/services/etc_lite/param/ohos_const/ohos.para +++ b/services/etc_lite/param/ohos_const/ohos.para @@ -16,4 +16,4 @@ const.ohos.apiversion=20 const.ohos.apiminorversion=0 const.ohos.apipatchversion=0 const.ohos.version.security_patch=2025/09/01 -const.ohos.fullname=OpenHarmony-6.0.0.49 \ No newline at end of file +const.ohos.fullname=OpenHarmony-6.0.0.49