From 7dc5117ffd8098374ee528d5a9cd4a8d7906fc95 Mon Sep 17 00:00:00 2001 From: Yifan Hong Date: Tue, 12 Jan 2021 11:27:39 -0800 Subject: [PATCH] GetBootImageBuildProp returns None if file does not exist If system/etc/ramdisk/build.prop does not exist in the ramdisk, GetBootImageBuildProp should return None instead of a path to a non-existant file. Test: pass Bug: 177171706 Change-Id: I34e447bc315d203e136e8c0d59d00961f81301e3 --- tools/releasetools/common.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tools/releasetools/common.py b/tools/releasetools/common.py index 19b132b390..26c4ae8426 100644 --- a/tools/releasetools/common.py +++ b/tools/releasetools/common.py @@ -3672,14 +3672,13 @@ def GetBootImageBuildProp(boot_img): RunAndCheckOutput(['toybox', 'cpio', '-F', abs_uncompressed_ramdisk, '-i'], cwd=extracted_ramdisk) - prop_file = None for search_path in RAMDISK_BUILD_PROP_REL_PATHS: prop_file = os.path.join(extracted_ramdisk, search_path) if os.path.isfile(prop_file): - break + return prop_file logger.warning('Unable to get boot image timestamp: no %s in ramdisk', search_path) - return prop_file + return None except ExternalError as e: logger.warning('Unable to get boot image build props: %s', e)