===========制作系统签名==========
1.进入系统源码目录development/tools/
2.make_key的参数介绍
这里要顺便介绍下make_key的参数。第一个参数是要生成key的名字,第二个参数是关于你公司的信息。
key的名字很好理解,就是前面提到的4中类型的key,公司信息的参数比较多,它们的含义如下:
C —> Country Name (2 letter code)
ST —> State or Province Name (full name)
L —> Locality Name (eg, city)
O —> Organization Name (eg, company)
OU —> Organizational Unit Name (eg, section)
CN —> Common Name (eg, your name or your server’s hostname)
emailAddress —> Contact email address
3..执行类似以下命令生成各种签名
source make_key testkey '/C=CN/ST=Sichuan/L=Chengdu/O=KK/OU=KK/CN=kk/emailAddress=test@163.com'
source make_key platform '/C=CN/ST=Sichuan/L=Chengdu/O=KK/OU=KK/CN=kk/emailAddress=test@163.com'
source make_key shared '/C=CN/ST=Sichuan/L=Chengdu/O=KK/OU=KK/CN=kk/emailAddress=test@163.com'
source make_key media '/C=CN/ST=Sichuan/L=Chengdu/O=KK/OU=KK/CN=kk/emailAddress=test@163.com'
4.执行上一步命令后会生成各种签名,替换原来系统的默认签名,可以通过find命令搜索到签名路径,我的默认签名目录为:
bootable/recovery/tests/testdata/testkey.pk8
bootable/recovery/tests/testdata/testkey.x509.pem
build/target/product/security/media.pk8
build/target/product/security/media.x509.pem
build/target/product/security/platform.pk8
build/target/product/security/platform.x509.pem
build/target/product/security/shared.pk8
build/target/product/security/shared.x509.pem
build/target/product/security/testkey.pk8
build/target/product/security/testkey.x509.pem
5.重新编译系统即可,系统默认使用的testkey,具体细节见安卓编译相关的makefile,这里主要修改两个地方
5.1 build/core/config.mk
ifdef PRODUCT_DEFAULT_DEV_CERTIFICATE
DEFAULT_SYSTEM_DEV_CERTIFICATE := $(PRODUCT_DEFAULT_DEV_CERTIFICATE)
else
DEFAULT_SYSTEM_DEV_CERTIFICATE := build/target/product/security/testkey
endif
中的testkey改为你需要的key,因为在这里我们编译的testkey已经覆盖了系统的testkey,如果修改为其他key,则还需要修改以下的makefile。
5.2 system/sepolicy/keys.conf
[@PLATFORM]
ALL : $DEFAULT_SYSTEM_DEV_CERTIFICATE/platform.x509.pem
[@MEDIA]
ALL : $DEFAULT_SYSTEM_DEV_CERTIFICATE/media.x509.pem
[@SHARED]
ALL : $DEFAULT_SYSTEM_DEV_CERTIFICATE/shared.x509.pem
# Example of ALL TARGET_BUILD_VARIANTS
[@RELEASE]
ENG : $DEFAULT_SYSTEM_DEV_CERTIFICATE/testkey.x509.pem
USER : $DEFAULT_SYSTEM_DEV_CERTIFICATE/testkey.x509.pem
======安卓系统签名转应用签名keyStore=====
下载工具:https://github.com/getfatday/keytool-importkeypair
在linux环境执行以下命令
./keytool-importkeypair -k ./debug.keystore -p 密码 -pk8 platform.pk8 -cert platform.x509.pem -alias 别名