學習Android OTA相關
編譯Android code
進入android 根目錄
# first, build the target-files .zip
. build/envsetup.sh && lunch tardis-eng
mkdir dist_output
make dist DIST_DIR=dist_output #指定輸出dist_output目錄
Android 編譯輸出目錄
android 編譯生成的out目錄結構剖析
Android out目錄和linux啓動Android流程
Androd ota package 生成
Androd SW UPDATE LIFECYCLE
Android 編譯輸出目錄
Android 下提供的工具
build/make/tools/releasetools$
add_img_to_target_files
Given a target-files zipfile that does not contain images (ie, does
not have an IMAGES/ top-level subdirectory), produce the images and
add them to the zipfile.
ota_from_target_files
Given a target-files zipfile, produces an OTA package that installs
that build. An incremental OTA is produced if -i is given, otherwise
a full OTA is produced.
build_image
Build image output_image_file from input_directory, properties_file, and target_out_dir
check_ota_package_signature
Verify a given OTA package with the specifed certificate.
check_target_file_signatures
Check the signatures of all APKs in a target_files .zip file. With
-c, compare the signatures of each package to the ones in a separate
target_files (usually a previously distributed build for the same
device) and flag any changes.
img_from_target_files
Given a target-files zipfile, produces an image zipfile suitable for
use with ‘fastboot update’.
Google在Android系統了提供了自己的二進制差分工具,bsdiff/bspatch,代碼位於external/bsdiff目錄下。
在Ubuntu系統上可以直接通過apt進行安裝。
sudo apt-get install bsdiff
使用方法如下:
diff:
bsdiff oldfile newfile patch
patch:
bspatch oldfile newfile patch
雖然針對普通文件bsdiff/bspatch
效率非常高。但對於一些壓縮文件,由於壓縮前內容非常小的變化會導致壓縮後整個二進制文件產生非常巨大的變化,這樣patch文件會非常大。如Android系統中常用的boot.img/recovery.img,本質上就是一塊包含壓縮和非壓縮數據的二進制文件。
爲了解決這個問題,Android也提供了imgdiff
工具(bootable/recovery/applypatch)。在source文件中搜索壓縮部分(0x1f8b0800),將其劃分成多個小塊
imgdiff工具使用