releasetools: Handle the case of not having ro.vendor.build.fingerprint.

Commit d572632f3d added support in build
system to blacklist given vendor properties. When
ro.vendor.build.fingerprint gets blacklisted, the OTA generation script
can't rely on those properties to determine a change in vendor images.
This CL considers such a case as "vendor images must have changed"
between the two builds.

Bug: 113892939
Test: Generate an incremental package with builds not having
      ro.vendor.build.fingerprint.
Test: python -m unittest test_ota_from_target_files
Change-Id: I188de9c3cbeecf26132c92b9356e9d5fef75205e
This commit is contained in:
Tao Bao 2018-09-05 13:06:37 -07:00
parent 0e0ef050f9
commit ea6cbd0765
2 changed files with 36 additions and 5 deletions

View file

@ -284,6 +284,17 @@ class BuildInfo(object):
def fingerprint(self):
return self._fingerprint
@property
def vendor_fingerprint(self):
if "vendor.build.prop" not in self.info_dict:
return None
vendor_build_prop = self.info_dict["vendor.build.prop"]
if "ro.vendor.build.fingerprint" in vendor_build_prop:
return vendor_build_prop["ro.vendor.build.fingerprint"]
if "ro.vendor.build.thumbprint" in vendor_build_prop:
return vendor_build_prop["ro.vendor.build.thumbprint"]
return None
@property
def oem_props(self):
return self._oem_props
@ -706,11 +717,14 @@ def AddCompatibilityArchiveIfTrebleEnabled(target_zip, output_zip, target_info,
target_fp = target_info.fingerprint
system_updated = source_fp != target_fp
source_fp_vendor = source_info.GetVendorBuildProp(
"ro.vendor.build.fingerprint")
target_fp_vendor = target_info.GetVendorBuildProp(
"ro.vendor.build.fingerprint")
vendor_updated = source_fp_vendor != target_fp_vendor
source_fp_vendor = source_info.vendor_fingerprint
target_fp_vendor = target_info.vendor_fingerprint
# vendor build fingerprints could be possibly blacklisted at build time. For
# such a case, we consider the vendor images being changed.
if source_fp_vendor is None or target_fp_vendor is None:
vendor_updated = True
else:
vendor_updated = source_fp_vendor != target_fp_vendor
AddCompatibilityArchive(system_updated, vendor_updated)

View file

@ -255,6 +255,23 @@ class BuildInfoTest(unittest.TestCase):
self.assertRaises(common.ExternalError, target_info.GetVendorBuildProp,
'ro.build.nonexistent')
def test_vendor_fingerprint(self):
target_info = BuildInfo(self.TEST_INFO_DICT, None)
self.assertEqual('vendor-build-fingerprint',
target_info.vendor_fingerprint)
def test_vendor_fingerprint_blacklisted(self):
target_info_dict = copy.deepcopy(self.TEST_INFO_DICT_USES_OEM_PROPS)
del target_info_dict['vendor.build.prop']['ro.vendor.build.fingerprint']
target_info = BuildInfo(target_info_dict, self.TEST_OEM_DICTS)
self.assertIsNone(target_info.vendor_fingerprint)
def test_vendor_fingerprint_without_vendor_build_prop(self):
target_info_dict = copy.deepcopy(self.TEST_INFO_DICT_USES_OEM_PROPS)
del target_info_dict['vendor.build.prop']
target_info = BuildInfo(target_info_dict, self.TEST_OEM_DICTS)
self.assertIsNone(target_info.vendor_fingerprint)
def test_WriteMountOemScript(self):
target_info = BuildInfo(self.TEST_INFO_DICT_USES_OEM_PROPS,
self.TEST_OEM_DICTS)