forked from openkylin/platform_build
Merge "releasetools: Sanity check the build fingerprint."
am: d5b6094ed3
Change-Id: I6b2af3071e0cbbebddff959605f1b8afacc64c70
This commit is contained in:
commit
65f2333062
|
@ -299,6 +299,9 @@ class BuildInfo(object):
|
|||
that it always uses the first dict to calculate the fingerprint or the
|
||||
device name. The rest would be used for asserting OEM properties only
|
||||
(e.g. one package can be installed on one of these devices).
|
||||
|
||||
Raises:
|
||||
ValueError: On invalid inputs.
|
||||
"""
|
||||
self.info_dict = info_dict
|
||||
self.oem_dicts = oem_dicts
|
||||
|
@ -313,6 +316,13 @@ class BuildInfo(object):
|
|||
self._device = self.GetOemProperty("ro.product.device")
|
||||
self._fingerprint = self.CalculateFingerprint()
|
||||
|
||||
# Sanity check the build fingerprint.
|
||||
if (' ' in self._fingerprint or
|
||||
any(ord(ch) > 127 for ch in self._fingerprint)):
|
||||
raise ValueError(
|
||||
'Invalid build fingerprint: "{}". See the requirement in Android CDD '
|
||||
'3.2.2. Build Parameters.'.format(self._fingerprint))
|
||||
|
||||
@property
|
||||
def is_ab(self):
|
||||
return self._is_ab
|
||||
|
|
|
@ -174,6 +174,14 @@ class BuildInfoTest(test_utils.ReleaseToolsTestCase):
|
|||
self.assertRaises(AssertionError, BuildInfo,
|
||||
self.TEST_INFO_DICT_USES_OEM_PROPS, None)
|
||||
|
||||
def test_init_badFingerprint(self):
|
||||
info_dict = copy.deepcopy(self.TEST_INFO_DICT)
|
||||
info_dict['build.prop']['ro.build.fingerprint'] = 'bad fingerprint'
|
||||
self.assertRaises(ValueError, BuildInfo, info_dict, None)
|
||||
|
||||
info_dict['build.prop']['ro.build.fingerprint'] = 'bad\x80fingerprint'
|
||||
self.assertRaises(ValueError, BuildInfo, info_dict, None)
|
||||
|
||||
def test___getitem__(self):
|
||||
target_info = BuildInfo(self.TEST_INFO_DICT, None)
|
||||
self.assertEqual('value1', target_info['property1'])
|
||||
|
|
Loading…
Reference in New Issue