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

Commit 0f452f21 authored by Steve Kondik's avatar Steve Kondik Committed by Abaakouk Mehdi
Browse files

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

Set in board file with TARGET_OTA_ASSERT_DEVICE.
parent 0fd93187
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -1081,12 +1081,19 @@ else
$(INTERNAL_OTA_PACKAGE_TARGET): backuptool := true
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: $@"
	$(hide) ./build/tools/releasetools/ota_from_target_files -v \
	   -p $(HOST_OUT) \
           -k $(KEY_CERT_PAIR) \
           --backup=$(backuptool) \
	   --override_device=$(override_device) \
           $(BUILT_TARGET_FILES_PACKAGE) $@

.PHONY: otapackage
+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):
+12 −2
Original line number Diff line number Diff line
@@ -48,6 +48,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
@@ -80,6 +83,7 @@ OPTIONS.omit_prereq = False
OPTIONS.extra_script = None
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
@@ -292,7 +296,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)


@@ -723,6 +730,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
@@ -736,7 +745,8 @@ def main(argv):
                                              "no_prereq",
                                              "extra_script=",
                                              "worker_threads=",
                                              "backup="],
                                              "backup=",
                                              "override_device="],
                             extra_option_handler=option_handler)

  if len(args) != 2: