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

Commit f57e0601 authored by Steve Kondik's avatar Steve Kondik Committed by Sam Mortimer
Browse files

Allow override of device asserts, including multi-device support.



Set in board file with TARGET_OTA_ASSERT_DEVICE.
(cherry-picked from commit 0f452f21)

Change-Id: I3d06bdc0e3e26bde0c0e646accd050364f9713b9

ota_from_target_files: Remove device dependent arguments

These device-specific arguments are defined at build time and are
necessary to generate the zip correctly. Don't use command line
arguments to specify them, but write all the needed information
in misc_info.txt when the target-files zip is generated.
ota_from_target_files will then read misc_info.txt and set
everything automatically.

Change-Id: Ibdbca575b76eb07b53fccfcea52a351c7e333f91
Signed-off-by: default avatarAndré Pinela <sheffzor@gmail.com>
parent 47ec8cd1
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -2354,6 +2354,7 @@ ifeq ($(BREAKPAD_GENERATE_SYMBOLS),true)
	@# If breakpad symbols have been generated, add them to the zip.
	$(hide) $(ACP) -r $(TARGET_OUT_BREAKPAD) $(zip_root)/BREAKPAD
endif
	$(hide) echo "ota_override_device=$(OTA_SCRIPT_OVERRIDE_DEVICE)" >> $(zip_root)/META/misc_info.txt
ifdef BOARD_PREBUILT_VENDORIMAGE
	$(hide) mkdir -p $(zip_root)/IMAGES
	$(hide) cp $(INSTALLED_VENDORIMAGE_TARGET) $(zip_root)/IMAGES/
@@ -2425,6 +2426,12 @@ INTERNAL_OTA_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip

$(INTERNAL_OTA_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)

ifeq ($(TARGET_OTA_ASSERT_DEVICE),)
    OTA_SCRIPT_OVERRIDE_DEVICE := auto
else
    OTA_SCRIPT_OVERRIDE_DEVICE := $(TARGET_OTA_ASSERT_DEVICE)
endif

$(INTERNAL_OTA_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) \
		build/tools/releasetools/ota_from_target_files
	@echo "Package OTA: $@"
+7 −5
Original line number Diff line number Diff line
@@ -145,11 +145,13 @@ class EdifyGenerator(object):

  def AssertDevice(self, device):
    """Assert that the device identifier is the given string."""
    cmd = ('getprop("ro.product.device") == "%s" || '
           'abort("E%d: This package is for \\"%s\\" devices; '
           'this is a \\"" + getprop("ro.product.device") + "\\".");') % (
               device, common.ErrorCode.DEVICE_MISMATCH, device)
    self.script.append(cmd)
    cmd = ('assert(' +
           ' || \0'.join(['getprop("ro.product.device") == "%s" || getprop("ro.build.product") == "%s"'
                         % (i, i) for i in device.split(",")]) +
           ' || abort("E%d: This package is for device: %s; ' +
           'this device is " + getprop("ro.product.device") + ".");' +
           ');') % (common.ErrorCode.DEVICE_MISMATCH, device)
    self.script.append(self.WordWrap(cmd))

  def AssertSomeBootloader(self, *bootloaders):
    """Asert that the bootloader version is one of *bootloaders."""
+14 −1
Original line number Diff line number Diff line
@@ -130,6 +130,9 @@ Usage: ota_from_target_files [flags] input_target_files output_ota_package

  --payload_signer_args <args>
      Specify the arguments needed for payload signer.

  --override_device <device>
      Override device-specific asserts. Can be a comma-separated list.
"""

from __future__ import print_function
@@ -181,6 +184,7 @@ OPTIONS.log_diff = None
OPTIONS.payload_signer = None
OPTIONS.payload_signer_args = []
OPTIONS.extracted_input = None
OPTIONS.override_device = 'auto'

METADATA_NAME = 'META-INF/com/android/metadata'
UNZIP_PATTERN = ['IMAGES/*', 'META/*']
@@ -197,7 +201,10 @@ def SignOutput(temp_zip_name, output_zip_name):
def AppendAssertions(script, info_dict, oem_dicts=None):
  oem_props = info_dict.get("oem_fingerprint_properties")
  if not oem_props:
    if OPTIONS.override_device == "auto":
      device = GetBuildProp("ro.product.device", info_dict)
    else:
      device = OPTIONS.override_device
    script.AssertDevice(device)
  else:
    if not oem_dicts:
@@ -1322,6 +1329,8 @@ def main(argv):
      OPTIONS.payload_signer_args = shlex.split(a)
    elif o == "--extracted_input_target_files":
      OPTIONS.extracted_input = a
    elif o in ("--override_device"):
      OPTIONS.override_device = a
    else:
      return False
    return True
@@ -1353,6 +1362,7 @@ def main(argv):
                                 "payload_signer=",
                                 "payload_signer_args=",
                                 "extracted_input_target_files=",
                                 "override_device=",
                             ], extra_option_handler=option_handler)

  if len(args) != 2:
@@ -1382,6 +1392,9 @@ def main(argv):
    OPTIONS.info_dict = common.LoadInfoDict(input_zip)
    common.ZipClose(input_zip)

  if "ota_override_device" in OPTIONS.info_dict:
    OPTIONS.override_device = OPTIONS.info_dict.get("ota_override_device")

  ab_update = OPTIONS.info_dict.get("ab_update") == "true"

  if ab_update: