Skip to content

Commit

Permalink
Allow override of device asserts, including multi-device support.
Browse files Browse the repository at this point in the history
Set in board file with TARGET_OTA_ASSERT_DEVICE.

Change-Id: I3d06bdc0e3e26bde0c0e646accd050364f9713b9

Conflicts:
	tools/releasetools/ota_from_target_files.py
  • Loading branch information
hyperb1iss authored and andi34 committed Sep 17, 2016
1 parent 8d50502 commit 1dde142
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
7 changes: 7 additions & 0 deletions core/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -1840,13 +1840,20 @@ INTERNAL_OTA_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip

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

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)
@echo "Package OTA: $@"
$(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH MKBOOTIMG=$(MKBOOTIMG) \
./build/tools/releasetools/ota_from_target_files -v \
--block \
-p $(HOST_OUT) \
-k $(KEY_CERT_PAIR) \
--override_device=$(override_device) \
$(if $(OEM_OTA_CONFIG), -o $(OEM_OTA_CONFIG)) \
$(BUILT_TARGET_FILES_PACKAGE) $@

Expand Down
10 changes: 6 additions & 4 deletions tools/releasetools/edify_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,12 @@ def AssertOlderBuild(self, timestamp, timestamp_text):

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)
cmd = ('assert(' +
' || '.join(['getprop("ro.product.device") == "%s" || getprop("ro.build.product") == "%s"'
% (i, i) for i in device.split(",")]) +
' || abort("This package is for device: %s; ' +
'this device is " + getprop("ro.product.device") + ".");' +
');') % device
self.script.append(cmd)

def AssertSomeBootloader(self, *bootloaders):
Expand Down
12 changes: 11 additions & 1 deletion tools/releasetools/ota_from_target_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@
Generate a log file that shows the differences in the source and target
builds for an incremental package. This option is only meaningful when
-i is specified.
--override_device <device>
Override device-specific asserts. Can be a comma-separated list.
"""

import sys
Expand Down Expand Up @@ -160,6 +163,7 @@
OPTIONS.stash_threshold = 0.8
OPTIONS.gen_verify = False
OPTIONS.log_diff = None
OPTIONS.override_device = 'auto'

def MostPopularKey(d, default):
"""Given a dict, return the key corresponding to the largest
Expand Down Expand Up @@ -440,7 +444,10 @@ def SignOutput(temp_zip_name, output_zip_name):
def AppendAssertions(script, info_dict, oem_dict=None):
oem_props = info_dict.get("oem_fingerprint_properties")
if oem_props is None or len(oem_props) == 0:
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)
else:
if oem_dict is None:
Expand Down Expand Up @@ -1912,6 +1919,8 @@ def option_handler(o, a):
OPTIONS.gen_verify = True
elif o == "--log_diff":
OPTIONS.log_diff = a
elif o == "--override_device":
OPTIONS.override_device = a
else:
return False
return True
Expand Down Expand Up @@ -1941,6 +1950,7 @@ def option_handler(o, a):
"stash_threshold=",
"gen_verify",
"log_diff=",
"override_device=",
], extra_option_handler=option_handler)

if len(args) != 2:
Expand Down

0 comments on commit 1dde142

Please sign in to comment.