OpenHarmony开发者论坛
标题:
Openharmony Launcher 自定义
[打印本页]
作者:
liubo-688
时间:
2024-12-26 11:40
标题:
Openharmony Launcher 自定义
[md]一、前言
在Openharmony 开发过程中很多时候需要自定义Launcher 桌面,或去掉;除非是手机终端设备,否则不需要臃肿的原生Launcher;因为都是面向特定场景需求而开发,可以说是做定制性的开发,所以如何进行 Launcher 自定义变得很有必要。以下介绍自定义替换方法:
替换 launcher 有两种方法:(以下介绍同包名替换方法,改包名替换方法复杂,不推荐)
二、包名替换法
1、将自己普通应用的 bundleName 改为 com.ohos.launcher
2、ohos 3.1.0 及以下系统必须用 api8 faMode 应用,ohos3.1.1 及以上可用 api19 stageMode 应用。
三、修改启动配置
1、全屏配置(无须全屏可忽略此步)
修改 foundation/aafwk/standard/services/abilitymgr/resource/ams_service_config.json {
"service_startup_config":
"startup_settings_data": true,
"startup_screen_lock" : true,
"startup_system_ui_status_bar" : true,
"startup_system_ui_navigation_bar" : true,
"startup_phone_service" : true,
"startup_mms":true,
"mission_save_time" : 43200000,
"root_launcher_restart_max":15,
"use_new_mission":true,
"app_not_response_process_timeout_time" : 5000, "ams_timeout_time" : 60
},
"memorythreshold":{
"home_application": "20" },
"system_configuration":{
"system_orientation": "vertical"
将 startup_system_ui_status_bar 和 startup_system_ui_navigation_bar 两项 true 全部改为 false, 如其它项不须要也可改为 false 将其关闭。
2、自定义内置应用
1) ohos4.1.0 修改 device 下对应开发板型号目录下的 system_hap 中 BUILD.gn 文件
2) ohos4.1.1 修改 applications/standard/hap/BUILD.gn
可以把不需要的 hap 全部删除只保留 ohos_prebuilt_etc("launcher_hap") {
source = "Launcher.hap" module_install_dir = "app" part_name = "prebuilt_hap" subsystem_name = "applications"
}
group("hap") {
//applications/standard/hap:launcher_hap"
四、应用端设置
启动页必须在 MainAbility 下,
将生成模块生成的页面文件置空即可,如图:

在 module.json5 或 config.json 中加入 entities flag 与 actions flag
五、编译hap 包
1、将应用签名打包
2、将 hap 包命令为 Launcher.hap 3、将 hap 替换
1) ohos 3.1.0 (路径: device/hihope/rk3568/system_hap)
2) Ohos3.1.1 (路径: applications/standard/hap)
3) 重新编译系统,将 img 镜像固件重新烧录即可
[/md]
欢迎光临 OpenHarmony开发者论坛 (https://forums.openharmony.cn/)
Powered by Discuz! X3.5