为了通过google 的认证,我们需要修改fingerprint
ro.product.model (Model Name) | (型号名称) | |
ro.product.name (Product Name) | (产品名称) | |
ro.product.brand (Brand Name) | (品牌名称) | |
ro.product.device (Device Name) | (设备名称) | |
ro.product.manufacturer | (制造商名称) |
公司做了MTK 和高通平台,总结下修改方法,以下都是基于Android 12平台
MTK 平台
首先找到这几个property 设置值的地方
build/make/core/sysprop.mk
define generate-common-build-props
echo "####################################" >> $(2);\
echo "# from generate-common-build-props" >> $(2);\
echo "# These properties identify this partition image." >> $(2);\
echo "####################################" >> $(2);\
$(if $(filter system,$(1)),\
echo "ro.product.$(1).brand=$(PRODUCT_SYSTEM_BRAND)" >> $(2);\
echo "ro.product.$(1).device=$(PRODUCT_SYSTEM_DEVICE)" >> $(2);\
echo "ro.product.$(1).manufacturer=$(PRODUCT_SYSTEM_MANUFACTURER)" >> $(2);\
echo "ro.product.$(1).model=$(PRODUCT_SYSTEM_MODEL)" >> $(2);\
echo "ro.product.$(1).name=$(PRODUCT_SYSTEM_NAME)" >> $(2);\
,\
echo "ro.product.$(1).brand=$(PRODUCT_BRAND)" >> $(2);\
echo "ro.product.$(1).device=$(TARGET_DEVICE)" >> $(2);\
echo "ro.product.$(1).manufacturer=$(PRODUCT_MANUFACTURER)" >> $(2);\
echo "ro.product.$(1).model=$(PRODUCT_MODEL)" >> $(2);\
echo "ro.product.$(1).name=$(TARGET_PRODUCT)" >> $(2);\
)\
这几个property 对应的值分别是
PRODUCT_MODEL PRODUCT_BRAND TARGET_DEVICE PRODUCT_MANUFACTURER
TARGET_PRODUCT
所以我们只要修改对应的宏就可以了
我们的修改方式是
build/make/core/Makefile
MY_BRAND="111111"
MY_MANUFACTURER="1111"
MY_DEVICE="1111"
MY_MODEL="11111"
MY_NAME="1111"
define generate-common-build-props
PRODUCT_BRAND="$(MY_BRAND)" \
PRODUCT_DEVICE="$(MY_DEVICE)" \
PRODUCT_MANUFACTURER="$(MY_MANUFACTURER)" \
PRODUCT_MODEL="$(MY_MODEL)" \
PRODUCT_NAME="$(MY_NAME)" \
$(call generate-common-build-props-with-product-vars-set,$(1),$(2))
endef
替换成
echo "ro.product.$(1).brand=$(MY_BRAND)" >> $(2);\
echo "ro.product.$(1).device=$(MY_DEVICE)" >> $(2);\
echo "ro.product.$(1).manufacturer=$(MY_MANUFACTURER)" >> $(2);\
echo "ro.product.$(1).model=$(MY_MODEL)" >> $(2);\
echo "ro.product.$(1).name=$(MY_PRODUCT)" >> $(2);\
整编生效
对应的fingerprint 如何修改呢,先看下原生的是的如何拼成的
echo "ro.$(1).build.fingerprint=$(BUILD_FINGERPRINT_FROM_FILE)" >> $(2);\
echo "ro.build.fingerprint=$(BUILD_FINGERPRINT_FROM_FILE)" >> $(2);\
# BUILD_FINGERPRINT is used used to uniquely identify the combined build and
# product; used by the OTA server.
ifeq (,$(strip $(BUILD_FINGERPRINT)))
ifeq ($(strip $(HAS_BUILD_NUMBER)),false)
BF_BUILD_NUMBER := $(BUILD_USERNAME)$$($(DATE_FROM_FILE) +%m%d%H%M)
else
BF_BUILD_NUMBER := $(file <$(BUILD_NUMBER_FILE))
endif
#BUILD_FINGERPRINT := $(PRODUCT_BRAND)/$(TARGET_PRODUCT)/$(TARGET_DEVICE):$(PLATFORM_VERSION)/$(BUILD_ID)/$(BF_BUILD_NUMBER):$(TARGET_BUILD_VARIANT)/$(BUILD_VERSION_TAGS)
BUILD_FINGERPRINT := $(PRODUCT_BRAND)/$(TARGET_PRODUCT)/$(TARGET_DEVICE):$(PLATFORM_VERSION)/$(BUILD_ID)/$(BUILD_NUMBER_EXTERNAL):$(TARGET_BUILD_VARIANT)/$(BUILD_VERSION_TAGS)
endif
# unset it for safety.
BF_BUILD_NUMBER :=
BUILD_FINGERPRINT_FILE := $(PRODUCT_OUT)/build_fingerprint.txt
ifneq (,$(shell mkdir -p $(PRODUCT_OUT) && echo $(BUILD_FINGERPRINT) >$(BUILD_FINGERPRINT_FILE) && grep " " $(BUILD_FINGERPRINT_FILE)))
$(error BUILD_FINGERPRINT cannot contain spaces: "$(file <$(BUILD_FINGERPRINT_FILE))")
endif
BUILD_FINGERPRINT_FROM_FILE := $$(cat $(BUILD_FINGERPRINT_FILE))
# unset it for safety.
BUILD_FINGERPRINT :=
注意看BUILD_FINGERPRINT 的生成规则,既然我们要生成自己的fingerprint
只要替换成自己上面自己的PRODUCT INFO 就可以了,抄google 的作业
ifeq (,$(strip $(MY_FINGERPRINT)))
MY_FINGERPRINT := $(MY_BRAND)/$(MY_NAME)/$(MY_DEVICE):$(PLATFORM_VERSION)/$(BUILD_ID)/$(BUILD_NUMBER_FROM_FILE):$(TARGET_BUILD_VARIANT)/$(BUILD_VERSION_TAGS)
endif
MY_FINGERPRINT_FILE := $(PRODUCT_OUT)/my_fingerprint.txt
ifneq (,$(shell mkdir -p $(PRODUCT_OUT) && echo $(MY_FINGERPRINT) >$(PRODUCT_OUT)/my_fingerprint.txt ))
$(error MY_FINGERPRINT cannot contain spaces: )
endif
MY_FINGERPRINT_FROM_FILE := $$(cat $(MY_FINGERPRINT_FILE))
然后把BUILD_FINGERPRINT_FROM_FILE 替换成 MY_FINGERPRINT_FROM_FILE OK
Release key
修改release key 路径
MTK 原生的release key 逻辑好复杂呀,小伙伴们瞅瞅
device/mediatek/common/device.mk
device/mediatek/vendor/common /device.mk
device/mediatek/system/common /device.mk
#我自己加的
PRODUCT_DEFAULT_DEV_CERTIFICATE := build/target/product/security/releasekey
#MTK的逻辑
#ifdef SYS_TARGET_PROJECT
#ifndef MTK_TARGET_PROJECT
#ifneq ($(wildcard $(strip $(SYS_TARGET_PROJECT_FOLDER))/security),)
# PRODUCT_DEFAULT_DEV_CERTIFICATE := $(strip $(SYS_TARGET_PROJECT_FOLDER))/security/releasekey
#else ifneq ($(wildcard device/mediatek/security),)
# PRODUCT_DEFAULT_DEV_CERTIFICATE := device/mediatek/security/releasekey
#else
# ifeq ($(MSSI_MTK_SIGNATURE_CUSTOMIZATION),yes)
# ifeq ($(wildcard device/mediatek/security/$(strip $(SYS_TARGET_PROJECT))),)
# $(error Please create device/mediatek/security/$(strip $(SYS_TARGET_PROJECT))/ and put your releasekey there!!)
# else
# PRODUCT_DEFAULT_DEV_CERTIFICATE := device/mediatek/security/$(strip $(SYS_TARGET_PROJECT))/releasekey
# endif
# else
## Not specify PRODUCT_DEFAULT_DEV_CERTIFICATE and the default testkey will be used.
# endif
#endif
#endif
#endif
上面注释掉的部分就是MTK 的逻辑,看的晕乎乎的,他们这么做的原因大概是为了通用其他项目,我只保留上面一段release key 的路径,咱又不需要适配哈哈.注意上面两个路径都要改.
生成自己的key
知道了release key 路径,下面就要想办法替换了
先生成自己的,生成方式,google 已经在代码里面告诉我们了.参考下面README
build/make/target/product/security/README
需要生成我们自己的release key ,方法同上
development/tools/make_key releasekey '/C=US/ST=California/L=Mountain View/O=Android/OU=Android/CN=Android/emailAddress=android@android.com'
把生成的key ,copy 到PRODUCT_DEFAULT_DEV_CERTIFICATE 对应的路径可以
记得修改权限
chmod 664 releasekey.pk8
chmod 664 releasekey.x509.pem
通过下面命令生成4个key
subject='/C=ZH/ST=SH/L=ODM/O=ODM/OU=ODM/CN=ODM/emailAddress=odm@odm.com'
for x in releasekey platform shared media testkey; do ../../../../../development/tools/make_key $x "$subject"; done
修改fingerprint
build/make/core/Makefile
ifeq ($(DEFAULT_SYSTEM_DEV_CERTIFICATE),build/target/product/security/releasekey)
BUILD_KEYS := release-keys
endif
/build/core/sysprop.mk 这里面也要加,不然fingerprint 后面会出现releasekey,testkey 这种怪怪的问题
高通平台
高通平台和MTK 类似,不过高通平台分qssi和vendor 两套代码,所以改的时候有需要注意下,不能改漏了
修改release key,注意生成的release key ,需要在vendor 下source /launcher 自己项目的名称,同时copy 一份到qssi目前 下
Vendor 修改路径:
vendor/qcom/项目名/项目名字.mk
PRODUCT_DEFAULT_DEV_CERTIFICATE := build/make/target/product/security/releasekey
build / core/Makefile
ifeq ($(DEFAULT_SYSTEM_DEV_CERTIFICATE),build/make/target/product/security/releasekey)
BUILD_KEYS := release-keys
endif
build / core/Makefile
参考MTK 平台修改device info
build / tools/buildinfo_common.sh
修改生成的规则即可生效
echo "ro.${partition}.build.fingerprint=$MY_FINGERPRINT"
Qssi 修改路径
device/qcom/qssi/qssi.mk
PRODUCT_DEFAULT_DEV_CERTIFICATE := build/make/target/product/security/releasekey
build/core/sysprop.mk
ifeq ($(DEFAULT_SYSTEM_DEV_CERTIFICATE),build/make/target/product/security/releasekey)
BUILD_KEYS := release-keys
endif
fingerprinter 修改成功,编译后可通过,查看下面文件看看是否生效
out/target/product/qssi/build_fingerprint.txt
qti/qssi/qssi:11/RKQ1.210614.002/xxxx:userdebug/release-keys
adb shell getprop | grep finger 查看finger 是否设置正确.
查看签名
keytool -printcert -jarfile xxx.apk 通过这个命令查看系统签名是否是我们设置的release key 信息
这样完整的流程就结束啦