Merge "Rename ota_utils.Payload to PayloadGenerator" am: 0ab4e21939 am: 8ad6da6e9c am: 14511f3c2d

Original change: https://android-review.googlesource.com/c/platform/build/+/2188196

Change-Id: I45c3a94a6a2f5423211a595afe725cc0b4ed48d9
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Treehugger Robot
2022-08-31 06:37:10 +00:00
committed by Automerger Merge Worker
3 changed files with 27 additions and 27 deletions

View File

@@ -263,7 +263,7 @@ import care_map_pb2
import common import common
import ota_utils import ota_utils
from ota_utils import (UNZIP_PATTERN, FinalizeMetadata, GetPackageMetadata, from ota_utils import (UNZIP_PATTERN, FinalizeMetadata, GetPackageMetadata,
Payload, SECURITY_PATCH_LEVEL_PROP_NAME, StreamingPropertyFiles, AbOtaPropertyFiles) PayloadGenerator, SECURITY_PATCH_LEVEL_PROP_NAME, StreamingPropertyFiles, AbOtaPropertyFiles)
from common import IsSparseImage from common import IsSparseImage
import target_files_diff import target_files_diff
from check_target_files_vintf import CheckVintfIfTrebleEnabled from check_target_files_vintf import CheckVintfIfTrebleEnabled
@@ -893,7 +893,7 @@ def GenerateAbOtaPackage(target_file, output_file, source_file=None):
# Metadata to comply with Android OTA package format. # Metadata to comply with Android OTA package format.
metadata = GetPackageMetadata(target_info, source_info) metadata = GetPackageMetadata(target_info, source_info)
# Generate payload. # Generate payload.
payload = Payload() payload = PayloadGenerator()
partition_timestamps_flags = [] partition_timestamps_flags = []
# Enforce a max timestamp this payload can be applied on top of. # Enforce a max timestamp this payload can be applied on top of.
@@ -972,7 +972,7 @@ def GenerateAbOtaPackage(target_file, output_file, source_file=None):
# building an incremental OTA. See the comments for "--include_secondary". # building an incremental OTA. See the comments for "--include_secondary".
secondary_target_file = GetTargetFilesZipForSecondaryImages( secondary_target_file = GetTargetFilesZipForSecondaryImages(
target_file, OPTIONS.skip_postinstall) target_file, OPTIONS.skip_postinstall)
secondary_payload = Payload(secondary=True) secondary_payload = PayloadGenerator(secondary=True)
secondary_payload.Generate(secondary_target_file, secondary_payload.Generate(secondary_target_file,
additional_args=["--max_timestamp", additional_args=["--max_timestamp",
max_timestamp]) max_timestamp])

View File

@@ -578,7 +578,7 @@ class PropertyFiles(object):
else: else:
tokens.append(ComputeEntryOffsetSize(METADATA_NAME)) tokens.append(ComputeEntryOffsetSize(METADATA_NAME))
if METADATA_PROTO_NAME in zip_file.namelist(): if METADATA_PROTO_NAME in zip_file.namelist():
tokens.append(ComputeEntryOffsetSize(METADATA_PROTO_NAME)) tokens.append(ComputeEntryOffsetSize(METADATA_PROTO_NAME))
return ','.join(tokens) return ','.join(tokens)
@@ -707,7 +707,7 @@ def IsZucchiniCompatible(source_file: str, target_file: str):
return sourceEntry and targetEntry and sourceEntry == targetEntry return sourceEntry and targetEntry and sourceEntry == targetEntry
class Payload(object): class PayloadGenerator(object):
"""Manages the creation and the signing of an A/B OTA Payload.""" """Manages the creation and the signing of an A/B OTA Payload."""
PAYLOAD_BIN = 'payload.bin' PAYLOAD_BIN = 'payload.bin'
@@ -828,11 +828,11 @@ class Payload(object):
assert self.payload_properties is not None assert self.payload_properties is not None
if self.secondary: if self.secondary:
payload_arcname = Payload.SECONDARY_PAYLOAD_BIN payload_arcname = PayloadGenerator.SECONDARY_PAYLOAD_BIN
payload_properties_arcname = Payload.SECONDARY_PAYLOAD_PROPERTIES_TXT payload_properties_arcname = PayloadGenerator.SECONDARY_PAYLOAD_PROPERTIES_TXT
else: else:
payload_arcname = Payload.PAYLOAD_BIN payload_arcname = PayloadGenerator.PAYLOAD_BIN
payload_properties_arcname = Payload.PAYLOAD_PROPERTIES_TXT payload_properties_arcname = PayloadGenerator.PAYLOAD_PROPERTIES_TXT
# Add the signed payload file and properties into the zip. In order to # Add the signed payload file and properties into the zip. In order to
# support streaming, we pack them as ZIP_STORED. So these entries can be # support streaming, we pack them as ZIP_STORED. So these entries can be

