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

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

Merge "Add spl-downgrade field to ota metadata"

parents 0e0307b0 05ff7055
Loading
Loading
Loading
Loading
+10 −4
Original line number Diff line number Diff line
@@ -230,7 +230,7 @@ import zipfile
import common
import ota_utils
from ota_utils import (UNZIP_PATTERN, FinalizeMetadata, GetPackageMetadata,
                       PropertyFiles)
                       PropertyFiles, SECURITY_PATCH_LEVEL_PROP_NAME)
import target_files_diff
from check_target_files_vintf import CheckVintfIfTrebleEnabled
from non_ab_ota import GenerateNonAbOtaPackage
@@ -292,7 +292,7 @@ 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):
@@ -1418,14 +1418,20 @@ def main(argv):
    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:
    is_spl_downgrade = target_spl < source_spl
    if is_spl_downgrade 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 "
        "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))
    elif not is_spl_downgrade and OPTIONS.spl_downgrade:
      raise ValueError("--spl_downgrade specified but no actual SPL downgrade"
                       " detected. Please only pass in this flag if you want a"
                       " SPL downgrade. Target SPL: {} Source SPL: {}"
                       .format(target_spl, source_spl))
  if generate_ab:
    GenerateAbOtaPackage(
        target_file=args[0],
+3 −0
Original line number Diff line number Diff line
@@ -105,4 +105,7 @@ message OtaMetadata {
  bool retrofit_dynamic_partitions = 7;
  // The required size of the cache partition, only valid for non-A/B update.
  int64 required_cache = 8;

  // True iff security patch level downgrade is permitted on this OTA.
  bool spl_downgrade = 9;
}
+53 −64

File changed.

Preview size limit exceeded, changes collapsed.

+8 −1
Original line number Diff line number Diff line
@@ -39,6 +39,8 @@ OPTIONS.boot_variable_file = None
METADATA_NAME = 'META-INF/com/android/metadata'
METADATA_PROTO_NAME = 'META-INF/com/android/metadata.pb'
UNZIP_PATTERN = ['IMAGES/*', 'META/*', 'OTA/*', 'RADIO/*']
SECURITY_PATCH_LEVEL_PROP_NAME = "ro.build.version.security_patch"


def FinalizeMetadata(metadata, input_file, output_file, needed_property_files):
  """Finalizes the metadata and signs an A/B OTA package.
@@ -317,6 +319,8 @@ def BuildLegacyOtaMetadata(metadata_proto):
    metadata_dict['pre-build'] = separator.join(pre_build.build)
    metadata_dict['pre-build-incremental'] = pre_build.build_incremental

  if metadata_proto.spl_downgrade:
    metadata_dict['spl-downgrade'] = 'yes'
  metadata_dict.update(metadata_proto.property_files)

  return metadata_dict
@@ -330,6 +334,9 @@ def HandleDowngradeMetadata(metadata_proto, target_info, source_info):
  pre_timestamp = source_info.GetBuildProp("ro.build.date.utc")
  is_downgrade = int(post_timestamp) < int(pre_timestamp)

  if OPTIONS.spl_downgrade:
    metadata_proto.spl_downgrade = True

  if OPTIONS.downgrade:
    if not is_downgrade:
      raise RuntimeError(
+6 −2

File changed.

Preview size limit exceeded, changes collapsed.