首页 > 其他分享 >Android官方资料--Reducing OTA Size

Android官方资料--Reducing OTA Size

时间:2023-09-06 13:05:51浏览次数:40  
标签:googlesource -- OTA platform build file Android com android


Reducing OTA Size


IN THIS DOCUMENT

  1. The build diff tool
  2. Changes to reduce OTA size
  1. File Order
  2. Build Directory
  3. Timestamps
  4. Version Strings
  5. Consistent build tools



A common problem with Android over-the-air updates (OTAs) is that they contain changed files that do not correspond to code changes, but instead are artifacts of the build system. This happens whenever the same code, built at different times, from different directories, or on different machines, produces a large number of changed files. The excess files not only increase the size of an OTA, but make it difficult to determine which code is changed in the OTA.

To make the contents of an OTA more transparent, we have added a number of build system changes that reduce the size of an OTA by eliminating unnecessary file changes between builds. The aim is to reduce the size of OTAs to include only the files that relate to the patches contained in the OTA. We have also introduced a build diff tool that filters out common build-related file changes and provides a cleaner build file diff (see below).

This document provides an explanation of some of the build changes that have been added to AOSP to reduce unnecessary file changes between builds. For device implementers who maintain their own build system, it provides a guide to some of the changes that need to be made to reduce OTA size.

The build diff tool

Since there are cases where it is not possible to eliminate build-related file changes, we have supplied a build diff tool, target_files_diff.py, that can be used to compare two target file packages.

The build diff tool does a recursive diff between two builds, excluding common build-related file changes. Excluded changes include the following:

  • Expected changes in the build output (for example, due to build number changing).
  • Changes due to known issues in the current build system.

To use the build diff tool, run the following command:

$ target_files_diff.py dir1 dir2

where dir1 and dir2

Changes to reduce OTA size


There are several ways that the build system can create unnecessary file diffs. In the following sections, we discuss some of these issues, discuss solutions, and, where possible, show examples of the fixes in AOSP.

File Order

