OpenHarmony4.0 系统应用签名

本文详细介绍了如何在OpenHarmony系统中使用DevEcoStudio对Settings、Launcher等应用进行单独开发和编译,包括使用默认签名工具hapsigner、配置签名文件、环境准备以及实际操作步骤,确保应用成功推送到设备并正常加载。
摘要由CSDN通过智能技术生成

OpenHarmony 系统应用需要在DevEco Studio单独开发编译,不能使用build.sh hb编译,比如SettingsLauncherSystemUI等。

Launcher源码中有默认的签名配置,直接就可以使用。

Settings签名文件里面只有settings.p7b,虽然可以使用DevEco Studio默认自动签名,但是我发现push到设备里面后,点击应用,应用列表无法刷新,所以我想应该还是签名的问题,所以还是需要系统签名。

打开源码里面的签名工具目录OHOS_v4.0_NEW/developtools/hapsigner,这个就是默认签名工具,或者直接下载官方提供developtools_hapsigner

环境配置python 和 gradle,可以参考hap包签名工具,我们不需要重新生成密钥文件,使用系统默认提供的就可以。

1、复制文件

把OpenHarmonyApplication.pem和settings.p7b复制到developtools/hapsigner/autosign/result,目录下,需要签名的hap包放到developtools/hapsigner/autosign目录下。

2、修改配置文件

修改developtools/hapsigner/autosign/signHap.config

// Common configuration, will be overwrite by detail config
#common.keystoreFile 改为 OpenHarmony.p12
common.keystoreFile=OpenHarmony.p12
common.keystorePwd=123456
common.signAlg=SHA256withECDSA
common.mode=localSign

// You must change this instead of using default
common.keyPwd=123456
common.issuerKeyPwd=123456

// keypair of app signature
#pp.keypair.keyAlias 改为 OpenHarmony Application Release
app.keypair.keyAlias=OpenHarmony Application Release
app.keypair.keyPwd=123456

// App signature cert
#cert.app.outFile 改为penHarmonyApplication.pem
cert.app.outFile=OpenHarmonyApplication.pem

// Sign profile
#sign.profile.outFile 改为要签名的包里面的p7b文件
sign.profile.outFile=settingsdata.p7b

// Sign app
#要签名的包
sign.app.inFile=SettingsData-unsigned.hap
#生成签名的包
sign.app.outFile=SettingsData-signed.hap
3、执行脚本

修改完成后,执行脚本sign_hap.sh,提示Success表示签名成功,生成的文件在developtools/hapsigner/autosign/result/目录下,Settings-signed.hap。

4、push文件

hdc操作

hdc target mount
hdc shell rm -rf /data/misc_de/0/mdds/0/default/bundle_manager_service
hdc shell rm -rf /data/accounts
hdc shell mount -o remount,rw /
hdc file send C:\Users\XXX\Desktop\openharmony\Settings\Settings.hap /system/app/com.ohos.settings/Settings.hap
hdc file send C:\Users\XXX\Desktop\openharmony\Settings\SettingsData.hap /system/app/com.ohos.settingsdata/SettingsData.hap
echo "push Settings sueecess start reboot"
hdc shell mount -o remount,rw /
hdc shell rm /data/* -rf
hdc shell sync /system/bin/udevadm trigger
hdc shell reboot

重启后,应用重新加载,成功!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

开开心心everyday

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值