OpenHarmony Framework层开发笔记
  EzIAYXiV4scN 2023年11月02日 45 0

OH源码版本: OpenHarmony-v3.2-Beta5

2023.04.04

由于需要裁剪系统APP,原本想法是在 /applications/standard/hap/BUILD.gn增加一个part的但是最后发现vendor下有现成的裁剪APP的json配置文件,所以使用git reset还原了 /applications/standard/hap/仓库下的修改导致 此仓库下的所有hap都变成了一个空文件,需要再次调用”git lfs pul“才会将所有安装包全部下载下来。

BUILD.gn就是编译的模块

bundle.json声明部件也就是compent part_name 均是指代部件

边距相关:

padding指代内边距,指的是组件内部元素和组件的四边的距离

margin指代外边距,指的是当前的组件和其他组件之间的距离

/foundation/systemabilitymgr/safwk/etc/profile/foundation.cfg

/foundation/systemabilitymgr/safwk/services/safwk/

构建sa_main sa_main 可以创建service 进程主要有以下进程是sa_main创建的

AbilityManagerService是sa_main 进程通过启动foundation服务启动的

samgr /foundation/systemabilitymgr/samgr/services/samgr/

sa_main /foundation/systemabilitymgr/safwk/services/safwk/

以下xml代表的服务均是由sa_main启动的:

accessibility.xml               locationhub.xml
accesstoken_service.xml         media_service.xml
accountmgr.xml                  memmgrservice.xml
audio_policy.xml                msdp.xml
av_session.xml                  multimodalinput.xml
bgtaskmgr_service.xml           netmanager.xml
bluetooth_service.xml           netsysnative.xml
camera_service.xml              param_watcher.xml
cert_manager_service.xml        pasteboard_service.xml
d-bms.xml                       pinauth.xml
dcamera.xml                     privacy_service.xml
devattest_service.xml           pulseaudio.xml
device_manager.xml              quick_fix.xml
device_usage_stats_service.xml  resource_schedule_service.xml
deviceinfoservice.xml           screenlock_server.xml
dhardware.xml                   sensors.xml
distributeddata.xml             softbus_server.xml
distributedfiledaemon.xml       storage_manager.xml
distributedsched.xml            sys_installer_sa.xml
distributedsched_trust.xml      telephony.xml
download_server.xml             time_service.xml
dscreen.xml                     token_sync_service.xml
dslm_service.xml                ui_service.xml
edm.xml                         updater_sa.xml
foundation.xml                  usb_service.xml
foundation_trust.xml            useriam.xml
hidumper_service.xml            wallpaper_service.xml
huks_service.xml                wifi_manager_service.xml
inputmethod_service.xml

service_registrysystem_ability_manager(继承自system_ability_manager_stub )是一对代理和服务端主要负责服务的注册获取,和android的ServiceManager功能是一样的

系统的服务均是由sa_main进程启动并加载相应的so库运行起来的

/foundation/systemabilitymgr/samgr/interfaces/innerkits/samgr_proxy/include/system_ability_definition.h

1. 打开OpenHarmony的源码log的所有打印

param set persist.sys.hilog.debug.on true
param set hilog.loggable.global D //一次性的

要想永久打开可以在代码中加入以下修改:

/base/hiviewdfx/hilog/仓库
diff --git a/services/hilogd/etc/hilog.para b/services/hilogd/etc/hilog.para
index 83c775e..9d6512c 100644
--- a/services/hilogd/etc/hilog.para
+++ b/services/hilogd/etc/hilog.para
@@ -12,12 +12,12 @@
 # limitations under the License.
 
 
-hilog.private.on=true
+hilog.private.on=false
 hilog.debug.on=false
 persist.sys.hilog.kmsg.on=true
-persist.sys.hilog.debug.on=false
+persist.sys.hilog.debug.on=true
 hilog.flowctrl.proc.on=false
 hilog.flowctrl.domain.on=false
 
-hilog.loggable.global=I
-hilog.buffersize.global=262144
\ No newline at end of file
+hilog.loggable.global=D
+hilog.buffersize.global=16777216
\ No newline at end of file

要打开Init进程的log可以加入下面的修改:

2.默认设置永不息屏

3.1 beta5 base仓库
diff --git a/services/native/include/power_state_machine.h b/services/native/include/power_state_machine.h
index 2fa2d59..bed209b 100644
--- a/services/native/include/power_state_machine.h
+++ b/services/native/include/power_state_machine.h
@@ -27,7 +27,7 @@
 #include "power_state_machine_info.h"
 #include "running_lock_info.h"
 
-#define DEFAULT_DISPLAY_OFF_TIME    30000
+#define DEFAULT_DISPLAY_OFF_TIME    -1
 #define DEFAULT_SLEEP_TIME          5000
 
 namespace OHOS {
 

3.2 release base仓库
diff --git a/powermgr/power_manager/services/native/profile/power_mode_config.xml b/powermgr/power_manager/services/native/profile/power_mode_config.xml
index c801bac6..ecdac07e 100644
--- a/powermgr/power_manager/services/native/profile/power_mode_config.xml
+++ b/powermgr/power_manager/services/native/profile/power_mode_config.xml
@@ -32,7 +32,7 @@
 -->
 <switch_proxy version="1">
     <proxy id="600">
-        <switch id="101" value="30000" recover_flag="0"/>
+        <switch id="101" value="-1" recover_flag="0"/>

3.OpenHarmony所有的子系统定义

/build/subsystem_config.json

编译OpenHarmony所需要的依赖包定义在/build/scripts/build_package_list.json

4.新建项目配置

4.1 拷贝rk3568项目到新建项目的目录

mkdir -p vendor/guide/zp37a
cp -rf vendor/hihope/rk3568/* vendor/guide/zp37a/

4.2 加入以下修改:

From 2234b161845857d174c7c3a358c65d0286eca615 Mon Sep 17 00:00:00 2001
From: yuwei <yuw@guideir.com>
Date: Mon, 3 Apr 2023 10:01:27 +0800
Subject: [PATCH] feat: change rk3568 project to zp37a project

---
 zp37a/audio/BUILD.gn                               |  4 ++--
 zp37a/config.json                                  |  8 ++++----
 zp37a/default_app_config/BUILD.gn                  |  2 +-
 zp37a/etc/BUILD.gn                                 |  8 ++++----
 .../{hardware_rk3568.para => hardware_zp37a.para}  |  0
 .../{product_rk3568.para => product_zp37a.para}    |  0
 zp37a/ohos.build                                   | 14 +++++++-------
 zp37a/preinstall-config/BUILD.gn                   |  8 ++++----
 zp37a/product.gni                                  |  2 +-
 zp37a/resourceschedule/BUILD.gn                    | 10 +++++-----
 10 files changed, 28 insertions(+), 28 deletions(-)
 rename zp37a/etc/para/{hardware_rk3568.para => hardware_zp37a.para} (100%)
 rename zp37a/etc/para/{product_rk3568.para => product_zp37a.para} (100%)

diff --git a/zp37a/audio/BUILD.gn b/zp37a/audio/BUILD.gn
index dbf158c..fd04cd7 100644
--- a/zp37a/audio/BUILD.gn
+++ b/zp37a/audio/BUILD.gn
@@ -16,9 +16,9 @@ import("//build/ohos.gni")
 ohos_prebuilt_etc("audio_policy_config") {
   if (target_cpu == "arm64") {
     source =
-        "//vendor/hihope/${product_name}/audio/arm64/audio_policy_config.xml"
+        "//vendor/${product_company}/${product_name}/audio/arm64/audio_policy_config.xml"
   } else {
-    source = "//vendor/hihope/${product_name}/audio/arm/audio_policy_config.xml"
+    source = "//vendor/${product_company}/${product_name}/audio/arm/audio_policy_config.xml"
   }
   subsystem_name = "hdf"
   relative_install_dir = "audio"
diff --git a/zp37a/config.json b/zp37a/config.json
index 5ab86fc..b31716f 100755
--- a/zp37a/config.json
+++ b/zp37a/config.json
@@ -1,11 +1,11 @@
 {
-  "product_name": "rk3568",
-  "device_company": "rockchip",
-  "device_build_path": "device/board/hihope/rk3568",
+  "product_name": "zp37a",
+  "device_company": "guide",
+  "device_build_path": "device/board/guide/zp37a",
   "target_cpu": "arm",
   "type": "standard",
   "version": "3.0",
-  "board": "rk3568",
+  "board": "zp37a",
   "api_version": 8,
   "enable_ramdisk": true,
   "build_selinux": true,
diff --git a/zp37a/default_app_config/BUILD.gn b/zp37a/default_app_config/BUILD.gn
index 33d4559..0e0b797 100755
--- a/zp37a/default_app_config/BUILD.gn
+++ b/zp37a/default_app_config/BUILD.gn
@@ -16,7 +16,7 @@ import("//build/ohos.gni")
 ohos_prebuilt_etc("default_app_detail_config") {
   source = "./default_app.json"
   relative_install_dir = "app"
-  part_name = "product_rk3568"
+  part_name = "product_${product_name}"
 }
 
 group("default_app_config") {
diff --git a/zp37a/etc/BUILD.gn b/zp37a/etc/BUILD.gn
index 8965a06..d53de1d 100644
--- a/zp37a/etc/BUILD.gn
+++ b/zp37a/etc/BUILD.gn
@@ -14,17 +14,17 @@
 import("//build/ohos.gni")
 
 ohos_prebuilt_etc("para_for_chip_prod") {
-  source = "./para/hardware_rk3568.para"
+  source = "./para/hardware_zp37a.para"
   install_images = [ chip_prod_base_dir ]
   relative_install_dir = "para"
-  part_name = "product_rk3568"
+  part_name = "product_${product_name}"
 }
 
 ohos_prebuilt_etc("para_for_sys_prod") {
-  source = "./para/product_rk3568.para"
+  source = "./para/product_zp37a.para"
   install_images = [ sys_prod_base_dir ]
   relative_install_dir = "para"
-  part_name = "product_rk3568"
+  part_name = "product_${product_name}"
 }
 
 group("product_etc_conf") {
diff --git a/zp37a/etc/para/hardware_rk3568.para b/zp37a/etc/para/hardware_zp37a.para
similarity index 100%
rename from zp37a/etc/para/hardware_rk3568.para
rename to zp37a/etc/para/hardware_zp37a.para
diff --git a/zp37a/etc/para/product_rk3568.para b/zp37a/etc/para/product_zp37a.para
similarity index 100%
rename from zp37a/etc/para/product_rk3568.para
rename to zp37a/etc/para/product_zp37a.para
diff --git a/zp37a/ohos.build b/zp37a/ohos.build
index fd7af27..69bc9d2 100644
--- a/zp37a/ohos.build
+++ b/zp37a/ohos.build
@@ -1,14 +1,14 @@
 {
   "parts": {
-    "product_rk3568": {
+    "product_zp37a": {
       "module_list": [
-        "//vendor/hihope/rk3568/default_app_config:default_app_config",
-        "//vendor/hihope/rk3568/image_conf:custom_image_conf",
-        "//vendor/hihope/rk3568/preinstall-config:preinstall-config",
-        "//vendor/hihope/rk3568/resourceschedule:resourceschedule",
-        "//vendor/hihope/rk3568/etc:product_etc_conf"
+        "//vendor/${product_company}/${product_name}/default_app_config:default_app_config",
+        "//vendor/${product_company}/${product_name}/image_conf:custom_image_conf",
+        "//vendor/${product_company}/${product_name}/preinstall-config:preinstall-config",
+        "//vendor/${product_company}/${product_name}/resourceschedule:resourceschedule",
+        "//vendor/${product_company}/${product_name}/etc:product_etc_conf"
       ]
     }
   },
-  "subsystem": "product_hihope"
+  "subsystem": "product_guide"
 }
diff --git a/zp37a/preinstall-config/BUILD.gn b/zp37a/preinstall-config/BUILD.gn
index b99999c..87f5761 100644
--- a/zp37a/preinstall-config/BUILD.gn
+++ b/zp37a/preinstall-config/BUILD.gn
@@ -16,25 +16,25 @@ import("//build/ohos.gni")
 ohos_prebuilt_etc("install_list_config") {
   source = "./install_list.json"
   relative_install_dir = "app"
-  part_name = "product_rk3568"
+  part_name = "product_${product_name}"
 }
 
 ohos_prebuilt_etc("uninstall_list_config") {
   source = "./uninstall_list.json"
   relative_install_dir = "app"
-  part_name = "product_rk3568"
+  part_name = "product_${product_name}"
 }
 
 ohos_prebuilt_etc("install_list_capability_config") {
   source = "./install_list_capability.json"
   relative_install_dir = "app"
-  part_name = "product_rk3568"
+  part_name = "product_${product_name}"
 }
 
 ohos_prebuilt_etc("install_list_permissions_config") {
   source = "./install_list_permissions.json"
   relative_install_dir = "app"
-  part_name = "product_rk3568"
+  part_name = "product_${product_name}"
 }
 
 group("preinstall-config") {
diff --git a/zp37a/product.gni b/zp37a/product.gni
index 60e3959..f4e9019 100644
--- a/zp37a/product.gni
+++ b/zp37a/product.gni
@@ -11,4 +11,4 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-import("//device/board/hihope/${device_name}/device.gni")
+import("//device/board/${product_company}/${device_name}/device.gni")
diff --git a/zp37a/resourceschedule/BUILD.gn b/zp37a/resourceschedule/BUILD.gn
index 6f04165..d77ad2d 100644
--- a/zp37a/resourceschedule/BUILD.gn
+++ b/zp37a/resourceschedule/BUILD.gn
@@ -18,7 +18,7 @@ ohos_prebuilt_etc("res_sched_config") {
   install_enable = true
   install_images = [ "vendor" ]
   module_install_dir = "etc/ressched"
-  part_name = "product_rk3568"
+  part_name = "product_${product_name}"
 }
 
 ohos_prebuilt_etc("res_sched_plugin_switch") {
@@ -26,7 +26,7 @@ ohos_prebuilt_etc("res_sched_plugin_switch") {
   install_enable = true
   install_images = [ "vendor" ]
   module_install_dir = "etc/ressched"
-  part_name = "product_rk3568"
+  part_name = "product_${product_name}"
 }
 
 ohos_prebuilt_etc("cgroup_action_config") {
@@ -34,7 +34,7 @@ ohos_prebuilt_etc("cgroup_action_config") {
   install_enable = true
   install_images = [ "vendor" ]
   module_install_dir = "etc/cgroup_sched"
-  part_name = "product_rk3568"
+  part_name = "product_${product_name}"
 }
 
 ohos_prebuilt_etc("socperf_boost_config") {
@@ -42,7 +42,7 @@ ohos_prebuilt_etc("socperf_boost_config") {
   install_enable = true
   install_images = [ "vendor" ]
   module_install_dir = "etc/soc_perf"
-  part_name = "product_rk3568"
+  part_name = "product_${product_name}"
 }
 
 ohos_prebuilt_etc("socperf_resource_config") {
@@ -50,7 +50,7 @@ ohos_prebuilt_etc("socperf_resource_config") {
   install_enable = true
   install_images = [ "vendor" ]
   module_install_dir = "etc/soc_perf"
-  part_name = "product_rk3568"
+  part_name = "product_${product_name}"
 }
 
 group("resourceschedule") {
-- 
2.25.1

4.3 拷贝板子配置到新建项目

mkdir  -p device/board/guide/zp37a
cp -rf  device/board/hihope/rk3568/* device/board/guide/zp37a

4.4 加入如下修改

From 4d8532e1c03926f57e534c9c5929a3b7814d0029 Mon Sep 17 00:00:00 2001
From: yuwei <yuw@guideir.com>
Date: Mon, 3 Apr 2023 09:59:06 +0800
Subject: [PATCH] feat:change rk3568 project to zp37a project

---
 zp37a/BUILD.gn               |   4 +-
 zp37a/bootanimation/BUILD.gn |   2 +-
 zp37a/kernel/BUILD.gn        |   2 +-
 zp37a/kernel/build_kernel.sh |   4 +-
 zp37a/kernel/make-boot.sh    |  31 ++++++++
 zp37a/kernel/make-ohos.sh    | 135 +++++++++++++++++++++++++++++++++++
 zp37a/ohos.build             |   6 +-
 7 files changed, 176 insertions(+), 8 deletions(-)
 create mode 100755 zp37a/kernel/make-boot.sh
 create mode 100755 zp37a/kernel/make-ohos.sh

diff --git a/zp37a/BUILD.gn b/zp37a/BUILD.gn
index a233fa6..3d4f5e2 100644
--- a/zp37a/BUILD.gn
+++ b/zp37a/BUILD.gn
@@ -14,8 +14,8 @@
 import("//build/ohos.gni")
 import("device.gni")
 
-print("rk3568_group in")
-group("rk3568_group") {
+print("${product_name} in")
+group("${product_name}_group") {
   deps = [
     "cfg:init_configs",
     "distributedhardware:distributedhardware",
diff --git a/zp37a/bootanimation/BUILD.gn b/zp37a/bootanimation/BUILD.gn
index c540e5c..6345319 100755
--- a/zp37a/bootanimation/BUILD.gn
+++ b/zp37a/bootanimation/BUILD.gn
@@ -12,7 +12,7 @@
 # limitations under the License.
 import("//build/ohos.gni")
 
-BOOTANIMATION_DIR = "//device/board/hihope/${device_name}/bootanimation"
+BOOTANIMATION_DIR = "//device/board/${product_company}/${device_name}/bootanimation"
 
 ohos_prebuilt_etc("bootanimation-720x1280") {
   source = "$BOOTANIMATION_DIR/bootanimation-720x1280.raw"
diff --git a/zp37a/kernel/BUILD.gn b/zp37a/kernel/BUILD.gn
index 3e9ca7f..864121b 100755
--- a/zp37a/kernel/BUILD.gn
+++ b/zp37a/kernel/BUILD.gn
@@ -25,7 +25,7 @@ action("kernel") {
   args = [
     rebase_path(kernel_build_script_dir, root_build_dir),
     rebase_path("$root_build_dir/packages/phone/images"),
-    rebase_path("//device/board/hihope/$device_name"),
+    rebase_path("//device/board/$product_company/$device_name"),
     product_path,
     rebase_path("$root_build_dir/../.."),
     device_company,
diff --git a/zp37a/kernel/build_kernel.sh b/zp37a/kernel/build_kernel.sh
index 4bd1e65..a635422 100755
--- a/zp37a/kernel/build_kernel.sh
+++ b/zp37a/kernel/build_kernel.sh
@@ -85,6 +85,8 @@ cp ${3}/loader/MiniLoaderAll.bin ${2}/MiniLoaderAll.bin
 cp ${3}/loader/uboot.img ${2}/uboot.img
 cp ${3}/loader/config.cfg ${2}/config.cfg
 popd
-
+echo "cp -rf ${ROOT_DIR}/device/board/${PRODUCT_COMPANY}/${DEVICE_NAME}/kernel/make-boot.sh ${KERNEL_SRC_TMP_PATH}"
+cp -rf ${ROOT_DIR}/device/board/${PRODUCT_COMPANY}/${DEVICE_NAME}/kernel/make-boot.sh ${KERNEL_SRC_TMP_PATH}
+cp -rf ${ROOT_DIR}/device/board/${PRODUCT_COMPANY}/${DEVICE_NAME}/kernel/make-ohos.sh ${KERNEL_SRC_TMP_PATH}
 ../kernel/src_tmp/linux-5.10/make-boot.sh ..
 
diff --git a/zp37a/kernel/make-boot.sh b/zp37a/kernel/make-boot.sh
new file mode 100755
index 0000000..8ef6edb
--- /dev/null
+++ b/zp37a/kernel/make-boot.sh
@@ -0,0 +1,31 @@
+#!/bin/bash
+
+set -e
+BOOT_LINUX=${1}/kernel/src_tmp/linux-5.10
+OUT_IMAGE=${1}/${DEVICE_NAME}/packages/phone/images/
+IMAGE_SIZE=64  # 64M
+IMAGE_BLOCKS=4096
+
+BUILD_PATH=boot_linux
+EXTLINUX_PATH=${BUILD_PATH}/extlinux
+EXTLINUX_CONF=${EXTLINUX_PATH}/extlinux.conf
+TOYBRICK_DTB=toybrick.dtb
+
+function make_boot_image()
+{
+        blocks=${IMAGE_BLOCKS}
+        block_size=$((${IMAGE_SIZE} * 1024 * 1024 / ${blocks}))
+        echo "blocks = ${blocks}  block_size ${block_size}"
+        if [ "`uname -m`" == "aarch64" ]; then
+                echo y | sudo mke2fs -b ${block_size} -d boot_linux -i 8192 -t ext2 boot_linux.img ${blocks}
+        else
+                genext2fs -B ${blocks} -b ${block_size} -d boot_linux -i 8192 -U boot_linux.img
+        fi
+
+        return $?
+}
+
+cd ${BOOT_LINUX}
+make_boot_image
+cd -
+cp ${BOOT_LINUX}/boot_linux.img ${OUT_IMAGE}
diff --git a/zp37a/kernel/make-ohos.sh b/zp37a/kernel/make-ohos.sh
new file mode 100755
index 0000000..26e0cf9
--- /dev/null
+++ b/zp37a/kernel/make-ohos.sh
@@ -0,0 +1,135 @@
+#!/bin/bash
+
+set -e
+
+export PATH=../../../../prebuilts/clang/ohos/linux-x86_64/llvm/bin/:$PATH
+export PRODUCT_PATH=vendor/${PRODUCT_COMPANY}/${DEVICE_NAME}
+IMAGE_SIZE=64  # 64M
+IMAGE_BLOCKS=4096
+ENABLE_LTO_O0=${3}
+
+CPUs=`sed -n "N;/processor/p" /proc/cpuinfo|wc -l`
+MAKE="make LLVM=1 LLVM_IAS=1 CROSS_COMPILE=../../../../prebuilts/gcc/linux-x86/aarch64/gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-"
+[ "${ENABLE_LTO_O0}" == "enable_lto_O0" ] && MAKE="${MAKE} KCFLAGS=-Wl,--lto-O0"
+BUILD_PATH=boot_linux
+EXTLINUX_PATH=${BUILD_PATH}/extlinux
+EXTLINUX_CONF=${EXTLINUX_PATH}/extlinux.conf
+TOYBRICK_DTB=toybrick.dtb
+if [ ${KBUILD_OUTPUT} ]; then
+	OBJ_PATH=${KBUILD_OUTPUT}/
+fi
+
+ID_MODEL=1
+ID_ARCH=2
+ID_UART=3
+ID_DTB=4
+ID_IMAGE=5
+ID_CONF=6
+model_list=(
+	"TB-RK3568X0   arm64 0xfe660000 rk3568-toybrick-x0-linux  Image rockchip_linux_defconfig"
+	"TB-RK3568X10  arm64 0xfe660000 rk3568-toybrick-x10-linux Image rockchip_linux_defconfig"
+)
+
+
+function help()
+{
+	echo "Usage: ./make-ohos.sh {BOARD_NAME}"
+	echo "e.g."
+	for i in "${model_list[@]}"; do
+		echo "  ./make-ohos.sh $(echo $i | awk '{print $1}')"
+	done
+}
+
+
+function make_extlinux_conf()
+{
+	dtb_path=$1
+	uart=$2
+	image=$3
+	
+	echo "label rockchip-kernel-5.10" > ${EXTLINUX_CONF}
+	echo "	kernel /extlinux/${image}" >> ${EXTLINUX_CONF}
+	echo "	fdt /extlinux/${TOYBRICK_DTB}" >> ${EXTLINUX_CONF}
+	cmdline="append earlycon=uart8250,mmio32,${uart} root=PARTUUID=614e0000-0000-4b53-8000-1d28000054a9 rw rootwait rootfstype=ext4"
+	echo "  ${cmdline}" >> ${EXTLINUX_CONF}
+}
+
+function make_kernel_image()
+{
+	arch=$1
+	conf=$2
+	dtb=$3
+	
+	config_base="arch/${arch}/configs/${conf}"
+	config_frag=""
+	if [ "$GPUDRIVER" == "mesa3d" ]; then 
+		config_frag="../../../../device/soc/rockchip/panfrost.config"
+	fi
+	ARCH=${arch} ./scripts/kconfig/merge_config.sh ${config_base} ${config_frag}
+
+	if [ $? -ne 0 ]; then
+		echo "FAIL: ${MAKE} ARCH=${arch} ${conf}"
+		return -1
+	fi
+
+	${MAKE} ARCH=${arch} ${dtb}.img -j${CPUs}
+	if [ $? -ne 0 ]; then
+		echo "FAIL: ${MAKE} ARCH=${arch} ${dtb}.img"
+		return -2
+	fi
+
+	return 0
+}
+
+function make_ext2_image()
+{
+	blocks=${IMAGE_BLOCKS}
+	block_size=$((${IMAGE_SIZE} * 1024 * 1024 / ${blocks}))
+
+	if [ "`uname -m`" == "aarch64" ]; then
+		echo y | sudo mke2fs -b ${block_size} -d boot_linux -i 8192 -t ext2 boot_linux.img ${blocks}
+	else
+		genext2fs -B ${blocks} -b ${block_size} -d boot_linux -i 8192 -U boot_linux.img
+	fi
+
+	return $?
+}
+
+function make_boot_linux()
+{
+	arch=${!ID_ARCH}
+	uart=${!ID_UART}
+	dtb=${!ID_DTB}
+	image=${!ID_IMAGE}
+	conf=${!ID_CONF}
+	if [ ${arch} == "arm" ]; then
+		dtb_path=arch/arm/boot/dts
+	else
+		dtb_path=arch/arm64/boot/dts/rockchip
+	fi
+
+	rm -rf ${BUILD_PATH}
+	mkdir -p ${EXTLINUX_PATH}
+
+	make_kernel_image ${arch} ${conf} ${dtb}
+	if [ $? -ne 0 ]; then
+		exit 1
+	fi
+	make_extlinux_conf ${dtb_path} ${uart} ${image}
+	cp -f ${OBJ_PATH}arch/${arch}/boot/${image} ${EXTLINUX_PATH}/
+	cp -f ${OBJ_PATH}${dtb_path}/${dtb}.dtb ${EXTLINUX_PATH}/${TOYBRICK_DTB}
+	cp -f logo*.bmp ${BUILD_PATH}/
+	if [ "enable_ramdisk" != "${ramdisk_flag}" ]; then
+		make_ext2_image
+	fi
+}
+
+ramdisk_flag=$2
+found=0
+for i in "${model_list[@]}"; do
+	if [ "$(echo $i | awk '{print $1}')" == "$1" ]; then
+		make_boot_linux $i
+		found=1
+	fi
+done
+
diff --git a/zp37a/ohos.build b/zp37a/ohos.build
index 6e9f26e..85d327a 100755
--- a/zp37a/ohos.build
+++ b/zp37a/ohos.build
@@ -3,9 +3,9 @@
     "parts": {
         "rockchip_products": {
             "module_list": [
-                "//device/board/hihope/${device_name}:rk3568_group",
-                "//vendor/hihope/${product_name}/bluetooth:libbt_vendor",
-                "//vendor/hihope/${product_name}/bluetooth:BCM4362A2.hcd"
+                "//device/board/${product_company}/${product_name}:${product_name}_group",
+                "//vendor/${product_company}/${product_name}/bluetooth:libbt_vendor",
+                "//vendor/${product_company}/${product_name}/bluetooth:BCM4362A2.hcd"
             ],
             "test_list": [
                 "//kernel/linux/build/test:linuxkerneltest"
-- 
2.25.1

device/board/guide/zp37a/wifi/bcmdhd_wifi6/Makefile和 device/board/guide/zp37a/audio_drivers

将以上两个文件中的hihope/rk3568全部替换成 guide/zp37a

使用新建的项目配置发现部分service无法启动比如usb_service 需要加入以下修改:

device 仓库下

diff --git a/board/guide/zp37a/kernel/build_kernel.sh b/board/guide/zp37a/kernel/build_kernel.sh
index 75103ee..555db7e 100755
--- a/board/guide/zp37a/kernel/build_kernel.sh
+++ b/board/guide/zp37a/kernel/build_kernel.sh
@@ -43,14 +43,14 @@ cp -arf ${KERNEL_SOURCE}/* ${KERNEL_SRC_TMP_PATH}/
 cd ${KERNEL_SRC_TMP_PATH}
 
 #HDF patch
-bash ${ROOT_DIR}/drivers/hdf_core/adapter/khdf/linux/patch_hdf.sh ${ROOT_DIR} ${KERNEL_SRC_TMP_PATH} ${KERNEL_PATCH_PATH} ${DEVICE_NAME}
+bash ${ROOT_DIR}/drivers/hdf_core/adapter/khdf/linux/patch_hdf.sh ${ROOT_DIR} ${KERNEL_SRC_TMP_PATH} ${KERNEL_PATCH_PATH} rk3568
 
 #kernel patch
 patch -p1 < ${KERNEL_PATCH}
 
 #newip
 if [ -f $NEWIP_PATCH_FILE ]; then
-bash $NEWIP_PATCH_FILE ${ROOT_DIR} ${KERNEL_SRC_TMP_PATH} ${DEVICE_NAME} linux-5.10
+bash $NEWIP_PATCH_FILE ${ROOT_DIR} ${KERNEL_SRC_TMP_PATH} rk3568 linux-5.10
 fi
 
 cp -rf ${3}/kernel/logo* ${KERNEL_SRC_TMP_PATH}/
@@ -91,4 +91,3 @@ cp -rf ${ROOT_DIR}/device/board/${PRODUCT_COMPANY}/${DEVICE_NAME}/kernel/make-bo
 cp -rf ${ROOT_DIR}/device/board/${PRODUCT_COMPANY}/${DEVICE_NAME}/kernel/make-ohos.sh ${KERNEL_SRC_TMP_PATH}
 
 ../kernel/src_tmp/linux-5.10/make-boot.sh ..

5. 添加编译log

在BUILD.gn里打印只需要使用print即可

6.裁剪系统APP

2023.04.04 由于需要裁剪系统APP,原本想法是在 /applications/standard/hap/BUILD.gn增加一个part的但是最后发现vendor下有现成得裁剪APP的json配置文件,所以使用git reset还原了 /applications/standard/hap/仓库下的修改导致 此仓库下的所有hap都变成了一个空文件,需要再次调用”git lfs pul“才会将所有安装包全部下载下来。

关于SystemUI相关的组件的裁剪可以加入如下修改:

applications/standard/hap仓库下:
     deps +=
         [ "//applications/standard/admin_provisioning:adminprovisioning_hap" ]
   }
+
+  if (defined(guide_disable_unused_systemui_compents) && guide_disable_unused_systemui_compents ) {
+    deps -= [
+      "//applications/standard/hap:dropdownPanel_hap",
+      "//applications/standard/hap:notificationManagement_hap",
+      "//applications/standard/hap:screenLock_hap",
+      "//applications/standard/hap:statusBar_hap",
+      "//applications/standard/hap:volumePanel_hap",
+      "//applications/standard/hap:navigationBar_hap"
+    ]
+  }

关于其他的整包APP可以在如下配置文件中裁剪:

在vendor/OpenHarmony Framework层开发笔记_xml{device_name}/preinstall-config/uninstall_list.json中添加需要裁剪的APP即可,比如润和的rk3568开发板就是

vendor/hihope/rk3568/preinstall-config/uninstall_list.json:

diff --git a/zp37a/preinstall-config/uninstall_list.json b/zp37a/preinstall-config/uninstall_list.json
index 0e0e778..fce2576 100644
--- a/zp37a/preinstall-config/uninstall_list.json
+++ b/zp37a/preinstall-config/uninstall_list.json
@@ -1,4 +1,29 @@
-{
-    "uninstall_list" : [],
-    "recover_list" : []
+{
+    "uninstall_list" : [
+        "/system/app/com.ohos.note",
+        "/system/app/ohos.samples.clock",
+        "/system/app/ohos.samples.airquality",
+        "/system/app/com.example.distributedcalc",
+        "/system/app/ohos.samples.flashlight",
+        "/system/app/ohos.samples.ecg",
+        "/system/app/com.ohos.distributedmusicplayer",
+        "/system/app/com.ohos.callui",
+        "/system/app/com.ohos.mms",
+        "/system/app/com.ohos.contacts",
+        "/system/app/com.ohos.settings.faceauth",
+        "/system/app/com.ohos.adminprovisioning",
+        "/system/app/com.ohos.filepicker",
+        "/system/app/com.ohos.contactsdataability",
+        "/system/app/com.ohos.nweb",
+        "/system/app/com.ohos.download",
+        "/system/app/com.ohos.UserFile.ExternalFileManager",
+        "/system/app/com.ohos.gameperceptio",
+        "/system/app/ohos.sample.shopping",
+        "/system/app/com.ohos.wallpaper",
+        "/system/app/cn.openharmony.inputmethodchoosedialog",
+        "/system/app/com.ohos.sharepickerdialog",
+        "/system/app/cn.openharmony.pasteboarddialog",
+        "/system/app/com.ohos.notificationdialog"
+    ],
+    "recover_list" : []
 }

上面对应的包名可以到vendor/OpenHarmony Framework层开发笔记_xml{device_name}/preinstall-config/install_list.json中获取。

7.裁剪子系统

OpenHarmony的子系统是在vendor/OpenHarmony Framework层开发笔记_xml{device_name}/config.json中加载的,比如rk3568的config.json配置文件如下:

vendor/hihope/rk3568/config.json
{
  "product_name": "rk3568",
  "device_company": "rockchip",
  "device_build_path": "device/board/hihope/rk3568",
  "target_cpu": "arm",
  "type": "standard",
  "version": "3.0",
  "board": "rk3568",
  "api_version": 8,
  "enable_ramdisk": true,
  "build_selinux": true,
  "build_seccomp": true,
  "inherit": [ "productdefine/common/inherit/rich.json", "productdefine/common/inherit/chipset_common.json" ],
  ...
}

上面的inherit项属于集成哪些部件,productdefine/common/inherit/rich.json则是标准系统的全量组件,包含的组件比较全,那么我们其实可以直接拷贝一份productdefine/common/inherit/rich.json到vendor/OpenHarmony Framework层开发笔记_xml{device_name}/目录下,接着在上面进行裁剪你需要裁剪的子系统和组件,最后将

inherit前面那个路径改成当前目录下的rich.json文件即可

8.input输入命令

uinput -K -d 2 -u 2 按下返回键

KeyCode可以在/foundation/multimodalinput/input/frameworks/proxy/events/src/key_event.cpp中找到。

9.修改屏幕相关的配置

9.1 修改配置加载的逻辑 通过判断//vendor/OpenHarmony Framework层开发笔记_xml{device_name}/window_manager/resources/config/目录下是否有相关的config文件来加载

/foundation/window/window_manager 仓库下
diff --git a/resources/config/BUILD.gn b/resources/config/BUILD.gn
index c1ffc9b5..3f5a9f03 100644
--- a/resources/config/BUILD.gn
+++ b/resources/config/BUILD.gn
@@ -20,6 +20,22 @@ ohos_prebuilt_etc("window_manager_config") {
     source = "//foundation/window/window_manager/resources/config/other/window_manager_config.xml"
     install_enable = false
   }
+
+  config_path = "//vendor/${product_company}/${device_name}/window_manager/resources/config/window_manager_config.xml"
+  _script = "//build/ohos/file_exists.py"
+  _args = [
+  "--filename",
+  rebase_path(config_path),
+  "--type",
+  "file",
+  ]
+  has_config_path = exec_script(_script, _args, "string")
+  if (has_config_path == "True") {
+    print("YW_ config file:${config_path} exists")
+    source = config_path
+    install_enable = true
+  }
+
   part_name = "window_manager"
   subsystem_name = "window"
   relative_install_dir = "window/resources"
@@ -33,6 +49,22 @@ ohos_prebuilt_etc("display_manager_config") {
     source = "//foundation/window/window_manager/resources/config/other/display_manager_config.xml"
     install_enable = false
   }
+
+  config_path = "//vendor/${product_company}/${device_name}/window_manager/resources/config/display_manager_config.xml"
+  _script = "//build/ohos/file_exists.py"
+  _args = [
+  "--filename",
+  rebase_path(config_path),
+  "--type",
+  "file",
+  ]
+  has_config_path = exec_script(_script, _args, "string")
+  if (has_config_path == "True") {
+    print("YW_ config file:${config_path} exists")
+    source = config_path
+    install_enable = true
+  }
+
   part_name = "window_manager"
   subsystem_name = "window"
   relative_install_dir = "window/resources"

9.2 将rk3568的config文件拷贝到//vendor/OpenHarmony Framework层开发笔记_xml{device_name}/下

在//vendor/${product_company}/${device_name}/下执行如下指令:
cd //vendor/guide/zp37a/
mkdir window_manager/resources/config
cp -rf //foundation/window/window_manager/resources/config/rk3568/* ./window_manager/resources/config/

10 build相关的param无法正常显示

const.product.build.type = default      ----------  ohos_build_type
const.product.build.user = default      ----------  ohos_build_user
const.product.build.host = default      ----------  ohos_build_host
const.product.build.date = default      ----------  ohos_build_time

查看这些属性的赋值是根据编译时上面对应的变量赋值的,通过编译log可以知道上述的变量时有对应的值的,原因是由于/base/startup/init/services/param/linux/BUILD.gn引入的//build/ohos.gni其中引用了//build/ohos_var.gni中没有ohos_build_type,ohos_build_user,

ohos_build_host,ohos_build_time等等这类变量导致gn编译时无法修改这些变量的值。解决方法如下:

1.在build仓库下加入如下修改

diff --git a/ohos.gni b/ohos.gni
index e1e11c8..7829b43 100755
--- a/ohos.gni
+++ b/ohos.gni
@@ -29,3 +29,11 @@ import("//build/templates/common/ohos_templates.gni")
 
 # import prebuilt templates
 import("//build/templates/cxx/prebuilt.gni")
+check_file_script = "//build/ohos/file_exists.py"
+file_path = "//vendor/${product_company}/${device_name}/${device_name}_var.gni"
+check_guide_file_args = ["--filename",rebase_path(file_path)]
+if (exec_script(check_file_script, check_guide_file_args, "string") == "True"){
+  print("${file_path} ")
+  import(file_path)
+}

2.在vendor/guide/zp37a/目录下新建zp37a_var.gni文件

vendor/guide/zp37a/zp37a_var.gni
declare_args() {
  name = "OpenHarmony"
  major = "2"
  minor = "3"
  revision = "beta"
  ohos_version = "$name $major.$minor $revision"
  ohos_build_time = ""
  ohos_build_datetime = ""
  # "debug" or "release"
  ohos_build_type = "debug"
  ohos_build_user = "yuwei"
  ohos_build_host = "Ubuntu20.04"
}

11.编译项目为arm64

修改vendor/guide/zp37a/config.json文件中的target_cpu项为arm64即可

12.添加自定义的子系统、部件、模块

这里我们将OpenHarmony的两个例子添加到源码中并使其编译到系统中,具体的操作步骤见《OpenHarmony添加自定义的子系统、部件、模块.md

13 编译sdk需要安装的软件:

sudo apt-get update && sudo apt-get install binutils binutils-dev git git-lfs gnupg flex bison gperf build-essential zip curl zlib1g-dev gcc-multilib g++-multilib gcc-arm-linux-gnueabi libc6-dev-i386 libc6-dev-amd64 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z1-dev ccache libgl1-mesa-dev libxml2-utils xsltproc unzip m4 bc gnutls-bin python3.8 python3-pip ruby genext2fs device-tree-compiler make libffi-dev e2fsprogs pkg-config perl openssl libssl-dev libelf-dev libdwarf-dev u-boot-tools mtd-utils cpio doxygen liblz4-tool openjdk-8-jre gcc g++ texinfo dosfstools mtools default-jre default-jdk libncurses5 apt-utils wget scons python3.8-distutils tar rsync git-core libxml2-dev lib32z-dev grsync xxd libglib2.0-dev libpixman-1-dev kmod jfsutils reiserfsprogs xfsprogs squashfs-tools pcmciautils quota ppp libtinfo-dev libtinfo5 libncurses5-dev libncursesw5 libstdc++6 gcc-arm-none-eabi vim ssh locales libxinerama-dev libxcursor-dev libxrandr-dev libxi-dev

14 BUILD.gn中判断文件是否存在的方法

check_file_script = "//build/ohos/file_exists.py"
file_path = "//vendor/${product_company}/${device_name}/${device_name}_var.gni"
check_guide_file_args = ["--filename",rebase_path(file_path)]
if (exec_script(check_file_script, check_guide_file_args, "string") == "True"){
  print("${file_path} ")
  import(file_path)
}

  VENDOR_CONFIG_PATH = rebase_path(
          "//vendor/${product_company}/${product_name}/power_config/power_mode_config.xml")
  CMD = "if [ -f ${VENDOR_CONFIG_PATH} ]; then echo true; else echo false; fi"
  vendor_config_exist =
      exec_script("//build/lite/run_shell_cmd.py", [ CMD ], "value")
  if (vendor_config_exist) {
    print("YW_ vendor_config_exist")
    deps += [ ":power_mode_config_vendor" ]
  }

15 hidumper可以dump指定service的信息

hidumper -h    //打印hidumper的用法
hidumper -s -a '-h' //打印指定服务的用法

16 launcher大概率无法横屏

launcher自己指定了显示的模式,去掉下面这个即可

/applications/standard/launcher/common/src/main/ets/default/manager/WindowManager.ts
   createWindow(context: ServiceExtensionContext, name: string, windowType: number, loadContent: string,
               isShow: boolean, callback?: Function) {
    Window.create(context, name, windowType).then((win) => {
        //在这里将下面这句注释掉即可
      // void win.setPreferredOrientation(Window.Orientation.AUTO_ROTATION_RESTRICTED);
      void win.loadContent(loadContent).then(() => {
        void win.setSystemBarProperties({
          navigationBarColor: StyleConstants.DEFAULT_SYSTEM_UI_COLOR,
          statusBarColor: StyleConstants.DEFAULT_SYSTEM_UI_COLOR
        }).then(() => {
          win.setBackgroundColor(StyleConstants.DEFAULT_SYSTEM_UI_COLOR, () => {
            Log.showDebug(TAG, `then begin ${name} window loadContent in then!`);
            if (name !== this.RECENT_WINDOW_NAME) {
              void win.setLayoutFullScreen(true).then(() => {
                Log.showDebug(TAG, `${name} setLayoutFullScreen`);
              });
            }
            if (callback) {
              callback(win);
            }
            // there is a low probability that white flashes when no delay because of setBackgroundColor is asynchronous
            setTimeout(() => {
              isShow && this.showWindow(name);
            }, StyleConstants.WINDOW_SHOW_DELAY)
          })
        });
      }, (error) => {
        Log.showError(TAG, `createWindow, create error: ${JSON.stringify(error)}`);
      });
    });
  }

17 APP文件的分类

ets 基本上都是定义UI组件的文件在其中都会有@Component

ts 一般定义class文件用来定义实现的功能

18 设置系统APP为launcherAPP

在想要成为主界面的module.json5文件中将加入priority和skill统计并且在entities中添加"flag.home.intent.from.system"即可

+        "priority": 2,
        "skills": [
          {
            "entities": [
              "entity.system.home",
+              "flag.home.intent.from.system"
            ],
            "actions": [
              "action.system.home"
            ]
          }
        ]

19 设置系统某个APP进程为常驻进程

/vendor/hihope/rk3568/preinstall-config/install_list_capability.json
        {
            "bundleName": "com.ohos.powerdialog",
            "keepAlive": true,
            "app_signature": ["8E93863FC32EE238060BF69A9B37E2608FFFB21F93C862DD511CBAC9F30024B5"],
            "allowAppUsePrivilegeExtension": true,
            "allowAppDesktopIconHide": true
        },

同样的可以设置APP的bundle属性有如下:

/foundation/bundlemanager/bundle_framework/services/bundlemgr/src/pre_bundle_profile.cpp
const std::string BUNDLE_NAME = "bundleName";
const std::string KEEP_ALIVE = "keepAlive";
const std::string SINGLETON = "singleton";
const std::string ALLOW_COMMON_EVENT = "allowCommonEvent";
const std::string RUNNING_RESOURCES_APPLY = "runningResourcesApply";
const std::string APP_SIGNATURE = "app_signature";
const std::string ASSOCIATED_WAKE_UP = "associatedWakeUp";
const std::string ALLOW_APP_DATA_NOT_CLEARED = "allowAppDataNotCleared";
const std::string ALLOW_APP_MULTI_PROCESS = "allowAppMultiProcess";
const std::string ALLOW_APP_DESKTOP_ICON_HIDE = "allowAppDesktopIconHide";
const std::string ALLOW_ABILITY_PRIORITY_QUERIED = "allowAbilityPriorityQueried";
const std::string ALLOW_ABILITY_EXCLUDE_FROM_MISSIONS = "allowAbilityExcludeFromMissions";
const std::string ALLOW_APP_USE_PRIVILEGE_EXTENSION = "allowAppUsePrivilegeExtension";
const std::string ALLOW_FORM_VISIBLE_NOTIFY = "allowFormVisibleNotify";

20 performance test

OpenSo spend

SAFWK OnStart systemAbilityId

/data/service/el0/startup/init/上面这个目录下存放了init各个阶段的耗时

21 arkUI仓库下:

diff --git a/ace_engine/frameworks/bridge/declarative_frontend/engine/jsi/jsi_declarative_engine.cpp b/ace_engine/frameworks/bridge/declarative_frontend/engine/jsi/jsi_declarative_engine.cpp
index 50429e8..38d01b8 100644
--- a/ace_engine/frameworks/bridge/declarative_frontend/engine/jsi/jsi_declarative_engine.cpp
+++ b/ace_engine/frameworks/bridge/declarative_frontend/engine/jsi/jsi_declarative_engine.cpp
@@ -647,10 +647,10 @@ RefPtr<JsAcePage> JsiDeclarativeEngineInstance::GetStagingPage(int32_t instanceI
 
 shared_ptr<JsRuntime> JsiDeclarativeEngineInstance::GetCurrentRuntime()
 {
-    auto jsRuntime = InnerGetCurrentRuntime();
-    if (isUnique_ && jsRuntime) {
-        return jsRuntime;
-    }
+    // auto jsRuntime = InnerGetCurrentRuntime();
+    // if (isUnique_ && jsRuntime) {
+    //     return jsRuntime;
+    // }
 
     // ArkTsCard
     if (isUnique_ && localRuntime_) {
@@ -662,7 +662,7 @@ shared_ptr<JsRuntime> JsiDeclarativeEngineInstance::GetCurrentRuntime()
         return globalRuntime_;
     }
 
-    return jsRuntime == nullptr ? localRuntime_ : jsRuntime;
+    return nullptr;
 }
 
 shared_ptr<JsRuntime> JsiDeclarativeEngineInstance::InnerGetCurrentRuntime()

22 camera_host的启动

camera_host是init解析设备端的/vendor/etc/init/hdf_devhost.cfg后通过start service使用hdf_devhost进程启动的

23 输入事件的耗时

log中搜索InputEventHandler 可以看到输入子系统分发的事件类型 eventType 开始时间,结束时间,耗时多久

搜索TimeCostChk可以查看输入事件的阶段耗时

当reason是HandleLibinputEvent 指的是输入事件从报上来到发送给客户端的分发阶段的耗时

reason是ClientMsgHandler::OnMsgHandler指的输入事件消费的耗时

reason是ServerMsgHandler::OnMsgHandler指的是input子系统服务端接收到客户端消息时处理的耗时

reason是IPC-OnRemoteRequest指的是input子系统服务接收到指令的处理耗时比如注册eventlistener

eventType 的数字和类型的对应关系如下:

/**
 * @ingroup base
 *
 * Event type for events returned by libinput_get_event().
 */
enum libinput_event_type {
	/**
	 * This is not a real event type, and is only used to tell the user that
	 * no new event is available in the queue. See
	 * libinput_next_event_type().
	 */
	LIBINPUT_EVENT_NONE = 0,

	/**
	 * Signals that a device has been added to the context. The device will
	 * not be read until the next time the user calls libinput_dispatch()
	 * and data is available.
	 *
	 * This allows setting up initial device configuration before any events
	 * are created.
	 */
	LIBINPUT_EVENT_DEVICE_ADDED,

	/**
	 * Signals that a device has been removed. No more events from the
	 * associated device will be in the queue or be queued after this event.
	 */
	LIBINPUT_EVENT_DEVICE_REMOVED,

	LIBINPUT_EVENT_KEYBOARD_KEY = 300,

	LIBINPUT_EVENT_POINTER_MOTION = 400,
	LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE,
	LIBINPUT_EVENT_POINTER_BUTTON,
	LIBINPUT_EVENT_POINTER_AXIS,

	LIBINPUT_EVENT_TOUCH_DOWN = 500,
	LIBINPUT_EVENT_TOUCH_UP,
	LIBINPUT_EVENT_TOUCH_MOTION,
	LIBINPUT_EVENT_TOUCH_CANCEL,
	/**
	 * Signals the end of a set of touchpoints at one device sample
	 * time. This event has no coordinate information attached.
	 */
	LIBINPUT_EVENT_TOUCH_FRAME,

	/**
	 * One or more axes have changed state on a device with the @ref
	 * LIBINPUT_DEVICE_CAP_TABLET_TOOL capability. This event is only sent
	 * when the tool is in proximity, see @ref
	 * LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY for details.
	 *
	 * The proximity event contains the initial state of the axis as the
	 * tool comes into proximity. An event of type @ref
	 * LIBINPUT_EVENT_TABLET_TOOL_AXIS is only sent when an axis value
	 * changes from this initial state. It is possible for a tool to
	 * enter and leave proximity without sending an event of type @ref
	 * LIBINPUT_EVENT_TABLET_TOOL_AXIS.
	 *
	 * An event of type @ref LIBINPUT_EVENT_TABLET_TOOL_AXIS is sent
	 * when the tip state does not change. See the documentation for
	 * @ref LIBINPUT_EVENT_TABLET_TOOL_TIP for more details.
	 *
	 * @since 1.2
	 */
	LIBINPUT_EVENT_TABLET_TOOL_AXIS = 600,
	/**
	 * Signals that a tool has come in or out of proximity of a device with
	 * the @ref LIBINPUT_DEVICE_CAP_TABLET_TOOL capability.
	 *
	 * Proximity events contain each of the current values for each axis,
	 * and these values may be extracted from them in the same way they are
	 * with @ref LIBINPUT_EVENT_TABLET_TOOL_AXIS events.
	 *
	 * Some tools may always be in proximity. For these tools, events of
	 * type @ref LIBINPUT_TABLET_TOOL_PROXIMITY_STATE_IN are sent only once after @ref
	 * LIBINPUT_EVENT_DEVICE_ADDED, and events of type @ref
	 * LIBINPUT_TABLET_TOOL_PROXIMITY_STATE_OUT are sent only once before @ref
	 * LIBINPUT_EVENT_DEVICE_REMOVED.
	 *
	 * If the tool that comes into proximity supports x/y coordinates,
	 * libinput guarantees that both x and y are set in the proximity
	 * event.
	 *
	 * When a tool goes out of proximity, the value of every axis should be
	 * assumed to have an undefined state and any buttons that are currently held
	 * down on the stylus are marked as released. Button release events for
	 * each button that was held down on the stylus are sent before the
	 * proximity out event.
	 *
	 * @since 1.2
	 */
	LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY,
	/**
	 * Signals that a tool has come in contact with the surface of a
	 * device with the @ref LIBINPUT_DEVICE_CAP_TABLET_TOOL capability.
	 *
	 * On devices without distance proximity detection, the @ref
	 * LIBINPUT_EVENT_TABLET_TOOL_TIP is sent immediately after @ref
	 * LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY for the tip down event, and
	 * immediately before for the tip up event.
	 *
	 * The decision when a tip touches the surface is device-dependent
	 * and may be derived from pressure data or other means. If the tip
	 * state is changed by axes changing state, the
	 * @ref LIBINPUT_EVENT_TABLET_TOOL_TIP event includes the changed
	 * axes and no additional axis event is sent for this state change.
	 * In other words, a caller must look at both @ref
	 * LIBINPUT_EVENT_TABLET_TOOL_AXIS and @ref
	 * LIBINPUT_EVENT_TABLET_TOOL_TIP events to know the current state
	 * of the axes.
	 *
	 * If a button state change occurs at the same time as a tip state
	 * change, the order of events is device-dependent.
	 *
	 * @since 1.2
	 */
	LIBINPUT_EVENT_TABLET_TOOL_TIP,
	/**
	 * Signals that a tool has changed a logical button state on a
	 * device with the @ref LIBINPUT_DEVICE_CAP_TABLET_TOOL capability.
	 *
	 * Button state changes occur on their own and do not include axis
	 * state changes. If button and axis state changes occur within the
	 * same logical hardware event, the order of the @ref
	 * LIBINPUT_EVENT_TABLET_TOOL_BUTTON and @ref
	 * LIBINPUT_EVENT_TABLET_TOOL_AXIS event is device-specific.
	 *
	 * This event is not to be confused with the button events emitted
	 * by the tablet pad. See @ref LIBINPUT_EVENT_TABLET_PAD_BUTTON.
	 *
	 * @see LIBINPUT_EVENT_TABLET_PAD_BUTTON
	 *
	 * @since 1.2
	 */
	LIBINPUT_EVENT_TABLET_TOOL_BUTTON,

	/**
	 * A button pressed on a device with the @ref
	 * LIBINPUT_DEVICE_CAP_TABLET_PAD capability.
	 *
	 * A button differs from @ref LIBINPUT_EVENT_TABLET_PAD_KEY in that
	 * buttons are sequentially indexed from 0 and do not carry any
	 * other information.  Keys have a specific functionality assigned
	 * to them. The key code thus carries a semantic meaning, a button
	 * number does not.
	 *
	 * This event is not to be confused with the button events emitted
	 * by tools on a tablet (@ref LIBINPUT_EVENT_TABLET_TOOL_BUTTON).
	 *
	 * @since 1.3
	 */
	LIBINPUT_EVENT_TABLET_PAD_BUTTON = 700,
	/**
	 * A status change on a tablet ring with the @ref
	 * LIBINPUT_DEVICE_CAP_TABLET_PAD capability.
	 *
	 * @since 1.3
	 */
	LIBINPUT_EVENT_TABLET_PAD_RING,

	/**
	 * A status change on a strip on a device with the @ref
	 * LIBINPUT_DEVICE_CAP_TABLET_PAD capability.
	 *
	 * @since 1.3
	 */
	LIBINPUT_EVENT_TABLET_PAD_STRIP,

	/**
	 * A key pressed on a device with the @ref
	 * LIBINPUT_DEVICE_CAP_TABLET_PAD capability.
	 *
	 * A key differs from @ref LIBINPUT_EVENT_TABLET_PAD_BUTTON in that
	 * keys have a specific functionality assigned to them (buttons are
	 * sequentially ordered). The key code thus carries a semantic
	 * meaning, a button number does not.
	 *
	 * @since 1.15
	 */
	LIBINPUT_EVENT_TABLET_PAD_KEY,

	LIBINPUT_EVENT_GESTURE_SWIPE_BEGIN = 800,
	LIBINPUT_EVENT_GESTURE_SWIPE_UPDATE,
	LIBINPUT_EVENT_GESTURE_SWIPE_END,
	LIBINPUT_EVENT_GESTURE_PINCH_BEGIN,
	LIBINPUT_EVENT_GESTURE_PINCH_UPDATE,
	LIBINPUT_EVENT_GESTURE_PINCH_END,

	/**
	 * @since 1.7
	 */
	LIBINPUT_EVENT_SWITCH_TOGGLE = 900,
};
  • InputEventHandler::OnEvent(void event)调用 EventNormalizeHandler::HandleEvent(libinput_event event)开始按顺序处理输入事件。
  • EventNormalizeHandler把libinput_event标准化成各种InputEvent(KeyEvent,PointerEvent,AxisEvent),并传递给下一级 EventFilterHandler处理
  • EventFilterHandler会过滤一些事件,否则继续往下传递
  • EventInterceptorHandler事件拦截器,拦截成功不会继续往下传
  • KeyCommandHandler根据配置文件,对一些特殊按键,拉起特定应用界面,或者对电源键,音量键做特殊处理,否则继续往下传递
  • KeySubscriberHandler应用订阅的组合按键(应用通过inputConsumer.on接口订阅)处理,否则继续往下传递
  • EventMonitorHandler事件跟踪器,把事件分发给跟踪者并继续往下传
  • EventDispatchHandler通过socket把事件派发给应用

24 Openharmony的camera数据传输机制

在上层发送start的信号后 source_node接收到后设置buffer回调SetBufferCallback(),接着StartCollectBuffers开始收集buffer,接着填充好数据的buffer通过设置的回调回调到OnPackBuffer接着使用DistributeBuffers将buffer分发到其他的node中最终在sink_node中将buffer回调给 stream_base的HandleResult中

【版权声明】本文内容来自摩杜云社区用户原创、第三方投稿、转载,内容版权归原作者所有。本网站的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@moduyun.com

  1. 分享:
最后一次编辑于 2023年11月08日 0

暂无评论

推荐阅读
  6x82OSIkB82a   2023年12月23日   53   0   0 jsonJSONjavajava
EzIAYXiV4scN
最新推荐 更多