From 7563de2f2c07140b821542dd5dba6e186662934e Mon Sep 17 00:00:00 2001 From: Robert Drab <robert.drab@huawei.com> Date: Mon, 4 Jul 2022 13:00:01 +0200 Subject: [PATCH] ohos_param_service: Split out from the unused OHOS Init service In OpenHarmony 3.0 Param Service is a part of the whole Init system. This service is required by many other services. Therefore we have to split out the service as an independent from Init when Init is not used. Closes: https://gitlab.eclipse.org/eclipse/oniro-core/meta-openharmony/-/issues/28 Signed-off-by: Robert Drab <robert.drab@huawei.com> --- .../ohos_param_service.c | 33 +++++++ .../ohos_param_service.patch | 99 +++++++++++++++++++ .../openharmony/openharmony-standard_3.0.bb | 3 + 3 files changed, 135 insertions(+) create mode 100644 recipes-openharmony/openharmony/openharmony-standard-3.0/ohos_param_service.c create mode 100644 recipes-openharmony/openharmony/openharmony-standard-3.0/ohos_param_service.patch diff --git a/recipes-openharmony/openharmony/openharmony-standard-3.0/ohos_param_service.c b/recipes-openharmony/openharmony/openharmony-standard-3.0/ohos_param_service.c new file mode 100644 index 0000000..d6e44d6 --- /dev/null +++ b/recipes-openharmony/openharmony/openharmony-standard-3.0/ohos_param_service.c @@ -0,0 +1,33 @@ +/* + * SPDX-FileCopyrightText: Huawei Inc. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include <signal.h> +#include <init_log.h> +#include <init_param.h> + +void sig_handler(int signum) { + INIT_LOGI("Stopping param service...") + StopParamService(); +} + +int main(int argc, char **argv) +{ + struct sigaction action = { 0 }; + + InitParamService(); + LoadDefaultParams("/system/etc/ohos.para"); + + action.sa_handler = sig_handler; + sigaction(SIGTERM, &action, NULL); + sigaction(SIGINT, &action, NULL); + + // Following call spins up libuv event loop that will keep service running + INIT_LOGI("Starting param service...") + StartParamService(); + + return 0; +} + diff --git a/recipes-openharmony/openharmony/openharmony-standard-3.0/ohos_param_service.patch b/recipes-openharmony/openharmony/openharmony-standard-3.0/ohos_param_service.patch new file mode 100644 index 0000000..3e95bc3 --- /dev/null +++ b/recipes-openharmony/openharmony/openharmony-standard-3.0/ohos_param_service.patch @@ -0,0 +1,99 @@ +# SPDX-FileCopyrightText: Huawei Inc. +# +# SPDX-License-Identifier: Apache-2.0 + +ohos_param_service: Add to build system + +In OpenHarmony 3.0 Param Service is a part of the whole Init system. This +service is required by many other services. Therefore we have to split out +the service as an independent from Init when Init is not used. + +Signed-off-by: Robert Drab <robert.drab@huawei.com> +Upstream-Status: Inappropriate + +diff --git a/services/BUILD.gn b/services/BUILD.gn +index 1994c2ef..95867aa2 100644 +--- a/services/BUILD.gn ++++ b/services/BUILD.gn +@@ -85,6 +85,25 @@ if (defined(ohos_lite)) { + } else { + import("//build/ohos.gni") + ++ ohos_executable("ohos_param_service") { ++ sources = [ "param/src/ohos_param_service.c" ] ++ include_dirs = [ ++ "//base/startup/init_lite/services/include/param", ++ "//base/startup/init_lite/services/log", ++ "//third_party/cJSON", ++ ] ++ deps = [ ++ "//base/startup/init_lite/services/log:init_log", ++ "//base/startup/init_lite/services/param:paramservice", ++ ] ++ install_images = [ ++ "system", ++ "updater", ++ ] ++ install_enable = true ++ part_name = "startup_l2" ++ } ++ + ohos_executable("init") { + sources = [ + "src/device.c", +@@ -132,6 +151,7 @@ if (defined(ohos_lite)) { + + group("startup_init") { + deps = [ ++ ":ohos_param_service", + ":init", + ":init_etc", + "//base/startup/init_lite/interfaces/innerkits/socket:libsocket", +diff --git a/services/param/BUILD.gn b/services/param/BUILD.gn +index 07e1d278..ba420b66 100644 +--- a/services/param/BUILD.gn ++++ b/services/param/BUILD.gn +@@ -83,7 +83,7 @@ ohos_executable("getparam") { + "//third_party/cJSON:cjson_static", + ] + install_enable = true +- part_name = "init" ++ part_name = "startup_l2" + } + + ohos_executable("setparam") { +@@ -100,5 +100,5 @@ ohos_executable("setparam") { + "//third_party/cJSON:cjson_static", + ] + install_enable = true +- part_name = "init" ++ part_name = "startup_l2" + } +diff --git a/services/param/service/param_service.c b/services/param/service/param_service.c +index cd5d93be..03a10ae0 100644 +--- a/services/param/service/param_service.c ++++ b/services/param/service/param_service.c +@@ -131,7 +131,11 @@ static int ProcessParamSet(const RequestMsg *msg) + ret = WritePersistParam(info[0].value, info[1].value); + PARAM_CHECK(ret == 0, return ret, "Failed to set param"); + // notify event to process trigger ++// TODO: add some flag or something instead of if 0 ++// The following call is a part of OpenHarmony init system ++#if 0 + PostTrigger(EVENT_PROPERTY, msg->content, msg->contentSize); ++#endif + return 0; + } + +@@ -267,7 +271,11 @@ int SystemWriteParam(const char *name, const char *value) + PARAM_CHECK(ret == 0, return ret, "Failed to set persist param %s", name); + + // notify event to process trigger ++// TODO: add some flag or something instead of if 0 ++// The following call is a part of OpenHarmony init system ++#if 0 + PostParamTrigger(name, value); ++#endif + return ret; + } + diff --git a/recipes-openharmony/openharmony/openharmony-standard_3.0.bb b/recipes-openharmony/openharmony/openharmony-standard_3.0.bb index 637708a..53f36be 100644 --- a/recipes-openharmony/openharmony/openharmony-standard_3.0.bb +++ b/recipes-openharmony/openharmony/openharmony-standard_3.0.bb @@ -64,6 +64,9 @@ SRC_URI += "file://xf86drm.c-Add-drmWaitVBlank-hack.patch;patchdir=${S}/third_pa SRC_URI += "file://graphic-standard-Add-missing-entry-for-libwms_client.patch;patchdir=${S}/foundation/graphic/standard" +SRC_URI += "file://ohos_param_service.c;subdir=${S}/base/startup/init_lite/services/param/src" +SRC_URI += "file://ohos_param_service.patch;patchdir=${S}/base/startup/init_lite" + inherit python3native gn_base ptest B = "${S}/out/ohos-arm-release" -- GitLab