Add support for verifying OEM properties.

A separate OEM file must be specified to provide the expected
values for these properties.  The list of properties comes from
the "oem_fingerprint_properties" list in misc_info.txt

Bug: b/13367676

Change-Id: I1a3eaf108492132cf6f595a5d1c9f7e0c3cb3142
This commit is contained in:
Michael Runge
2014-04-15 17:40:21 -07:00
parent a1215ab943
commit 6e836116f7
4 changed files with 94 additions and 28 deletions

View File

@@ -68,6 +68,19 @@ class EdifyGenerator(object):
with temporary=True) to this one."""
self.script.extend(other.script)
def AssertOemProperty(self, name, value):
"""Assert that a property on the OEM paritition matches a value."""
if not name:
raise ValueError("must specify an OEM property")
if not value:
raise ValueError("must specify the OEM value")
cmd = ('file_getprop("/oem/oem.prop", "%s") == "%s" || '
'abort("This package expects the value \\"%s\\" for '
'\\"%s\\" on the OEM partition; '
'this has value \\"" + file_getprop("/oem/oem.prop") + "\\".");'
) % (name, value, name, value)
self.script.append(cmd)
def AssertSomeFingerprint(self, *fp):
"""Assert that the current system build fingerprint is one of *fp."""
if not fp:
@@ -81,15 +94,16 @@ class EdifyGenerator(object):
) % (" or ".join(fp),)
self.script.append(cmd)
def AssertRecoveryFingerprint(self, *fp):
"""Assert that the current recovery build fingerprint is one of *fp."""
def AssertSomeThumbprint(self, *fp):
"""Assert that the current system build thumbprint is one of *fp."""
if not fp:
raise ValueError("must specify some fingerprints")
raise ValueError("must specify some thumbprints")
cmd = (
' ||\n '.join([('getprop("ro.build.fingerprint") == "%s"')
' ||\n '.join([('file_getprop("/system/build.prop", '
'"ro.build.thumbprint") == "%s"')
% i for i in fp]) +
' ||\n abort("Package expects build fingerprint of %s; this '
'device has " + getprop("ro.build.fingerprint") + ".");'
' ||\n abort("Package expects build thumbprint of %s; this '
'device has " + getprop("ro.build.thumbprint") + ".");'
) % (" or ".join(fp),)
self.script.append(cmd)