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 8, 2016
1 parent c862cbf commit 35cbbb0
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
7 changes: 7 additions & 0 deletions core/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -1555,13 +1555,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) $(DISTTOOLS)
@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 @@ -117,10 +117,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("This package is for \\"%s\\" devices; '
'this is a \\"" + getprop("ro.product.device") + "\\".");') % (
device, 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
13 changes: 12 additions & 1 deletion tools/releasetools/ota_from_target_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@
--stash_threshold <float>
Specifies the threshold that will be used to compute the maximum
allowed stash size (defaults to 0.8).
--override_device <device>
Override device-specific asserts. Can be a comma-separated list.
"""

import sys
Expand Down Expand Up @@ -134,6 +138,7 @@
# Stash size cannot exceed cache_size * threshold.
OPTIONS.cache_size = None
OPTIONS.stash_threshold = 0.8
OPTIONS.override_device = 'auto'

def MostPopularKey(d, default):
"""Given a dict, return the key corresponding to the largest
Expand Down Expand Up @@ -413,7 +418,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 @@ -1550,6 +1558,8 @@ def option_handler(o, a):
except ValueError:
raise ValueError("Cannot parse value %r for option %r - expecting "
"a float" % (a, o))
elif o in ("--override_device"):
OPTIONS.override_device = a
else:
return False
return True
Expand All @@ -1575,6 +1585,7 @@ def option_handler(o, a):
"verify",
"no_fallback_to_full",
"stash_threshold=",
"override_device=",
], extra_option_handler=option_handler)

if len(args) != 2:
Expand Down

0 comments on commit 35cbbb0

Please sign in to comment.