Rename preferCodeIntegrity to useEmbeddedDex

Test: build and run testing app
Bug: 112037137
Change-Id: Ia82c2c3ba7eb32117a4be078ac31ee2ba510f9eb
This commit is contained in:
Victor Hsieh
2019-01-29 13:00:33 -08:00
parent 910cdf95cd
commit d181c8ba76
5 changed files with 37 additions and 36 deletions

View File

@@ -61,9 +61,10 @@ def parse_args():
help='specify additional <uses-library> tag to add. android:requred is set to false')
parser.add_argument('--uses-non-sdk-api', dest='uses_non_sdk_api', action='store_true',
help='manifest is for a package built against the platform')
parser.add_argument('--prefer-code-integrity', dest='prefer_code_integrity', action='store_true',
help=('specify if the app prefers strict code integrity. Should not be conflict '
'if already declared in the manifest.'))
parser.add_argument('--use-embedded-dex', dest='use_embedded_dex', action='store_true',
help=('specify if the app wants to use embedded dex and avoid extracted,'
'locally compiled code. Should not be conflict if already declared '
'in the manifest.'))
parser.add_argument('input', help='input AndroidManifest.xml file')
parser.add_argument('output', help='output AndroidManifest.xml file')
return parser.parse_args()
@@ -272,7 +273,7 @@ def add_uses_non_sdk_api(doc):
application.setAttributeNode(attr)
def add_prefer_code_integrity(doc):
def add_use_embedded_dex(doc):
manifest = parse_manifest(doc)
elems = get_children_with_tag(manifest, 'application')
application = elems[0] if len(elems) == 1 else None
@@ -285,13 +286,13 @@ def add_prefer_code_integrity(doc):
manifest.insertBefore(doc.createTextNode(indent), first)
manifest.insertBefore(application, first)
attr = application.getAttributeNodeNS(android_ns, 'preferCodeIntegrity')
attr = application.getAttributeNodeNS(android_ns, 'useEmbeddedDex')
if attr is None:
attr = doc.createAttributeNS(android_ns, 'android:preferCodeIntegrity')
attr = doc.createAttributeNS(android_ns, 'android:useEmbeddedDex')
attr.value = 'true'
application.setAttributeNode(attr)
elif attr.value != 'true':
raise RuntimeError('existing attribute mismatches the option of --prefer-code-integrity')
raise RuntimeError('existing attribute mismatches the option of --use-embedded-dex')
def write_xml(f, doc):
@@ -321,8 +322,8 @@ def main():
if args.uses_non_sdk_api:
add_uses_non_sdk_api(doc)
if args.prefer_code_integrity:
add_prefer_code_integrity(doc)
if args.use_embedded_dex:
add_use_embedded_dex(doc)
with open(args.output, 'wb') as f:
write_xml(f, doc)