diff --git a/core/Makefile b/core/Makefile index 5c0ea4313..8a5b43128 100644 --- a/core/Makefile +++ b/core/Makefile @@ -1295,6 +1295,12 @@ else OTA_FROM_TARGET_SCRIPT := $(TARGET_RELEASETOOL_OTA_FROM_TARGET_SCRIPT) 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) $(DISTTOOLS) @echo -e ${CL_YLW}"Package OTA:"${CL_RST}" $@" $(hide) ./build/tools/releasetools/ota_from_target_files -v \ diff --git a/tools/releasetools/edify_generator.py b/tools/releasetools/edify_generator.py index b882f37c3..5fdf7da66 100644 --- a/tools/releasetools/edify_generator.py +++ b/tools/releasetools/edify_generator.py @@ -87,8 +87,10 @@ def AssertOlderBuild(self, timestamp): 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): diff --git a/tools/releasetools/ota_from_target_files b/tools/releasetools/ota_from_target_files index 6ac52d3bf..a832ff3bb 100755 --- a/tools/releasetools/ota_from_target_files +++ b/tools/releasetools/ota_from_target_files @@ -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 + 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 = True +OPTIONS.override_device = 'auto' def MostPopularKey(d, default): """Given a dict, return the key corresponding to the largest @@ -309,7 +313,10 @@ def SignOutput(temp_zip_name, output_zip_name): def AppendAssertions(script, info_dict): - device = GetBuildProp("ro.product.device", info_dict) + if OPTIONS.override_device == "auto": + device = GetBuildProp("ro.product.device", info_dict) + else: + device = OPTIONS.override_device script.AssertDevice(device) @@ -759,6 +766,8 @@ def main(argv): OPTIONS.worker_threads = int(a) elif o in ("--backup"): OPTIONS.backuptool = True + elif o in ("--override_device"): + OPTIONS.override_device = a else: return False return True @@ -774,7 +783,7 @@ def main(argv): "worker_threads=", "aslr_mode=", "backup=", - ], + "override_device="], extra_option_handler=option_handler) if len(args) != 2: