From ca3b1aaf393e3bcc212b7c778e06f2d1b4ee3e37 Mon Sep 17 00:00:00 2001
From: Esben Haabendal <esben@geanix.com>
Date: Wed, 15 Mar 2023 14:57:36 +0100
Subject: [PATCH] openharmony-standard: Move default parameter values to
 ohos.para

This simplifies initialization, by having param_service starting up with all the
default parameter values instead of setting them manually in different places.

Signed-off-by: Esben Haabendal <esben@geanix.com>
---
 .../openharmony/files/faultloggerd.service    |  2 -
 .../openharmony/files/hdcd.service            |  3 --
 .../openharmony/files/ohos.para               | 54 +++++++++++++++++++
 .../openharmony/files/openharmony-preinit     |  3 --
 .../openharmony/openharmony-standard_3.0.bb   |  3 ++
 5 files changed, 57 insertions(+), 8 deletions(-)
 create mode 100644 recipes-openharmony/openharmony/files/ohos.para

diff --git a/recipes-openharmony/openharmony/files/faultloggerd.service b/recipes-openharmony/openharmony/files/faultloggerd.service
index a551c141..b9fb1811 100644
--- a/recipes-openharmony/openharmony/files/faultloggerd.service
+++ b/recipes-openharmony/openharmony/files/faultloggerd.service
@@ -3,8 +3,6 @@ Description=OpenHarmony FaultLogger daemon
 
 [Service]
 Type=notify
-# UserType::OVERSEAS_COMMERCIAL
-ExecStartPre=setparam ro.logsystem.usertype 6
 ExecStartPre=!install -o root -g system -m 0755 -d /run/openharmony/faultlogger
 ExecStartPre=!install -o system -g log -m 0770 -d /data/log
 ExecStartPre=!install -o system -g system -m 0770 -d /data/log/faultlog
diff --git a/recipes-openharmony/openharmony/files/hdcd.service b/recipes-openharmony/openharmony/files/hdcd.service
index 1980879d..2c4f297f 100644
--- a/recipes-openharmony/openharmony/files/hdcd.service
+++ b/recipes-openharmony/openharmony/files/hdcd.service
@@ -7,9 +7,6 @@ After=param.service
 
 [Service]
 Type=exec
-ExecStartPre=setparam persist.hdc.port 35000
-ExecStartPre=setparam persist.hdc.root 1
-ExecStartPre=setparam ro.hdc.secure 0
 ExecStart=/usr/bin/hdcd -t -l 3
 
 [Install]
diff --git a/recipes-openharmony/openharmony/files/ohos.para b/recipes-openharmony/openharmony/files/ohos.para
new file mode 100644
index 00000000..249342ef
--- /dev/null
+++ b/recipes-openharmony/openharmony/files/ohos.para
@@ -0,0 +1,54 @@
+# Copyright (c) 2021 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.
+
+build_version = 2.0
+
+hw_sc.build.os.enable=true
+hw_sc.build.os.apiversion=6
+hw_sc.build.os.version=3.0.1
+hw_sc.build.os.devicetype=headless
+hw_sc.build.os.releasetype=Canary1
+
+ro.actionable_compatible_property.enabled=false
+ro.postinstall.fstab.prefix=/system
+ro.secure=1
+security.perf_harden=1
+ro.allow.mock.location=0
+ro.debuggable=1
+ro.build.characteristics=default
+
+# There is some kind of special handling if this is "OHOS"
+ro.product.model=OHOS
+ro.product.name=OpenHarmony 3.0.1
+ro.product.locale=en-US
+
+# 1: COMMERCIAL
+# 2: FANS 
+# 3: BETA
+# 4: TEST
+# 5: OVERSEAS_BETA
+# 6: OVERSEAS_COMMERCIAL
+ro.logsystem.usertype=4
+
+# user: General public
+# userdebug: like user, but with root
+# eng: build for testing ROMS not for public
+ro.build.type=user
+
+persist.sys.usb.config=hdc
+
+ro.hdc.secure=0
+persist.hdc.port=35000
+persist.hdc.root=1
+
+persist.ace.trace.enabled=0
diff --git a/recipes-openharmony/openharmony/files/openharmony-preinit b/recipes-openharmony/openharmony/files/openharmony-preinit
index 48a45dce..8307d528 100644
--- a/recipes-openharmony/openharmony/files/openharmony-preinit
+++ b/recipes-openharmony/openharmony/files/openharmony-preinit
@@ -78,6 +78,3 @@ mkdir -p /data/log/faultlog/temp
 mkdir -p /usr/lib/dri
 
 chmod -R 777 /data
-
-# 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/openharmony-standard_3.0.bb b/recipes-openharmony/openharmony/openharmony-standard_3.0.bb
index c50b3ed6..e2b47e1c 100644
--- a/recipes-openharmony/openharmony/openharmony-standard_3.0.bb
+++ b/recipes-openharmony/openharmony/openharmony-standard_3.0.bb
@@ -219,6 +219,7 @@ symlink_python3() {
 
 SRC_URI += "file://start_service file://stop_service"
 SRC_URI += "file://param"
+SRC_URI += "file://ohos.para"
 
 do_install () {
     OHOS_PACKAGE_OUT_DIR="${B}/packages/${OHOS_PRODUCT_PLATFORM_TYPE}"
@@ -248,6 +249,8 @@ do_install () {
     mkdir -p ${D}${sysconfdir}/openharmony
     cp -r  ${OHOS_PACKAGE_OUT_DIR}/system/etc/* ${D}${sysconfdir}/openharmony
     ln -sfT ..${sysconfdir}/openharmony ${D}/system/etc
+    # Overwrite the OpenHarmony provideded parameter file
+    install -m 0644 -t ${D}${sysconfdir}/openharmony ${WORKDIR}/ohos.para
 
     # OpenHarmony font files
     mkdir -p ${D}${datadir}/fonts/openharmony
-- 
GitLab