Skip to content
This repository was archived by the owner on Jan 27, 2025. It is now read-only.

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

Open
wants to merge 1 commit into
base: jb43-legacy
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions core/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
6 changes: 4 additions & 2 deletions tools/releasetools/edify_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
13 changes: 11 additions & 2 deletions tools/releasetools/ota_from_target_files
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)


Expand Down Expand Up @@ -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
Expand All @@ -774,7 +783,7 @@ def main(argv):
"worker_threads=",
"aslr_mode=",
"backup=",
],
"override_device="],
extra_option_handler=option_handler)

if len(args) != 2:
Expand Down