Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0ab4e219 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Rename ota_utils.Payload to PayloadGenerator"

parents 5137db03 fa928694
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -263,7 +263,7 @@ import care_map_pb2
import common
import ota_utils
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
import target_files_diff
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 = GetPackageMetadata(target_info, source_info)
  # Generate payload.
  payload = Payload()
  payload = PayloadGenerator()

  partition_timestamps_flags = []
  # 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".
    secondary_target_file = GetTargetFilesZipForSecondaryImages(
        target_file, OPTIONS.skip_postinstall)
    secondary_payload = Payload(secondary=True)
    secondary_payload = PayloadGenerator(secondary=True)
    secondary_payload.Generate(secondary_target_file,
                               additional_args=["--max_timestamp",
                                                max_timestamp])
+6 −6
Original line number Diff line number Diff line
@@ -707,7 +707,7 @@ def IsZucchiniCompatible(source_file: str, target_file: str):
  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."""

  PAYLOAD_BIN = 'payload.bin'
@@ -828,11 +828,11 @@ class Payload(object):
    assert self.payload_properties is not None

    if self.secondary:
      payload_arcname = Payload.SECONDARY_PAYLOAD_BIN
      payload_properties_arcname = Payload.SECONDARY_PAYLOAD_PROPERTIES_TXT
      payload_arcname = PayloadGenerator.SECONDARY_PAYLOAD_BIN
      payload_properties_arcname = PayloadGenerator.SECONDARY_PAYLOAD_PROPERTIES_TXT
    else:
      payload_arcname = Payload.PAYLOAD_BIN
      payload_properties_arcname = Payload.PAYLOAD_PROPERTIES_TXT
      payload_arcname = PayloadGenerator.PAYLOAD_BIN
      payload_properties_arcname = PayloadGenerator.PAYLOAD_PROPERTIES_TXT

    # 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
+18 −18
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
import copy
import os
import os.path
import tempfile
import zipfile

import common
@@ -24,15 +25,14 @@ import ota_metadata_pb2
import test_utils
from ota_utils import (
    BuildLegacyOtaMetadata, CalculateRuntimeDevicesAndFingerprints,
    ConstructOtaApexInfo, FinalizeMetadata, GetPackageMetadata, PropertyFiles)
    ConstructOtaApexInfo, FinalizeMetadata, GetPackageMetadata, PropertyFiles, AbOtaPropertyFiles, PayloadGenerator, StreamingPropertyFiles)
from ota_from_target_files import (
    _LoadOemDicts, AbOtaPropertyFiles,
    _LoadOemDicts,
    GetTargetFilesZipForCustomImagesUpdates,
    GetTargetFilesZipForPartialUpdates,
    GetTargetFilesZipForSecondaryImages,
    GetTargetFilesZipWithoutPostinstallConfig,
    Payload, POSTINSTALL_CONFIG,
    StreamingPropertyFiles, AB_PARTITIONS)
    POSTINSTALL_CONFIG, AB_PARTITIONS)
from apex_utils import GetApexInfoFromTargetFiles
from test_utils import PropertyFilesTestCase
from common import OPTIONS
@@ -975,7 +975,7 @@ class AbOtaPropertyFilesTest(PropertyFilesTestCase):
  @test_utils.SkipIfExternalToolsUnavailable()
  def test_GetPayloadMetadataOffsetAndSize(self):
    target_file = construct_target_files()
    payload = Payload()
    payload = PayloadGenerator()
    payload.Generate(target_file)

    payload_signer = PayloadSigner()
@@ -1040,7 +1040,7 @@ class AbOtaPropertyFilesTest(PropertyFilesTestCase):
  def construct_zip_package_withValidPayload(with_metadata=False):
    # Cannot use construct_zip_package() since we need a "valid" payload.bin.
    target_file = construct_target_files()
    payload = Payload()
    payload = PayloadGenerator()
    payload.Generate(target_file)

    payload_signer = PayloadSigner()
@@ -1222,7 +1222,7 @@ class PayloadTest(test_utils.ReleaseToolsTestCase):
  @staticmethod
  def _create_payload_full(secondary=False):
    target_file = construct_target_files(secondary)
    payload = Payload(secondary)
    payload = PayloadGenerator(secondary)
    payload.Generate(target_file)
    return payload

@@ -1230,7 +1230,7 @@ class PayloadTest(test_utils.ReleaseToolsTestCase):
  def _create_payload_incremental():
    target_file = construct_target_files()
    source_file = construct_target_files()
    payload = Payload()
    payload = PayloadGenerator()
    payload.Generate(target_file, source_file)
    return payload

@@ -1248,7 +1248,7 @@ class PayloadTest(test_utils.ReleaseToolsTestCase):
  def test_Generate_additionalArgs(self):
    target_file = construct_target_files()
    source_file = construct_target_files()
    payload = Payload()
    payload = PayloadGenerator()
    # This should work the same as calling payload.Generate(target_file,
    # source_file).
    payload.Generate(
@@ -1259,7 +1259,7 @@ class PayloadTest(test_utils.ReleaseToolsTestCase):
  def test_Generate_invalidInput(self):
    target_file = construct_target_files()
    common.ZipDelete(target_file, 'IMAGES/vendor.img')
    payload = Payload()
    payload = PayloadGenerator()
    self.assertRaises(common.ExternalError, payload.Generate, target_file)

  @test_utils.SkipIfExternalToolsUnavailable()
@@ -1327,13 +1327,13 @@ class PayloadTest(test_utils.ReleaseToolsTestCase):
    with zipfile.ZipFile(output_file) as verify_zip:
      # First make sure we have the essential entries.
      namelist = verify_zip.namelist()
      self.assertIn(Payload.PAYLOAD_BIN, namelist)
      self.assertIn(Payload.PAYLOAD_PROPERTIES_TXT, namelist)
      self.assertIn(PayloadGenerator.PAYLOAD_BIN, namelist)
      self.assertIn(PayloadGenerator.PAYLOAD_PROPERTIES_TXT, namelist)

      # Then assert these entries are stored.
      for entry_info in verify_zip.infolist():
        if entry_info.filename not in (Payload.PAYLOAD_BIN,
                                       Payload.PAYLOAD_PROPERTIES_TXT):
        if entry_info.filename not in (PayloadGenerator.PAYLOAD_BIN,
                                       PayloadGenerator.PAYLOAD_PROPERTIES_TXT):
          continue
        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:
      # First make sure we have the essential entries.
      namelist = verify_zip.namelist()
      self.assertIn(Payload.SECONDARY_PAYLOAD_BIN, namelist)
      self.assertIn(Payload.SECONDARY_PAYLOAD_PROPERTIES_TXT, namelist)
      self.assertIn(PayloadGenerator.SECONDARY_PAYLOAD_BIN, namelist)
      self.assertIn(PayloadGenerator.SECONDARY_PAYLOAD_PROPERTIES_TXT, namelist)

      # Then assert these entries are stored.
      for entry_info in verify_zip.infolist():
        if entry_info.filename not in (
                Payload.SECONDARY_PAYLOAD_BIN,
                Payload.SECONDARY_PAYLOAD_PROPERTIES_TXT):
                PayloadGenerator.SECONDARY_PAYLOAD_BIN,
                PayloadGenerator.SECONDARY_PAYLOAD_PROPERTIES_TXT):
          continue
        self.assertEqual(zipfile.ZIP_STORED, entry_info.compress_type)