下面问题的描述不重要,想必每个公司都有它自己的一套客制化需求,主要是思路。
今天遇到个问题,就是订单的版本号对应不对,平常高通订单版本号都是在config.mk文件改写,找了很久没有头绪。后面直接在vendor(客制化,公司订单客制化需求在这下面)下搜索文件错误的订单版本号,搜索bash命令如下
grep -rni --include="*" --exclude-dir=out "错误订单版本号" ./
搜索到configwikoinfo.ini文件原来公司为Wiko的Unify,这个坑新接MR版本的我哪知道。原来fingerprint也是在这里面定义的(平常在buildinfo.sh文件里面),fingerprint固定的,我靠,MR与上一送测版本fingerprint一致,google是不会接受的直接打回来,差点背锅。
configwikoinfo.ini
#内部、外部版本号,产品名称、品牌等等,fingerprint
TCUSTOM_BUILD_VERNO_FR = ...
CUSTOM_BUILD_VERNO_FR = ...
INTERNAL_BUILD_VERNO_FR = ...
WIK_PRODUCT_MODEL_FR = ...
WIK_PRODUCT_NAME_FR = ...
WIK_PRODUCT_DEVICE_FR = ...
WIK_PRODUCT_BOARD_FR = ...
#fixed BUILD_FINGERPRINT build number line
WIK_BUILD_FINGERPRINT_FR = ...
然而这个文件又有什么用了,原来在另一个仓库下有一个bwc.mk文件
# check configwikoinfo.ini path
ifeq ($(strip $(SUB_PROJECT_NAME)),)
wik_config_path := vendor/tinno/${TARGET_PRODUCT}/${PROJECT_NAME}/unify/configwikoinfo.ini
else
wik_config_path := vendor/tinno/${TARGET_PRODUCT}/${PROJECT_NAME}/SUB_PROJECTS/${SUB_PROJECT_NAME}/unify/configwikoinfo.ini
endif
$(warning "wik_config_path = $(wik_config_path)")
result := $(shell ./vendor/tinno/requirement/wik_common/unify/tools/BWC/buildwiko.py "${wik_config_path}" "WIKO" "$(PLATFORM_VERSION)" "$(BUILD_ID)" "$(TARGET_BUILD_VARIANT)" "release-keys")
$(warning "-- build wiko area --")
由上bwc.mk文件可知得到configwikoinfo.ini文件路径,然后运行buildwiko.py脚本,传入全局参数
buildwiko.py
#!/usr/bin/env python
#import commands
import ConfigParser
import sys,os
import commands
#configFile = "/home/android/WD_WORK/V3991_7.0/baseline/vendor/tinno/v3971/wik_fr/unify/configwikoinfo.ini"
writePath = "vendor/tinno/requirement/wik_common/unify/tools/BWC/"
#writePath = "./"
print "build wiko config version 1.0"
tmpBuffer = ""
index = 0
WIK_PRODUCT_BRAND = ""
WIK_PRODUCT_NAME = ""
PLATFORM_VERSION = ""
BUILD_ID = ""
BUILD_NUMBER = ""
TARGET_BUILD_VARIANT = ""
BUILD_VERSION_TAGS = ""
WIK_ASIA_UNIFY_CONFIG = "ro.internal.build.version="
propList = [
'ro.tcustom.build.version=',
'ro.custom.build.version=',
'ro.tinternal.build.version=',
'ro.product.model=',
'ro.product.name=',
'ro.product.device=',
'ro.product.board=',
'ro.build.fingerprint='
]
def add_config_fingerprint(buf):
buf += "ro.build.fingerprint="
buf += WIK_PRODUCT_BRAND
buf += '/'
buf += WIK_PRODUCT_NAME
buf += '/'
buf += WIK_PRODUCT_NAME+":"+PLATFORM_VERSION
buf += '/'
buf += BUILD_ID
buf += '/'
buf += BUILD_NUMBER
buf += ':'
buf += TARGET_BUILD_VARIANT
buf += '/'
buf += BUILD_VERSION_TAGS
buf += '\n'
print "add_config_fingerprint ...."
return buf
def add_config_head(buf,area):
buf += "# begin wiko properties\n"
buf += "# WIKO_AREA:wik_"
buf += area
buf += "\n"
return buf
def add_config_tail(buf):
buf += "# end wiko properties\n"
return buf
def write_config_to_file(buf, filepath):
print "filepath = ",filepath
with open(filepath, 'w') as file_object:
file_object.write(buf)
def build_wiko_config(config_file_path):
cf = ConfigParser.ConfigParser()
try:
cf.read(config_file_path)
except:
print "read ",config_file_path, "failed !"
return None
sections = cf.sections()
print 'section:', sections
for section in sections:
print "section=",section
tmpBuffer = ""
index = 0
tmpBuffer = add_config_head(tmpBuffer,section)
writeFilePath = writePath + section
options = cf.options(section)
print "options = ",options
global BUILD_NUMBER
if section == "du":
(status, BUILD_NUMBER) = commands.getstatusoutput('date +%s -d \'+121 min\'')
elif section == "fr":
(status, BUILD_NUMBER) = commands.getstatusoutput('date +%s -d \'+121 min\'')
elif section == "vn":
(status, BUILD_NUMBER) = commands.getstatusoutput('date +%s -d \'+243 min\'')
elif section == "id":
(status, BUILD_NUMBER) = commands.getstatusoutput('date +%s -d \'+365 min\'')
elif section == "th":
(status, BUILD_NUMBER) = commands.getstatusoutput('date +%s -d \'+488 min\'')
elif section == "my":
(status, BUILD_NUMBER) = commands.getstatusoutput('date +%s -d \'+610 min\'')
elif section == "unify":
unify = "INTERNAL_BUILD_VERNO_UNIFY"
value = cf.get(section,unify)
print "INTERNAL_BUILD_VERNO_UNIFY=",value
if not value.strip():
print "INTERNAL_BUILD_VERNO_UNIFY is not config, fatal exception"
return
global WIK_ASIA_UNIFY_CONFIG
WIK_ASIA_UNIFY_CONFIG += value
continue
else:
print 'unsupport area break out', section
return
BUILD_NUMBER = "android" + BUILD_NUMBER
print "BUILD_NUMBER = ",BUILD_NUMBER
# add ro.internal.build.version config
if section != "fr":
tmpBuffer += WIK_ASIA_UNIFY_CONFIG
tmpBuffer += '\n'
flag = "0"
wik_product_name_tmp = "wik_product_name_" + section
for option in options:
print "option = ",option
value = cf.get(section,option)
print "value =",value, " option = ",option, "wik_product_name=",wik_product_name_tmp
if option == wik_product_name_tmp:
global WIK_PRODUCT_NAME
WIK_PRODUCT_NAME = value;
print "WIK_PRODUCT_NAME = ", WIK_PRODUCT_NAME
tmpBuffer += propList[index]
tmpBuffer += value
tmpBuffer += '\n'
index = index + 1
print "option=",option, "value=",value
if (("wik_build_fingerprint" in option) and (value != "")):
flag = "1"
if flag == "0":
tmpBuffer = add_config_fingerprint(tmpBuffer)
tmpBuffer = add_config_tail(tmpBuffer)
print "tmpBuffer = ",tmpBuffer
write_config_to_file(tmpBuffer, writeFilePath)
if __name__ == "__main__":
if len(sys.argv) != 7:
print "please input configwikoinfo.ini path"
WIK_PRODUCT_BRAND = sys.argv[2]
PLATFORM_VERSION = sys.argv[3]
BUILD_ID = sys.argv[4]
TARGET_BUILD_VARIANT = sys.argv[5]
BUILD_VERSION_TAGS = sys.argv[6]
print "start build wiko config"
build_wiko_config(sys.argv[1])
前几天刚学过一点python,发挥一点余热然后自行分析该脚本逻辑。脚本比较简单易懂
1.先拿出参数赋值到变量中
2.然后通过传进来参数路径解读configwikoinfo.ini文件
3.然后就是判断逻辑操作,组建字符串写入相应的文件中了。写入文件的输出路径显而易见,在本同脚本目录下
解读完脚本之后就会修改了,从逻辑上看,只要wik_build_fingerprint等于null,它就会根据产品信息和时间戳等信息生成fingerprint数值。前面已经提到了我的需求,不与上一版本的fingerprint一样。直接将onfigwikoinfo.ini的WIK_BUILD_FINGERPRINT_FR值注释,这样就解决了。之后还需要同意fingerprint。要求BUILD_NUMBER里面不包含android这个字符串,这也很简单注释掉BUILD_NUMBER = "android" + BUILD_NUMBER这条语句
bwc.mk除上面以外的还做了意见事情
PRODUCT_COPY_FILES += $(LOCAL_PATH)/unify/tools/BWC/du:system/vendor/wiko/du
PRODUCT_COPY_FILES += $(LOCAL_PATH)/unify/tools/BWC/fr:system/vendor/wiko/fr
PRODUCT_COPY_FILES += $(LOCAL_PATH)/unify/tools/BWC/id:system/vendor/wiko/id
PRODUCT_COPY_FILES += $(LOCAL_PATH)/unify/tools/BWC/my:system/vendor/wiko/my
PRODUCT_COPY_FILES += $(LOCAL_PATH)/unify/tools/BWC/th:system/vendor/wiko/th
PRODUCT_COPY_FILES += $(LOCAL_PATH)/unify/tools/BWC/vn:system/vendor/wiko/vn
把脚本生成的信息文件copy到Android手机system/vendor/wiko 目录下,以备手机读取其中的信息。
真正意义上了解了Python的用处与强大。
打完Patch跑GMS出现错误,Google对于GMS认证要求是不断更新,毫无疑问,项目越久要求越多
果然,跑玩一轮GMS准备修改fail,又下面这种情况
Hi SPMs & TLs
根据谷歌最新的BTS(谷歌从6月份才强制check BTS测试)测试通知,要求fingerprint里的时间戳版本号要和ro.build.version.incremental的值保持一致,我们当前很多项目因为不一致导致送测3PL被拒,各位请及时安排工程师进行check和修改
*理解了这种模式其实修改起来十分简单,首先查看buildinfo.sh文件 echo "ro.build.version.incremental=$BUILD_NUMBER" 由此可知,ro.build.version.incremental这个值是等于BUILD_NUMBER宏,具体值eng.android.{时间戳},具体构造在build仓库脚本下,懒得看了。
*由上面那个buildwiko.py脚本可知,BUILD_NUMBER这个值不是取的Android项目整个宏,而是自己在脚本中构造的,部分代码如下:
(status, BUILD_NUMBER) = commands.getstatusoutput('date +%s -d \'+121 min\'')
刚开始这就让我十分头疼了,脚本代码生成的时间戳,毫无疑问不满足Google最新BTS测试通知,如何修改就从这个脚本入手了,首先如何取得这个宏,如何去得到呢?对这方面毫无经验
不过看到bwc.mk文件中
result := $(shell ./vendor/tinno/requirement/wik_common/unify/tools/BWC/buildwiko.py "${wik_config_path}" "WIKO" "$(PLATFORM_VERSION)" "$(BUILD_ID)" "$(TARGET_BUILD_VARIANT)" "release-keys")
这段,我猜想$(PLATFORM_VERSION)这种就是取得Android项目中的宏,然后当做脚本参数传入其中,抱着这种猜想,试试。
result := $(shell ./vendor/tinno/requirement/wik_common/unify/tools/BWC/buildwiko.py "${wik_config_path}" "WIKO" "$(PLATFORM_VERSION)" "$(BUILD_ID)" "$(TARGET_BUILD_VARIANT)" "release-keys" "$(BUILD_NUMBER)")
就改成这样,然后依葫芦画瓢,在buildwiko.py中接收参数 BUILD_NUMBER = sys.argv[7] ,然后对这个自行改造 BUILD_NUMBER = BUILD_NUMBER[12:],只截取时间戳的部分。既然BUILD_NUMBER是作为参数传入,就不需要自己在脚本中构造。build_wiko_config(config_file_path):函数中关于BUILD_NUMBER构造全部都删了。