From eb06afb602a95668ae401a62295282ee18be516c Mon Sep 17 00:00:00 2001 From: Tianjie Date: Thu, 11 Jun 2020 22:51:07 -0700 Subject: [PATCH] Fix the read on a closed zipfile When calculating the dynamic fingerprints, we need to reopen the input file if it's a ZipFile. Because the original object has been closed. Bug: 152167826 Test: generate an OTA package with zip input and overrides Change-Id: I623da3cc5fcc91c6230fb5a6e86517ed995913b7 --- tools/releasetools/ota_from_target_files.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tools/releasetools/ota_from_target_files.py b/tools/releasetools/ota_from_target_files.py index b75341410..3b68439d8 100755 --- a/tools/releasetools/ota_from_target_files.py +++ b/tools/releasetools/ota_from_target_files.py @@ -2012,9 +2012,16 @@ def CalculateRuntimeDevicesAndFingerprints(build_info, boot_variable_values): info_dict = copy.deepcopy(build_info.info_dict) for partition in common.PARTITIONS_WITH_CARE_MAP: partition_prop_key = "{}.build.prop".format(partition) - old_props = info_dict[partition_prop_key] - info_dict[partition_prop_key] = common.PartitionBuildProps.FromInputFile( - old_props.input_file, partition, placeholder_values) + input_file = info_dict[partition_prop_key].input_file + if isinstance(input_file, zipfile.ZipFile): + with zipfile.ZipFile(input_file.filename) as input_zip: + info_dict[partition_prop_key] = \ + common.PartitionBuildProps.FromInputFile(input_zip, partition, + placeholder_values) + else: + info_dict[partition_prop_key] = \ + common.PartitionBuildProps.FromInputFile(input_file, partition, + placeholder_values) info_dict["build.prop"] = info_dict["system.build.prop"] new_build_info = common.BuildInfo(info_dict, build_info.oem_dicts)