View File

@@ -17,6 +17,7 @@
import copy import copy
import os import os
import os.path import os.path
import tempfile
import zipfile import zipfile
import common import common
@@ -24,15 +25,14 @@ import ota_metadata_pb2
import test_utils import test_utils
from ota_utils import ( from ota_utils import (
BuildLegacyOtaMetadata, CalculateRuntimeDevicesAndFingerprints, BuildLegacyOtaMetadata, CalculateRuntimeDevicesAndFingerprints,
ConstructOtaApexInfo, FinalizeMetadata, GetPackageMetadata, PropertyFiles) ConstructOtaApexInfo, FinalizeMetadata, GetPackageMetadata, PropertyFiles, AbOtaPropertyFiles, PayloadGenerator, StreamingPropertyFiles)
from ota_from_target_files import ( from ota_from_target_files import (
_LoadOemDicts, AbOtaPropertyFiles, _LoadOemDicts,
GetTargetFilesZipForCustomImagesUpdates, GetTargetFilesZipForCustomImagesUpdates,
GetTargetFilesZipForPartialUpdates, GetTargetFilesZipForPartialUpdates,
GetTargetFilesZipForSecondaryImages, GetTargetFilesZipForSecondaryImages,
GetTargetFilesZipWithoutPostinstallConfig, GetTargetFilesZipWithoutPostinstallConfig,
Payload, POSTINSTALL_CONFIG, POSTINSTALL_CONFIG, AB_PARTITIONS)
StreamingPropertyFiles, AB_PARTITIONS)
from apex_utils import GetApexInfoFromTargetFiles from apex_utils import GetApexInfoFromTargetFiles
from test_utils import PropertyFilesTestCase from test_utils import PropertyFilesTestCase
from common import OPTIONS from common import OPTIONS
@@ -975,7 +975,7 @@ class AbOtaPropertyFilesTest(PropertyFilesTestCase):
@test_utils.SkipIfExternalToolsUnavailable() @test_utils.SkipIfExternalToolsUnavailable()
def test_GetPayloadMetadataOffsetAndSize(self): def test_GetPayloadMetadataOffsetAndSize(self):
target_file = construct_target_files() target_file = construct_target_files()
payload = Payload() payload = PayloadGenerator()
payload.Generate(target_file) payload.Generate(target_file)
payload_signer = PayloadSigner() payload_signer = PayloadSigner()
@@ -1040,7 +1040,7 @@ class AbOtaPropertyFilesTest(PropertyFilesTestCase):
def construct_zip_package_withValidPayload(with_metadata=False): def construct_zip_package_withValidPayload(with_metadata=False):
# Cannot use construct_zip_package() since we need a "valid" payload.bin. # Cannot use construct_zip_package() since we need a "valid" payload.bin.
target_file = construct_target_files() target_file = construct_target_files()
payload = Payload() payload = PayloadGenerator()
payload.Generate(target_file) payload.Generate(target_file)
payload_signer = PayloadSigner() payload_signer = PayloadSigner()
@@ -1222,7 +1222,7 @@ class PayloadTest(test_utils.ReleaseToolsTestCase):
@staticmethod @staticmethod
def _create_payload_full(secondary=False): def _create_payload_full(secondary=False):
target_file = construct_target_files(secondary) target_file = construct_target_files(secondary)
payload = Payload(secondary) payload = PayloadGenerator(secondary)
payload.Generate(target_file) payload.Generate(target_file)
return payload return payload
@@ -1230,7 +1230,7 @@ class PayloadTest(test_utils.ReleaseToolsTestCase):
def _create_payload_incremental(): def _create_payload_incremental():
target_file = construct_target_files() target_file = construct_target_files()
source_file = construct_target_files() source_file = construct_target_files()
payload = Payload() payload = PayloadGenerator()
payload.Generate(target_file, source_file) payload.Generate(target_file, source_file)
return payload return payload
@@ -1248,7 +1248,7 @@ class PayloadTest(test_utils.ReleaseToolsTestCase):
def test_Generate_additionalArgs(self): def test_Generate_additionalArgs(self):
target_file = construct_target_files() target_file = construct_target_files()
source_file = construct_target_files() source_file = construct_target_files()
payload = Payload() payload = PayloadGenerator()
# This should work the same as calling payload.Generate(target_file, # This should work the same as calling payload.Generate(target_file,
# source_file). # source_file).
payload.Generate( payload.Generate(
@@ -1259,7 +1259,7 @@ class PayloadTest(test_utils.ReleaseToolsTestCase):
def test_Generate_invalidInput(self): def test_Generate_invalidInput(self):
target_file = construct_target_files() target_file = construct_target_files()
common.ZipDelete(target_file, 'IMAGES/vendor.img') common.ZipDelete(target_file, 'IMAGES/vendor.img')
payload = Payload() payload = PayloadGenerator()
self.assertRaises(common.ExternalError, payload.Generate, target_file) self.assertRaises(common.ExternalError, payload.Generate, target_file)
@test_utils.SkipIfExternalToolsUnavailable() @test_utils.SkipIfExternalToolsUnavailable()
@@ -1327,13 +1327,13 @@ class PayloadTest(test_utils.ReleaseToolsTestCase):
with zipfile.ZipFile(output_file) as verify_zip: with zipfile.ZipFile(output_file) as verify_zip:
# First make sure we have the essential entries. # First make sure we have the essential entries.
namelist = verify_zip.namelist() namelist = verify_zip.namelist()
self.assertIn(Payload.PAYLOAD_BIN, namelist) self.assertIn(PayloadGenerator.PAYLOAD_BIN, namelist)
self.assertIn(Payload.PAYLOAD_PROPERTIES_TXT, namelist) self.assertIn(PayloadGenerator.PAYLOAD_PROPERTIES_TXT, namelist)
# Then assert these entries are stored. # Then assert these entries are stored.
for entry_info in verify_zip.infolist(): for entry_info in verify_zip.infolist():
if entry_info.filename not in (Payload.PAYLOAD_BIN, if entry_info.filename not in (PayloadGenerator.PAYLOAD_BIN,
Payload.PAYLOAD_PROPERTIES_TXT): PayloadGenerator.PAYLOAD_PROPERTIES_TXT):
continue continue
self.assertEqual(zipfile.ZIP_STORED, entry_info.compress_type) self.assertEqual(zipfile.ZIP_STORED, entry_info.compress_type)
@@ -1365,14 +1365,14 @@ class PayloadTest(test_utils.ReleaseToolsTestCase):
with zipfile.ZipFile(output_file) as verify_zip: with zipfile.ZipFile(output_file) as verify_zip:
# First make sure we have the essential entries. # First make sure we have the essential entries.
namelist = verify_zip.namelist() namelist = verify_zip.namelist()
self.assertIn(Payload.SECONDARY_PAYLOAD_BIN, namelist) self.assertIn(PayloadGenerator.SECONDARY_PAYLOAD_BIN, namelist)
self.assertIn(Payload.SECONDARY_PAYLOAD_PROPERTIES_TXT, namelist) self.assertIn(PayloadGenerator.SECONDARY_PAYLOAD_PROPERTIES_TXT, namelist)
# Then assert these entries are stored. # Then assert these entries are stored.
for entry_info in verify_zip.infolist(): for entry_info in verify_zip.infolist():
if entry_info.filename not in ( if entry_info.filename not in (
Payload.SECONDARY_PAYLOAD_BIN, PayloadGenerator.SECONDARY_PAYLOAD_BIN,
Payload.SECONDARY_PAYLOAD_PROPERTIES_TXT): PayloadGenerator.SECONDARY_PAYLOAD_PROPERTIES_TXT):
continue continue
self.assertEqual(zipfile.ZIP_STORED, entry_info.compress_type) self.assertEqual(zipfile.ZIP_STORED, entry_info.compress_type)