From d7c160ffbf87dfca0c74ea2a08cf0f233720e97b Mon Sep 17 00:00:00 2001 From: Hongguang Chen Date: Sun, 3 May 2020 21:24:26 -0700 Subject: [PATCH] Skip _oem_props if oem_dicts is None. The oem_dicts in BuildInfo is only available to ota_from_target_files when it's called with "--oem_settings" input. However, aosp/1135332 starts to use BuildInfo in add_img_to_target_files w/o oem_dicts. An assert is triggered due to it when oem_fingerprint_properties is in the info_dict. This change skip _oem_props reading if oem_dicts is None to allow to this case. BUG: 155360923 BUG: 154171021 Test: Sign images with oem_fingerprint_properties. Change-Id: I6a73feecd9567fd4d85f4eab3d4e11c5df28fe39 --- tools/releasetools/common.py | 9 ++++++--- tools/releasetools/test_common.py | 4 ---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/tools/releasetools/common.py b/tools/releasetools/common.py index 2f89a7095..7f40374ed 100644 --- a/tools/releasetools/common.py +++ b/tools/releasetools/common.py @@ -361,10 +361,13 @@ class BuildInfo(object): self.oem_dicts = oem_dicts self._is_ab = info_dict.get("ab_update") == "true" - self._oem_props = info_dict.get("oem_fingerprint_properties") - if self._oem_props: - assert oem_dicts, "OEM source required for this build" + # Skip _oem_props if oem_dicts is None to use BuildInfo in + # sign_target_files_apks + if self.oem_dicts: + self._oem_props = info_dict.get("oem_fingerprint_properties") + else: + self._oem_props = None def check_fingerprint(fingerprint): if (" " in fingerprint or any(ord(ch) > 127 for ch in fingerprint)): diff --git a/tools/releasetools/test_common.py b/tools/releasetools/test_common.py index f1971d3b4..665eb513d 100644 --- a/tools/releasetools/test_common.py +++ b/tools/releasetools/test_common.py @@ -176,10 +176,6 @@ class BuildInfoTest(test_utils.ReleaseToolsTestCase): self.assertEqual('brand3/product-name/device3:build-thumbprint', target_info.fingerprint) - # Missing oem_dict should be rejected. - self.assertRaises(AssertionError, common.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'