From a567eae9adbccc100ff50c918d3cbac532a9f69a Mon Sep 17 00:00:00 2001 From: Daniel Zheng Date: Mon, 8 Jan 2024 14:20:49 -0800 Subject: [PATCH] Support configuring compression factor With the introduction of variable block sized compression. We want ota_from_target_files to support a flag that confgures the max block size for compression. This flag will be passed to delta_generator and then used fro cow estimation + ota installation Removing a function here as it looks like it's unused. We can modify the specified values with ModifyTargetFilesDynamicPartitionInfo(). The other function looks like it's just a wrapper. Test: ota_from_target_files. Change-Id: Ia17bf62d40f947ef1fbe543886f04d10acd5bcc9 --- tools/releasetools/ota_from_target_files.py | 25 ++++++++++++--------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/tools/releasetools/ota_from_target_files.py b/tools/releasetools/ota_from_target_files.py index b65764b589..29042a5cba 100755 --- a/tools/releasetools/ota_from_target_files.py +++ b/tools/releasetools/ota_from_target_files.py @@ -259,6 +259,9 @@ A/B OTA specific options --vabc_cow_version Specify the VABC cow version to be used + + --compression_factor + Specify the maximum block size to be compressed at once during OTA. supported options: 4k, 8k, 16k, 32k, 64k, 128k """ from __future__ import print_function @@ -331,6 +334,7 @@ OPTIONS.vabc_compression_param = None OPTIONS.security_patch_level = None OPTIONS.max_threads = None OPTIONS.vabc_cow_version = None +OPTIONS.compression_factor = None POSTINSTALL_CONFIG = 'META/postinstall_config.txt' @@ -393,17 +397,6 @@ def ModifyVABCCompressionParam(content, algo): """ return ModifyKeyvalueList(content, "virtual_ab_compression_method", algo) -def SetVABCCowVersion(content, cow_version): - """ Update virtual_ab_cow_version in dynamic_partitions_info.txt - Args: - content: The string content of dynamic_partitions_info.txt - algo: The cow version be used for VABC. See - https://cs.android.com/android/platform/superproject/main/+/main:system/core/fs_mgr/libsnapshot/include/libsnapshot/cow_format.h;l=36 - Returns: - Updated content of dynamic_partitions_info.txt , updated cow version - """ - return ModifyKeyvalueList(content, "virtual_ab_cow_version", cow_version) - def UpdatesInfoForSpecialUpdates(content, partitions_filter, delete_keys=None): @@ -1020,6 +1013,8 @@ def GenerateAbOtaPackage(target_file, output_file, source_file=None): target_file, vabc_compression_param) if OPTIONS.vabc_cow_version: target_file = ModifyTargetFilesDynamicPartitionInfo(target_file, "virtual_ab_cow_version", OPTIONS.vabc_cow_version) + if OPTIONS.compression_factor: + target_file = ModifyTargetFilesDynamicPartitionInfo(target_file, "virtual_ab_compression_factor", OPTIONS.compression_factor) if OPTIONS.skip_postinstall: target_file = GetTargetFilesZipWithoutPostinstallConfig(target_file) # Target_file may have been modified, reparse ab_partitions @@ -1280,6 +1275,13 @@ def main(argv): else: raise ValueError("Cannot parse value %r for option %r - only " "integers are allowed." % (a, o)) + elif o in ("--compression_factor"): + values = ["4k", "8k", "16k", "32k", "64k", "128k"] + if a[:-1].isdigit() and a in values and a.endswith("k"): + OPTIONS.compression_factor = str(int(a[:-1]) * 1024) + else: + raise ValueError("Please specify value from following options: 4k, 8k, 16k, 32k, 64k, 128k") + elif o == "--vabc_cow_version": if a.isdigit(): OPTIONS.vabc_cow_version = a @@ -1335,6 +1337,7 @@ def main(argv): "security_patch_level=", "max_threads=", "vabc_cow_version=", + "compression_factor=", ], extra_option_handler=[option_handler, payload_signer.signer_options]) common.InitLogging()