From fa41fb27054185b3fba0519d01dabd21444fe772 Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Tue, 8 Mar 2016 17:53:39 -0800 Subject: [PATCH] Use the update-binary in the source build for downgrade OTAs. We used to use the update-binary from the target build when creating incremental OTAs. But for downgrade OTAs, we should use the one in the source build instead, which is actually newer. Bug: 27556903 Change-Id: Ib6415729b979dbffdebdda24902f7f560942801a (cherry picked from commit 4996cf03d2321eef56a8163c7fc73ba9976e1021) --- tools/releasetools/ota_from_target_files.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/tools/releasetools/ota_from_target_files.py b/tools/releasetools/ota_from_target_files.py index 17b56da1c..e61c64f57 100755 --- a/tools/releasetools/ota_from_target_files.py +++ b/tools/releasetools/ota_from_target_files.py @@ -69,7 +69,8 @@ Usage: ota_from_target_files [flags] input_target_files output_ota_package build to an older one (based on timestamp comparison). "post-timestamp" will be replaced by "ota-downgrade=yes" in the metadata file. A data wipe will always be enforced, so "ota-wipe=yes" will also be included in - the metadata file. + the metadata file. The update-binary in the source build will be used in + the OTA package, unless --binary flag is specified. -e (--extra_script) Insert the contents of file at the end of the update script. @@ -1008,7 +1009,12 @@ endif; """ % bcb_dev) script.SetProgress(1) - script.AddToZip(target_zip, output_zip, input_path=OPTIONS.updater_binary) + # For downgrade OTAs, we prefer to use the update-binary in the source + # build that is actually newer than the one in the target build. + if OPTIONS.downgrade: + script.AddToZip(source_zip, output_zip, input_path=OPTIONS.updater_binary) + else: + script.AddToZip(target_zip, output_zip, input_path=OPTIONS.updater_binary) WriteMetadata(metadata, output_zip) @@ -1543,7 +1549,13 @@ endif; script.Unmount("/vendor") script.Mount("/vendor") vendor_diff.EmitExplicitTargetVerification(script) - script.AddToZip(target_zip, output_zip, input_path=OPTIONS.updater_binary) + + # For downgrade OTAs, we prefer to use the update-binary in the source + # build that is actually newer than the one in the target build. + if OPTIONS.downgrade: + script.AddToZip(source_zip, output_zip, input_path=OPTIONS.updater_binary) + else: + script.AddToZip(target_zip, output_zip, input_path=OPTIONS.updater_binary) WriteMetadata(metadata, output_zip)