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

Commit 3f9b50a2 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Prevent SPL downgrade OTAs from generating" am: 28aab78e

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

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I93838ef94f6d132d5d889e59fbb4cb2e293c33b6
parents 449e59c8 28aab78e
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -273,6 +273,7 @@ OPTIONS.disable_verity_computation = False
OPTIONS.partial = None
OPTIONS.custom_images = {}
OPTIONS.disable_vabc = False
OPTIONS.spl_downgrade = False

POSTINSTALL_CONFIG = 'META/postinstall_config.txt'
DYNAMIC_PARTITION_INFO = 'META/dynamic_partitions_info.txt'
@@ -291,6 +292,8 @@ SECONDARY_PAYLOAD_SKIPPED_IMAGES = [
    'system_ext', 'vbmeta', 'vbmeta_system', 'vbmeta_vendor', 'vendor',
    'vendor_boot']

SECURITY_PATCH_LEVEL_PROP_NAME = "ro.build.version.security_patch"


class PayloadSigner(object):
  """A class that wraps the payload signing works.
@@ -1262,6 +1265,8 @@ def main(argv):
      OPTIONS.custom_images[custom_partition] = custom_image
    elif o == "--disable_vabc":
      OPTIONS.disable_vabc = True
    elif o == "--spl_downgrade":
      OPTIONS.spl_downgrade = True
    else:
      return False
    return True
@@ -1304,6 +1309,7 @@ def main(argv):
                                 "partial=",
                                 "custom_image=",
                                 "disable_vabc",
                                 "spl_downgrade"
                             ], extra_option_handler=option_handler)

  if len(args) != 2:
@@ -1400,6 +1406,19 @@ def main(argv):
    # Get signing keys
    OPTIONS.key_passwords = common.GetKeyPasswords([OPTIONS.package_key])

  if OPTIONS.source_info_dict:
    source_build_prop = OPTIONS.source_info_dict["build.prop"]
    target_build_prop = OPTIONS.target_info_dict["build.prop"]
    source_spl = source_build_prop.GetProp(SECURITY_PATCH_LEVEL_PROP_NAME)
    target_spl = target_build_prop.GetProp(SECURITY_PATCH_LEVEL_PROP_NAME)
    if target_spl < source_spl and not OPTIONS.spl_downgrade:
      raise common.ExternalError(
        "Target security patch level {} is older than source SPL {} applying "
        "such OTA will likely cause device fail to boot. Pass --spl-downgrade "
        "to override this check. This script expects security patch level to "
        "be in format yyyy-mm-dd (e.x. 2021-02-05). It's possible to use "
        "separators other than -, so as long as it's used consistenly across "
        "all SPL dates".format(target_spl, source_spl))
  if generate_ab:
    GenerateAbOtaPackage(
        target_file=args[0],