Problem: Filesystems don’t guarantee a file order when asked for a list of files in a directory, though it’s commonly the same for the same checkout. Tools such as ls sort the results by default, but the wildcard function used by commands such as find and make do not. So when any of these tools are used, you need to sort the outputs before using them.Solution: Users of tools such as find and makeExamples: Many instances of this were fixed in the core build system, especially when you use the builtin all-*-files-under macros (and all-cpp-files-under

Build Directory

Problem: Changing the directory in which things are built can cause the binaries to be different. Most paths in the android build are relative paths, so __FILE__But the debug symbols encode the full pathname by default. Then the .note.gnu.build-id

Solution: To fix this, AOSP master has been changed to make the debug paths relative, as shown here:

Timestamps

Problem: Timestamps in the build output result in unnecessary file changes. Two places this is likely to happen are the following:

__DATE__/__TIME__/__TIMESTAMP__ 

  • macros in C or C++ code.
  • Timestamps embedded in zip-based archives.

Solutions/Examples:

To remove timestamps from the build output in each of these instances, see the instructions in the sections below.

__DATE__/__TIME__/__TIMESTAMP__ in C/C++

These macros always produce different outputs for different builds, so they shouldn’t be used.

Here are a few options on how to eliminate these macros:

We have turned on -Werror=date-time, so that using timestamps is a build error.

Embedded Timestamps in Zip-based archives (zip, jar)

We fixed the problem of embedded timestamps in zip archives by adding -X to all uses of the zipA new tool, ziptime, resets the normal timestamps in the zip headers:

For more information, see the README file.

The signapk

Version Strings

Problem: APK version strings often had the BUILD_NUMBER appended to the hardcoded version. So even if nothing else changed in the APK, the APK would still be different.

Solution: Remove the build number from the APK version string.

Examples:

Consistent build tools

Problem: Any tools that generate installed files need to be consistent, that is, the same input should always produce the same output.

Solutions/Examples: Changes were required in the following build tools:

  • NOTICE file creator 
    The NOTICE file creator needed the following changes:
  • Java Android Compiler Kit (Jack) 
    The Jack toolchain required an update to handle an occasional change in generated constructor ordering:
  • ART AOT compiler (dex2oat)
    The ART compiler binary required an update to create a deterministic image:
  • The libpac.so file (V8)
    Every build creates a different /system/lib/libpac.so file, because the V8 snapshot changes for each build. The solution is to remove the snapshot:
  • Application pre-dexopt’d (.odex) files 
    The pre-dexopt’d (.odex) files contained uninitialized padding on 64-bit systems, requiring the following fix:

标签:googlesource,--,OTA,platform,build,file,Android,com,android
From: https://blog.51cto.com/u_16248677/7385155

相关文章

  • Android Recovery UI浅析1——概览
    最近在作一个在recovery中显示文字的工作,所以对这块研究较多,现在把研究的一点新的结果分享出来,如果有什么错误也欢迎大家在下面评论。 Android的Recovery中,利用 boottable/recovery下的minui库作为基础,采用的是直接存取framebuffer的方式,来完成recovery中所需的各种UI的绘制。......
  • Apache IoTDB开发系统整合之Hive TsFile
    TsFile-Hive-Connector用户指南关于TsFile-Hive-ConnectorTsFile-Hive-Connector实现了Hive对Tsfile类型的外部数据源的支持。这使用户能够按Hive操作Tsfile。使用此连接器,您可以将单个TsFile从本地文件系统或hdfs加载到hive中将特定目录中的所有文件(从本地文件系统或......
  • 二级医院信息系统源码(HIS) Angular+Nginx+ Java
    基层医疗云HIS作为基于云计算的B/S构架的HIS系统,为基层医疗机构提供了标准化的、信息化的、可共享的医疗信息管理系统,可有效进行医疗数据共享与交换,解决数据重复采集及信息孤岛等问题,实现对基层医疗数据的分析和挖掘,为基层卫生机构提供科学合理的业务管理服务。可实现“云部署”,即......
  • Android官方资料--Storage
    StorageINTHISDOCUMENTPermissionsRuntimepermissionsAndroidhasevolvedovertimetosupportawidevarietyofstoragedevicetypesandfeatures.AllversionsofAndroidsupportdeviceswithtraditionalstorage,whichincludesportableandemulateds......
  • 卫生间瓷砖铺贴方法
     卫生间瓷砖是墙压地还是地压墙,  卫生间是先铺地还是先铺墙  雅静说1,先铺墙,再铺地  优点,师父施工简单,人工费用低,瓦工师父干活方便,业主省钱  好打扫卫生,不伤害地面瓷砖  缺点,会有朝天缝,墙面的水流到缝隙,容易有异味和发霉,如果做了美缝......
  • Android官方资料--A/B System Updates
    A/BSystemUpdatesINTHISDOCUMENTOverviewBootloaderstateexamplesUpdateEnginefeaturesLifeofanA/BupdatePost-installstepImplementationKernelpatchesKernelcommandlineargumentsRecoveryBuildvariablesPartitionsFstabKernelslotargumentsOTApacka......
  • 重磅出击,微信小程序最新隐私协议弹窗解决方案
    微信官方公告❝微信日常整活,光权限和用户信息这一块不知道调整了多少次了,小程序开发者苦腾讯久已!上有政策,下有对策,这里讲解一下,新版本对线思路!❞啥都不说,先上社区评论为敬!友好评论1友好评论2这里展示的是原生小程序,因为Uniapp官网文档还没更新,其实方法都差不多,只是写法不同!前置问题......
  • 运维人的焦虑日常,等一个新的开始
    小春(化名),一个90后运维总监,需要统筹近60个项目,每天面临着各个项目的运维问题,她的工作就是帮助客户解决问题。小春总是尽最大努力在24小时内给客户一个满意的答复,她认为运维就是守护客户业务平稳、顺利进行。初困工作,手忙脚乱一天上午,客户在钉钉群艾特小春,“老师好,点扫描没有反应,不能......
  • 记一次生产项目Kubesphere中NS加入Workspace,致使NS数据删除事故
    一、前言2023年7月23日在项目上线前夕,k8s生产环境出现故障,经过紧急修复之后,k8s环境恢复正常;另外我们环境引入了kubesphere云原生平台技术,为了方便研发人员对于k8s权限的细粒度管理,我方手动将kubernetesnamespace(生产环境业务命名空间)加入到kubesphere中的workspace(企业空间),就在此......
  • Android官方资料--Device-Specific Code
    Device-SpecificCodeINTHISDOCUMENTPartitionmapRecoveryUIHeaderanditemfunctionsCustomizingCheckKeyScreenRecoveryUIDeviceClassStartRecoverySupplyingandmanagingrecoverymenuBuildandlinktodevicerecoveryRecoveryUIimagesAndroid5.xAndroid......