Android OTA系统升级---原理一

最近公司有个需求需要搭建服务器,通过对终端系统进行网络升级。对相关知识进行整理。

android中OTA进行升级,首先需要使用源码中OTA升级包打包工具: build/tools/releasetools/ota_from_target_files 生成OTA包。包有两类:整体完全升级包和增量升级包。

在android系统编译环境下,在终端下使用make otapackage生成。


android平台使用了提供了android.os.RecoverySystem工具类支持升级,需要添加android.Manifest.permission#REBOOT permission,  而REBOOT权限需要添加android:shareUserId="android.uid.system",进行系统签名,赋予升级平台权限后,才能支持升级,或是升级app在系统源码编译环境中编译后才能使用该功能。


使用RecoverySystem工具类,需要两个步骤。

1、   进行签名验证,public static void verifyPackage(File packageFile,
                                     ProgressListener listener,
                                     File deviceCertsZipFile)   throws IOException, GeneralSecurityException 

     * @param packageFile 待验证的升级包
     * @param listener   升级进度监听器,验证的进度
     * @param deviceCertsZipFile   验证证书文件,如果为null, 系统默认的是 "/system/etc/security/otacerts.zip"。
  

    private static final File DEFAULT_KEYSTORE =    new File("/system/etc/security/otacerts.zip")

    /** 通过/cache/recovery/command,与系统通信,接收升级命令指令,详细可以查看源码: bootable/recovery/recovery.c. */
    private static File RECOVERY_DIR = new File("/cache/recovery");
    private static File COMMAND_FILE = new File(RECOVERY_DIR, "command");

//验证OTA升级包方法

    public static void verifyPackage(File packageFile,
                                     ProgressListener listener,
                                     File deviceCertsZipFile)
        throws IOException, GeneralSecurityException {
        long fileLen = packageFile.length();
        RandomAccessFile raf = new RandomAccessFile(packageFile, "r");
        try {
            int lastPercent = 0;
            long lastPublishTime = System.currentTim

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
等到root权限 ,将解压的得到的三个文件复制到\\system\\etc 下 从文件夹名称来看保存的都是系统的配置文件,比如APN接入点设置等核心配置。 \\system\\etc\\apns-conf.xml APN接入点配置文件 \\system\\etc\\AudioFilter.csv 音频过滤器配置文件 \\system\\etc\\AudioPara4.csv \\system\\etc\\bookmarks.xml 书签数据库 \\system\\etc\\dbus.conf 总线监视配置文件 \\system\\etc\\dhcpcd \\system\\etc\\event-log-tags \\system\\etc\\favorites.xml 收藏夹 \\system\\etc\\firmware 固件信息 \\system\\etc\\gps.conf GPS设置文件 \\system\\etc\\hcid.conf内核HCID配置文件 \\system\\etc\\hosts 网络DNS缓存 \\system\\etc\\init.goldfish.sh \\system\\etc\\location 定位相关 \\system\\etc\\mountd.conf 存储挂载配置文件 \\system\\etc\\NOTICE.html 提示网页 \\system\\etc\\permissions.xml 权限许可 \\system\\etc\\pvplayer.conf \\system\\etc\\security \\system\\etc\\wifi WLAN相关组件 \\system\\etc\\dhcpcd\\dhcpcd-hooks \\system\\etc\\dhcpcd\\dhcpcd-run-hooks \\system\\etc\\dhcpcd\\dhcpcd.conf \\system\\etc\\dhcpcd\\dhcpcd-hooks\\01-test \\system\\etc\\dhcpcd\\dhcpcd-hooks\\20-dns.conf \\system\\etc\\dhcpcd\\dhcpcd-hooks\\95-configured \\system\\etc\\firmware\\brf6300.bin \\system\\etc\\location\\gps \\system\\etc\\location\\gps\\location 定位相关 \\system\\etc\\location\\gps\\nmea GPS数据解析 \\system\\etc\\location\\gps\\properties \\system\\etc\\security\\cacerts.bks \\system\\etc\\security\\otacerts.zip OTA下载验证 \\system\\etc\\wifi\\Fw1251r1c.bin \\system\\etc\\wifi\\tiwlan.ini \\system\\etc\\wifi\\wpa_supplicant.conf WPA验证组件
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值