From 538141ecb8fdd57b0446939893e8e8aa364bebd9 Mon Sep 17 00:00:00 2001
From: Esben Haabendal <esben@geanix.com>
Date: Thu, 9 Mar 2023 19:05:11 +0100
Subject: [PATCH] openharmony-standard: Run dsoftbus as systemd service

Signed-off-by: Esben Haabendal <esben@geanix.com>
---
 .../openharmony/files/dsoftbus.service        | 22 +++++++++++++++----
 .../openharmony/files/openharmony-preinit     | 10 ---------
 2 files changed, 18 insertions(+), 14 deletions(-)

diff --git a/recipes-openharmony/openharmony/files/dsoftbus.service b/recipes-openharmony/openharmony/files/dsoftbus.service
index d9728659..dc8301aa 100644
--- a/recipes-openharmony/openharmony/files/dsoftbus.service
+++ b/recipes-openharmony/openharmony/files/dsoftbus.service
@@ -1,10 +1,24 @@
 [Unit]
-Description=OpenHarmony DSoftBus services
+Description=OpenHarmony DSoftBus services (SA: 1401 4700)
+Requires=samgr.service
+After=samgr.service
+# Logging to hilogd, but seems to work without it
+Wants=hilogd.service
+After=hilogd.service
+# Requires SA: 3299
+Wants=foundation.service
+# Requires SA: 3510
+Wants=huks.service
+# Requires SA: 4701
+Wants=deviceauth.service
 
 [Service]
-Type=oneshot
-ExecStart=/bin/echo "OpenHarmony DSoftBus Service"
-RemainAfterExit=yes
+Type=notify
+User=system
+Group=system
+SupplementaryGroups=shell
+LimitNICE=40
+ExecStart=/usr/bin/sa_main /system/profile/softbus_server.xml
 
 [Install]
 WantedBy=multi-user.target
diff --git a/recipes-openharmony/openharmony/files/openharmony-preinit b/recipes-openharmony/openharmony/files/openharmony-preinit
index b4d3eb15..0276838c 100644
--- a/recipes-openharmony/openharmony/files/openharmony-preinit
+++ b/recipes-openharmony/openharmony/files/openharmony-preinit
@@ -132,16 +132,6 @@ if systemctl -q is-enabled weston.service; then
 	sleep "$STARTUP_CMD_SLEEP"
 fi
 
-# "name" : "softbus_server",
-# "path" : ["/system/bin/sa_main", "/system/profile/softbus_server.xml"],
-# "uid" : "system",
-# "gid" : ["system", "shell"]
-if systemctl -q is-enabled dsoftbus.service; then
-	echo >/dev/console "Starting OpenHarmony dsoftbus service"
-	su system -c '/system/bin/sa_main /system/profile/softbus_server.xml &' # SA: 1401 4700 | Required SA: 3299
-	sleep "$STARTUP_CMD_SLEEP"
-fi
-
 # trigger: not used?
 #sa_main /system/profile/dps_service.xml & # SA: 1401 180 3502
 #sleep "$STARTUP_CMD_SLEEP"
-- 
GitLab