RK3229平台Android6.0系统添加广升OTA升级功能

  1. 添加脚本:

build/core/FotaInfo.sh

#!/bin/bash

#********Do not modify this file. If you want modify this file, pls contact our FAE*******
echo ""
echo "# begin fota properties"
echo "ro.fota.platform=RK3229"
#type info: phone, pad ,box, tv
echo "ro.fota.type=hifi"
#oem info
echo "ro.fota.oem=CompanyName " #广升备案的公司名称
#model info, Settings->About phone->Model number
#FotaDevice=$(grep "ro.product.model=" "$1"|awk -F "=" '{print $NF}' )
#echo "ro.fota.device=SK04$FotaDevice" | sed  's/[^0-9a-zA-Z= ._-]//g'
echo "ro.fota.device=SK04"
#version number, Settings->About phone->Build number
#FotaVersion=$(grep "ro.build.display.id=" "$1"|awk -F "=" '{print $NF}' )`date +_%Y%m%d-%H%M`
FotaVersion=$(grep "ro.build.display.id=" "$1"|awk -F "=" '{print $NF}' )
echo "ro.fota.version=$FotaVersion"
echo "# end fota properties"
#********Do not modify this file. If you want modify this file, pls contact our FAE*******

build/core/getOtaPackage.sh
#!/bin/bash
# $1 - project name : e.g.

ROOTPATH="target_files-package"
mkdir -p $ROOTPATH

#build
mkdir -p  $ROOTPATH/build/target/product/
cp -a build/target/product/security/  $ROOTPATH/build/target/product/
mkdir -p $ROOTPATH/build/tools/
cp -ur build/tools/releasetools/  $ROOTPATH/build/tools/
#device
mkdir -p $ROOTPATH/device/rockchip/common/
cp -u device/rockchip/common/releasetools.py $ROOTPATH/device/rockchip/common/
#out
mkdir -p $ROOTPATH/out/host/linux-x86/bin/
cp -u out/host/linux-x86/bin/minigzip  out/host/linux-x86/bin/mkbootfs out/host/linux-x86/bin/mkbootimg out/host/linux-x86/bin/fs_config  out/host/linux-x86/bin/mkyaffs2image  out/host/linux-x86/bin/zipalign  out/host/linux-x86/bin/bsdiff out/host/linux-x86/bin/imgdiff out/host/linux-x86/bin/remkloader out/host/linux-x86/bin/mkparameter out/host/linux-x86/bin/drmsigntool out/host/linux-x86/bin/mkuserimg.sh  out/host/linux-x86/bin/make_ext4fs  out/host/linux-x86/bin/aapt  $ROOTPATH/out/host/linux-x86/bin/
cp -u out/host/linux-x86/bin/simg2img  out/host/linux-x86/bin/e2fsck out/host/linux-x86/bin/build_verity_tree out/host/linux-x86/bin/verity_signer out/host/linux-x86/bin/append2simg out/host/linux-x86/bin/boot_signer $ROOTPATH/out/host/linux-x86/bin/
mkdir -p $ROOTPATH/out/host/linux-x86/framework
cp -u out/host/linux-x86/framework/signapk.jar  out/host/linux-x86/framework/dumpkey.jar $ROOTPATH/out/host/linux-x86/framework/

#libc++.so
mkdir -p $ROOTPATH/out/host/linux-x86/lib64/
cp -u out/host/linux-x86/lib64/libc++.so $ROOTPATH/out/host/linux-x86/lib64/

#ota.zip
#cp -u $1/*.zip $ROOTPATH/org.zip
#org.zip
echo `ls -lrt $1/obj/PACKAGING/target_files_intermediates/*target_files*.zip|tail -n 1|awk '{print $NF}'`
cp -u `ls -lrt $1/obj/PACKAGING/target_files_intermediates/*target_files*.zip|tail -n 1|awk '{print $NF}'`  $ROOTPATH/ota_target_files.zip
mkdir -p IMAGES/
touch IMAGES/system.img
touch IMAGES/userdata.img
zip -q $ROOTPATH/ota_target_files.zip IMAGES/system.img IMAGES/userdata.img
rm -rf IMAGES
#build.prop
cp -u $1/system/build.prop $ROOTPATH/build.prop

#configure.xml
echo "">$ROOTPATH/configure.xml
echo "">>$ROOTPATH/configure.xml

#buildnumber
var=$(grep  "ro.fota.version=" "$1/system/build.prop" )
buildnumber=${var##"ro.fota.version="}
echo "$buildnumber">>$ROOTPATH/configure.xml

#language
var=$(grep  "ro.product.locale=" "$1/system/build.prop" )
echo "${var##"ro.product.locale="}">>$ROOTPATH/configure.xml

#oem
var=$(grep  "ro.fota.oem=" "$1/system/build.prop" )
echo "${var##"ro.fota.oem="}">>$ROOTPATH/configure.xml

#operator
var=$(grep  "ro.operator.optr=" "$1/system/build.prop")
if [ "$var" = "" ] ; then
  var=other
else
var=$(echo $var|tr A-Z a-z)
if [ ${var##"ro.operator.optr="} = op01 ] ; then
var=CMCC
elif [ ${var##"ro.operator.optr="} = op02 ] ; then
var=CU
else
var=other
fi
fi
echo "${var##"ro.operator.optr="}">>$ROOTPATH/configure.xml

#model
var=$(grep  "ro.fota.device=" "$1/system/build.prop" )
product=${var##"ro.fota.device="}
echo "$product">>$ROOTPATH/configure.xml

#publishtime
echo "$(date +20%y%m%d%H%M%S)">>$ROOTPATH/configure.xml

#versionname
echo "$buildnumber">>$ROOTPATH/configure.xml
#key
echo "$2">>$ROOTPATH/configure.xml
echo "">>$ROOTPATH/configure.xml

if [ -f $1/target_files-package.zip ]; then
echo "delete exist file:$1/target_files-package"
rm -f $1/target_files-package.zip
fi

#zip
cd target_files-package
zip -rq target_files-package.zip build device out configure.xml build.prop ota_target_files.zip
cd ..
mv target_files-package/target_files-package.zip $1/target_files-package.zip
rm -rf target_files-package

2.修改Makefile

build/core/Makefile

……//此处省略好多行
#abupdate fota start
ifeq ($(strip $(ABUPDATE_FOTA_SUPPORT)), yes)
FOTA_SH := build/core/FotaInfo.sh
endif
#abupdate fota end
BUILDINFO_SH := build/tools/buildinfo.sh
……//此处省略好多行
#abupdate fota start
ifeq ($(strip $(ABUPDATE_FOTA_SUPPORT)), yes)
        @echo "Target FotaInfo: $@"
        $(hide) chmod 777 $(FOTA_SH)
        bash $(FOTA_SH) $@ >> $@
endif
#abupdate fota end

build_desc :=

ifeq (,$(filter true, $(TARGET_NO_KERNEL) $(TARGET_NO_RECOVERY)))
INSTALLED_RECOVERYIMAGE_TARGET := $(PRODUCT_OUT)/recovery.img
else
INSTALLED_RECOVERYIMAGE_TARGET :=
Endif
……//此处省略好多行
#abupdate fota start
ifeq ($(strip $(ABUPDATE_FOTA_SUPPORT)), yes)
        @echo "Package FotaPackage"
        $(hide) chmod 777 build/core/getOtaPackage.sh
        bash build/core/getOtaPackage.sh $(PRODUCT_OUT) $(KEY_CERT_PAIR) $(TARGET_DEVICE) $(HOST_LIBRARY_PATH) $(HOST_SHLIB_SUFFIX)
endif
#abupdate fota end

.PHONY: otapackage
otapackage: $(INTERNAL_OTA_PACKAGE_TARGET)
……//此处省略好多行

3.修改BoardConfig.mk:

device/rockchip/rk322x/BoardConfig.mk

……//此处省略好多行
#abupdatefota start
ABUPDATE_FOTA_SUPPORT = yes
#abupdatefota end

4.最后修改根目录下的总编译脚本build_all.sh:

在make -j16之后添加

# build otapackage
echo "start build otapackage"
cd build/tools/drmsigntool && mm -B && cd -
make otapackage
# mkimage.sh
echo "make and copy android images"
# Note:it is neccessary to add ota.
./mkimage.sh ota

5.以上都做完之后每次全编译代码会生成OTA整包文件:target_files-package.zip,两个版本之间的整包通过广升提供的工具(IOTdeltaTool2.0.0.5_2018.3.23.zip)就可以做差分包了,最后在服务器上配置差分升级即可。

 

注意:

1). IOTdeltaTool2.0.0.5_2018.3.23.zip需要解压,然后在JDK1.8上通过指令(java -jar IOTdeltaTool2.0.0.5.jar)来运行。

2). 运行中可能存在环境错误,这时需要再安装(adups-delta-5.0.24.deb)

sudo dpkg -i adups-delta-5.0.24.deb

你可能感兴趣的:(Android开发)