diff --git a/frameworks/config_policy/BUILD.gn b/frameworks/config_policy/BUILD.gn index de798194f3aae199ca5abea00efa990ffab9ef52..37567f34c8ef0094d3e64ed3112813120fdc27ad 100644 --- a/frameworks/config_policy/BUILD.gn +++ b/frameworks/config_policy/BUILD.gn @@ -22,11 +22,13 @@ config("config_policy_config") { include_dirs = [ "//base/customization/config_policy/interfaces/innerkits/include", "//third_party/bounds_checking_function/include", + "//base/startup/init_lite/services/include", ] } if (defined(ohos_lite)) { shared_library("configpolicy_util") { + defines = [ "OHOS_LITE" ] sources = config_policy_sources public_configs = [ ":config_policy_config" ] deps = [ "//third_party/bounds_checking_function:libsec_shared" ] @@ -35,7 +37,17 @@ if (defined(ohos_lite)) { ohos_shared_library("configpolicy_util") { sources = config_policy_sources public_configs = [ ":config_policy_config" ] - deps = [ "//third_party/bounds_checking_function:libsec_static" ] + deps = [ + "etc:customization_etc", + "//base/startup/init_lite/services/param:param_client", + "//third_party/bounds_checking_function:libsec_static", + ] + subsystem_name = "customization" + part_name = "config_policy" + } + ohos_static_library("configpolicy_util_for_init_static") { + sources = config_policy_sources + public_configs = [ ":config_policy_config" ] subsystem_name = "customization" part_name = "config_policy" } diff --git a/frameworks/config_policy/etc/BUILD.gn b/frameworks/config_policy/etc/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..73c9d6fb894d28e5b599dabf3b47ded03e98a2ac --- /dev/null +++ b/frameworks/config_policy/etc/BUILD.gn @@ -0,0 +1,25 @@ +# Copyright (c) 2022 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") + +group("customization_etc") { + deps = [ ":customization.para.dac" ] +} + +ohos_prebuilt_etc("customization.para.dac") { + source = "customization.para.dac" + module_install_dir = "etc/param" + subsystem_name = "customization" + part_name = "config_policy" +} diff --git a/frameworks/config_policy/etc/customization.para.dac b/frameworks/config_policy/etc/customization.para.dac new file mode 100644 index 0000000000000000000000000000000000000000..823c6fbf46d11643a3bd05d5f3d017a969595e45 --- /dev/null +++ b/frameworks/config_policy/etc/customization.para.dac @@ -0,0 +1,15 @@ +# Copyright (c) 2022 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. + +const.cust.="root:root:774" + diff --git a/frameworks/config_policy/src/config_policy_utils.c b/frameworks/config_policy/src/config_policy_utils.c index 70084186b9e2ba29c5142a79854b42c5327e4a24..e831dcd248940922bb40955a4306aa419e25e94c 100644 --- a/frameworks/config_policy/src/config_policy_utils.c +++ b/frameworks/config_policy/src/config_policy_utils.c @@ -18,6 +18,11 @@ #include #include +#include "config_policy_impl.h" +#ifndef OHOS_LITE +#include "param/sys_param.h" +#endif + void FreeCfgFiles(CfgFiles *res) { if (res == NULL) { @@ -49,6 +54,14 @@ static void GetCfgDirRealPolicyValue(CfgDir *res) if (res == NULL) { return; } +#ifndef OHOS_LITE + unsigned int len = 0; + (void)SystemGetParameter(CUST_KEY_POLICY_LAYER, NULL, &len); + if (len > 0 && (res->realPolicyValue = calloc(len, 1))) { + (void)SystemGetParameter(CUST_KEY_POLICY_LAYER, res->realPolicyValue, &len); + return; + } +#endif res->realPolicyValue = strdup("/system:/chipset:/sys_prod:/chip_prod"); } diff --git a/interfaces/innerkits/include/config_policy_impl.h b/interfaces/innerkits/include/config_policy_impl.h new file mode 100644 index 0000000000000000000000000000000000000000..24bc630430d67935f52a4c04b1bf8fa753966609 --- /dev/null +++ b/interfaces/innerkits/include/config_policy_impl.h @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2022 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 CUSTOMIZATION_CONFIG_POLICY_IMPL_H +#define CUSTOMIZATION_CONFIG_POLICY_IMPL_H + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif +#endif // __cplusplus + +// these name is used for write data, init may use it +#define CUST_KEY_POLICY_LAYER "const.cust.config_dir_layer" + +#ifdef __cplusplus +#if __cplusplus +} +#endif +#endif // __cplusplus + +#endif // CUSTOMIZATION_CONFIG_POLICY_IMPL_H \ No newline at end of file