From c00fa152f764f26fa90afd95bbfffbe8143867ad Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Fri, 6 Oct 2023 13:10:52 -0700 Subject: [PATCH] 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 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 --- scripts/manifest_check.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/scripts/manifest_check.py b/scripts/manifest_check.py index c8d4f76c8..c33b104bd 100755 --- a/scripts/manifest_check.py +++ b/scripts/manifest_check.py @@ -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 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 tags') - elif not elems: - if uses_libraries or optional_uses_libraries: #pylint: disable=undefined-variable - raise ManifestMismatchError('no tag found') - return + if not elems: + return [], [], [] + + application = elems[0] libs = get_children_with_tag(application, 'uses-library')