From 96703b7708e6ec7ea7dbc075256c169c6c6914c6 Mon Sep 17 00:00:00 2001
From: Esben Haabendal <esben@geanix.com>
Date: Fri, 3 Mar 2023 14:50:08 +0100
Subject: [PATCH] openharmony-standard: Run param_service as systemd service

Signed-off-by: Esben Haabendal <esben@geanix.com>
---
 .../openharmony/files/openharmony-preinit            | 12 ------------
 .../openharmony/files/openharmony-preinit.service    |  2 ++
 recipes-openharmony/openharmony/files/param.service  |  8 +++++---
 3 files changed, 7 insertions(+), 15 deletions(-)

diff --git a/recipes-openharmony/openharmony/files/openharmony-preinit b/recipes-openharmony/openharmony/files/openharmony-preinit
index ad31ecde..f7eb48ef 100644
--- a/recipes-openharmony/openharmony/files/openharmony-preinit
+++ b/recipes-openharmony/openharmony/files/openharmony-preinit
@@ -92,24 +92,12 @@ if [ -c /dev/dri/card0 ]; then
 	chmod 666 /dev/dri/card0
 fi
 
-install -m 755 -d /dev/unix/socket
-
 export XDG_RUNTIME_DIR=/data/weston
 export XKB_CONFIG_ROOT=/etc/openharmony/xkb
 export XKB_CONFIG_EXTRA_PATH=/etc/openharmony/xkb
 
 STARTUP_CMD_SLEEP=4
 
-# trigger: part of the init process itself
-if systemctl -q is-enabled param.service; then
-	/system/bin/param_service &
-	sleep "$STARTUP_CMD_SLEEP"
-        while [ "$(setparam foobar 42)" != "setparam foobar 42 success" ] ; do
-            echo "param_service not ready"
-            sleep 1
-        done
-fi
-
 # Explicitly set default value to silence error message about parameter not being set
 setparam persist.ace.trace.enabled 0
 
diff --git a/recipes-openharmony/openharmony/files/openharmony-preinit.service b/recipes-openharmony/openharmony/files/openharmony-preinit.service
index 3b3fc017..ca384e6a 100644
--- a/recipes-openharmony/openharmony/files/openharmony-preinit.service
+++ b/recipes-openharmony/openharmony/files/openharmony-preinit.service
@@ -1,5 +1,7 @@
 [Unit]
 Description=OpenHarmony pre-init setup
+After=param.service
+Requires=param.service
 
 [Service]
 Type=oneshot
diff --git a/recipes-openharmony/openharmony/files/param.service b/recipes-openharmony/openharmony/files/param.service
index aa8b6ce6..5a26b545 100644
--- a/recipes-openharmony/openharmony/files/param.service
+++ b/recipes-openharmony/openharmony/files/param.service
@@ -2,9 +2,11 @@
 Description=OpenHarmony Param Service
 
 [Service]
-Type=oneshot
-ExecStart=/bin/echo "OpenHarmony Param Service"
-RemainAfterExit=yes
+Type=notify
+ExecStartPre=install -m 755 -d /dev/unix/socket
+ExecStartPre=install -m 755 -d /data/param
+ExecStartPre=install -m 755 -d /dev/__parameters__
+ExecStart=/usr/bin/param_service
 
 [Install]
 WantedBy=multi-user.target
-- 
GitLab