diff --git a/tools/releasetools/ota_from_target_files.py b/tools/releasetools/ota_from_target_files.py index 2b6987f56c..31f5cdea1b 100755 --- a/tools/releasetools/ota_from_target_files.py +++ b/tools/releasetools/ota_from_target_files.py @@ -1657,9 +1657,15 @@ def GetTargetFilesZipForSecondaryImages(input_file, skip_postinstall=False): target_file = common.MakeTempFile(prefix="targetfiles-", suffix=".zip") target_zip = zipfile.ZipFile(target_file, 'w', allowZip64=True) - input_tmp = common.UnzipTemp(input_file, UNZIP_PATTERN) with zipfile.ZipFile(input_file, 'r') as input_zip: infolist = input_zip.infolist() + namelist = input_zip.namelist() + + # Additionally unzip 'RADIO/*' if exists. + unzip_pattern = UNZIP_PATTERN[:] + if any([entry.startswith('RADIO/') for entry in namelist]): + unzip_pattern.append('RADIO/*') + input_tmp = common.UnzipTemp(input_file, unzip_pattern) for info in infolist: unzipped_file = os.path.join(input_tmp, *info.filename.split('/')) @@ -1675,7 +1681,7 @@ def GetTargetFilesZipForSecondaryImages(input_file, skip_postinstall=False): elif skip_postinstall and info.filename == POSTINSTALL_CONFIG: pass - elif info.filename.startswith(('META/', 'IMAGES/')): + elif info.filename.startswith(('META/', 'IMAGES/', 'RADIO/')): common.ZipWrite(target_zip, unzipped_file, arcname=info.filename) common.ZipClose(target_zip) diff --git a/tools/releasetools/test_ota_from_target_files.py b/tools/releasetools/test_ota_from_target_files.py index 7c34b7e998..c8e6750c59 100644 --- a/tools/releasetools/test_ota_from_target_files.py +++ b/tools/releasetools/test_ota_from_target_files.py @@ -566,6 +566,8 @@ class OtaFromTargetFilesTest(unittest.TestCase): self.assertIn('IMAGES/boot.img', namelist) self.assertIn('IMAGES/system.img', namelist) self.assertIn('IMAGES/vendor.img', namelist) + self.assertIn('RADIO/bootloader.img', namelist) + self.assertIn('RADIO/modem.img', namelist) self.assertIn(POSTINSTALL_CONFIG, namelist) self.assertNotIn('IMAGES/system_other.img', namelist) @@ -583,11 +585,33 @@ class OtaFromTargetFilesTest(unittest.TestCase): self.assertIn('IMAGES/boot.img', namelist) self.assertIn('IMAGES/system.img', namelist) self.assertIn('IMAGES/vendor.img', namelist) + self.assertIn('RADIO/bootloader.img', namelist) + self.assertIn('RADIO/modem.img', namelist) self.assertNotIn('IMAGES/system_other.img', namelist) self.assertNotIn('IMAGES/system.map', namelist) self.assertNotIn(POSTINSTALL_CONFIG, namelist) + def test_GetTargetFilesZipForSecondaryImages_withoutRadioImages(self): + input_file = construct_target_files(secondary=True) + common.ZipDelete(input_file, 'RADIO/bootloader.img') + common.ZipDelete(input_file, 'RADIO/modem.img') + target_file = GetTargetFilesZipForSecondaryImages(input_file) + + with zipfile.ZipFile(target_file) as verify_zip: + namelist = verify_zip.namelist() + + self.assertIn('META/ab_partitions.txt', namelist) + self.assertIn('IMAGES/boot.img', namelist) + self.assertIn('IMAGES/system.img', namelist) + self.assertIn('IMAGES/vendor.img', namelist) + self.assertIn(POSTINSTALL_CONFIG, namelist) + + self.assertNotIn('IMAGES/system_other.img', namelist) + self.assertNotIn('IMAGES/system.map', namelist) + self.assertNotIn('RADIO/bootloader.img', namelist) + self.assertNotIn('RADIO/modem.img', namelist) + def test_GetTargetFilesZipWithoutPostinstallConfig(self): input_file = construct_target_files() target_file = GetTargetFilesZipWithoutPostinstallConfig(input_file)