diff --git a/tools/releasetools/add_img_to_target_files.py b/tools/releasetools/add_img_to_target_files.py index babfc7dcad..687b9e7247 100644 --- a/tools/releasetools/add_img_to_target_files.py +++ b/tools/releasetools/add_img_to_target_files.py @@ -164,6 +164,20 @@ def AddVendor(output_zip, recovery_img=None, boot_img=None): img = OutputFile(output_zip, OPTIONS.input_tmp, "IMAGES", "vendor.img") if os.path.exists(img.name): logger.info("vendor.img already exists; no need to rebuild...") + + # AVB-sign the image as needed. + if OPTIONS.info_dict.get("avb_enable") == "true": + logger.info("updating avb hash for prebuilt vendor.img...") + avbtool = OPTIONS.info_dict["avb_avbtool"] + # The AVB hash footer will be replaced if already present. + cmd = [avbtool, "add_hashtree_footer", "--image", img.name, + "--partition_name", "vendor"] + common.AppendAVBSigningArgs(cmd, "vendor") + args = OPTIONS.info_dict.get("avb_vendor_add_hash_footer_args") + if args and args.strip(): + cmd.extend(shlex.split(args)) + common.RunAndCheckOutput + return img.name def output_sink(fn, data):