Fix manifest_check.py for generated manifests that have no application tag

Make generates manifests for modules that are missing AndroidManifest.xml
files in order to paper over differences between aapt and aapt2.  These
manifests don't have an <application> tag. which was tripping up an
unexercised error path in manifest_check.py.

Change manifest_check,py's extract_uses_libs_xml to consider manifests
with no application tag as having empty uses_library and
optional_uses_library lists.  Also fix up a few nearby pylint warnings.

Fixes: 303554426
Test: m ConnectivityMonitorRobotests
Change-Id: I3815a1c86e24d7b3dea7f4ea26c34d3af182ded1
This commit is contained in:
Colin Cross 2023-10-06 13:10:52 -07:00
parent f7fe400fbc
commit c00fa152f7

View file

@ -187,18 +187,17 @@ def extract_uses_libs_apk(badging):
return required, optional, tags
def extract_uses_libs_xml(xml): #pylint: disable=inconsistent-return-statements
def extract_uses_libs_xml(xml):
"""Extract <uses-library> tags from the manifest."""
manifest = parse_manifest(xml)
elems = get_children_with_tag(manifest, 'application')
application = elems[0] if len(elems) == 1 else None
if len(elems) > 1: #pylint: disable=no-else-raise
if len(elems) > 1:
raise RuntimeError('found multiple <application> tags')
elif not elems:
if uses_libraries or optional_uses_libraries: #pylint: disable=undefined-variable
raise ManifestMismatchError('no <application> tag found')
return
if not elems:
return [], [], []
application = elems[0]
libs = get_children_with_tag(application, 'uses-library')