Continue to pass in --signing_helper for avbtool.

BUG: 152424931
Test: Tested Locally
Change-Id: I4e93a899b9055c937980a496f20b35c01ccbb4c1
This commit is contained in:
Baligh Uddin 2020-03-25 20:50:23 -07:00
parent 3f3351514c
commit 639b3b7a65
1 changed files with 10 additions and 4 deletions

View File

@ -52,7 +52,7 @@ class ApexApkSigner(object):
self.key_passwords = key_passwords self.key_passwords = key_passwords
self.codename_to_api_level_map = codename_to_api_level_map self.codename_to_api_level_map = codename_to_api_level_map
def ProcessApexFile(self, apk_keys, payload_key): def ProcessApexFile(self, apk_keys, payload_key, signing_args=None):
"""Scans and signs the apk files and repack the apex """Scans and signs the apk files and repack the apex
Args: Args:
@ -87,7 +87,7 @@ class ApexApkSigner(object):
logger.info('No apk file has been signed in %s', self.apex_path) logger.info('No apk file has been signed in %s', self.apex_path)
return self.apex_path return self.apex_path
return self.RepackApexPayload(payload_dir, payload_key) return self.RepackApexPayload(payload_dir, payload_key, signing_args)
def ExtractApexPayloadAndSignApks(self, apk_entries, apk_keys): def ExtractApexPayloadAndSignApks(self, apk_entries, apk_keys):
"""Extracts the payload image and signs the containing apk files.""" """Extracts the payload image and signs the containing apk files."""
@ -115,7 +115,7 @@ class ApexApkSigner(object):
has_signed_apk = True has_signed_apk = True
return payload_dir, has_signed_apk return payload_dir, has_signed_apk
def RepackApexPayload(self, payload_dir, payload_key): def RepackApexPayload(self, payload_dir, payload_key, signing_args=None):
"""Rebuilds the apex file with the updated payload directory.""" """Rebuilds the apex file with the updated payload directory."""
apex_dir = common.MakeTempDir() apex_dir = common.MakeTempDir()
# Extract the apex file and reuse its meta files as repack parameters. # Extract the apex file and reuse its meta files as repack parameters.
@ -145,6 +145,12 @@ class ApexApkSigner(object):
os.getenv('PATH')] os.getenv('PATH')]
for key, val in arguments_dict.items(): for key, val in arguments_dict.items():
generate_image_cmd.extend(['--' + key, val]) generate_image_cmd.extend(['--' + key, val])
# Add quote to the signing_args as we will pass
# --signing_args "--signing_helper_with_files=%path" to apexer
if signing_args:
generate_image_cmd.extend(['--signing_args', '"{}"'.format(signing_args)])
# optional arguments for apex repacking # optional arguments for apex repacking
manifest_json = os.path.join(apex_dir, 'apex_manifest.json') manifest_json = os.path.join(apex_dir, 'apex_manifest.json')
if os.path.exists(manifest_json): if os.path.exists(manifest_json):
@ -303,7 +309,7 @@ def SignApex(avbtool, apex_data, payload_key, container_key, container_pw,
# the apex file after signing. # the apex file after signing.
apk_signer = ApexApkSigner(apex_file, container_pw, apk_signer = ApexApkSigner(apex_file, container_pw,
codename_to_api_level_map) codename_to_api_level_map)
apex_file = apk_signer.ProcessApexFile(apk_keys, payload_key) apex_file = apk_signer.ProcessApexFile(apk_keys, payload_key, signing_args)
# 2a. Extract and sign the APEX_PAYLOAD_IMAGE entry with the given # 2a. Extract and sign the APEX_PAYLOAD_IMAGE entry with the given
# payload_key. # payload_key.