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

Commit 12c195d2 authored by Steve Kondik's avatar Steve Kondik
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
parent 6085e8a9
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -1304,12 +1304,19 @@ else
    $(INTERNAL_OTA_PACKAGE_TARGET): backuptool := false
endif

ifeq ($(TARGET_OTA_ASSERT_DEVICE),)
    $(INTERNAL_OTA_PACKAGE_TARGET): override_device := auto
else
    $(INTERNAL_OTA_PACKAGE_TARGET): override_device := $(TARGET_OTA_ASSERT_DEVICE)
endif

$(INTERNAL_OTA_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(OTATOOLS)
	@echo "Package OTA: $@"
	$(OTA_FROM_TARGET_SCRIPT) -v \
	   -p $(HOST_OUT) \
           -k $(KEY_CERT_PAIR) \
           --backup=$(backuptool) \
	   --override_device=$(override_device) \
           $(BUILT_TARGET_FILES_PACKAGE) $@
ifneq ($(TARGET_CUSTOM_RELEASETOOL),)
	@echo "Running releasetool"
+4 −2
Original line number Diff line number Diff line
@@ -87,8 +87,10 @@ class EdifyGenerator(object):

  def AssertDevice(self, device):
    """Assert that the device identifier is the given string."""
    cmd = ('assert(getprop("ro.product.device") == "%s" ||\0'
           'getprop("ro.build.product") == "%s");' % (device, device))
    cmd = ('assert(' +
           ' || \0'.join(['getprop("ro.product.device") == "%s" || getprop("ro.build.product") == "%s"'
                         % (i, i) for i in device.split(",")]) +
           ');')
    self.script.append(self._WordWrap(cmd))

  def AssertSomeBootloader(self, *bootloaders):
+11 −2
Original line number Diff line number Diff line
@@ -56,6 +56,9 @@ Usage: ota_from_target_files [flags] input_target_files output_ota_package
      Enable or disable the execution of backuptool.sh.
      Disabled by default.

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

"""

import sys
@@ -93,6 +96,7 @@ OPTIONS.extra_script = None
OPTIONS.aslr_mode = True
OPTIONS.worker_threads = 3
OPTIONS.backuptool = False
OPTIONS.override_device = 'auto'

def MostPopularKey(d, default):
  """Given a dict, return the key corresponding to the largest
@@ -314,7 +318,10 @@ def SignOutput(temp_zip_name, output_zip_name):


def AppendAssertions(script, input_zip):
  if OPTIONS.override_device == "auto":
    device = GetBuildProp("ro.product.device", input_zip)
  else:
    device = OPTIONS.override_device
  script.AssertDevice(device)


@@ -775,6 +782,8 @@ def main(argv):
      OPTIONS.worker_threads = int(a)
    elif o in ("--backup"):
      OPTIONS.backuptool = bool(a.lower() == 'true')
    elif o in ("--override_device"):
      OPTIONS.override_device = a
    else:
      return False
    return True
@@ -790,7 +799,7 @@ def main(argv):
                                              "worker_threads=",
                                              "aslr_mode=",
                                              "backup=",
                                              ],
                                              "override_device="],
                             extra_option_handler=option_handler)

  if len(args) != 2: