Commit 090ae8b4 authored by Clark DuVall's avatar Clark DuVall Committed by Chromium LUCI CQ

Handle the chrome module when verifying AndroidManifest.xml

For now the chrome module's manifest is merged into the base manifest to
match the expectations files we have. If the chrome module launches, we
may want to have more checks on what gets put in the base manifest vs.
the chrome manifest.

Bug: 1151529
Change-Id: I786175aec33cf5f454a416d3f51e9dd069dbac82
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2572792Reviewed-by: default avatarAndrew Grieve <agrieve@chromium.org>
Commit-Queue: Clark DuVall <cduvall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#833591}
parent 644b7829
......@@ -242,6 +242,11 @@ def _ParseArgs(args):
'--uses-split',
help='Value to set uses-split to in the AndroidManifest.xml.')
input_opts.add_argument(
'--extra-verification-manifest',
help='Path to AndroidManifest.xml which should be merged into base '
'manifest when performing verification.')
diff_utils.AddCommandLineFlags(parser)
options = parser.parse_args(args)
......@@ -412,7 +417,7 @@ def _MoveImagesToNonMdpiFolders(res_root, path_info):
os.path.relpath(dst_file, res_root))
def _FixManifest(options, temp_dir):
def _FixManifest(options, temp_dir, extra_manifest=None):
"""Fix the APK's AndroidManifest.xml.
This adds any missing namespaces for 'android' and 'tools', and
......@@ -422,6 +427,8 @@ def _FixManifest(options, temp_dir):
Args:
options: The command-line arguments tuple.
temp_dir: A temporary directory where the fixed manifest will be written to.
extra_manifest: Path to an AndroidManifest.xml file which will get merged
into the application node of the base manifest.
Returns:
Tuple of:
* Manifest path within |temp_dir|.
......@@ -452,6 +459,11 @@ def _FixManifest(options, temp_dir):
doc, manifest_node, app_node = manifest_utils.ParseManifest(
options.android_manifest)
if extra_manifest:
_, _, extra_app_nodes = manifest_utils.ParseManifest(extra_manifest)
for node in extra_app_nodes:
app_node.append(node)
manifest_utils.AssertUsesSdk(manifest_node, options.min_sdk_version,
options.target_sdk_version)
# We explicitly check that maxSdkVersion is set in the manifest since we don't
......@@ -1039,9 +1051,10 @@ def _WriteOutputs(options, build):
shutil.move(temp, final)
def _CreateNormalizedManifest(options):
def _CreateNormalizedManifestForVerification(options):
with build_utils.TempDir() as tempdir:
fixed_manifest, _ = _FixManifest(options, tempdir)
fixed_manifest, _ = _FixManifest(
options, tempdir, extra_manifest=options.extra_verification_manifest)
with open(fixed_manifest) as f:
return manifest_utils.NormalizeManifest(f.read())
......@@ -1140,7 +1153,7 @@ def main(args):
options = _ParseArgs(args)
if options.expected_file:
actual_data = _CreateNormalizedManifest(options)
actual_data = _CreateNormalizedManifestForVerification(options)
diff_utils.CheckExpectations(actual_data, options)
if options.only_verify_expectations:
return
......
......@@ -2751,6 +2751,16 @@ if (enable_java_templates) {
if (fail_on_android_expectations) {
args += [ "--fail-on-expectations" ]
}
if (defined(invoker.extra_verification_manifest)) {
inputs += [ invoker.extra_verification_manifest ]
args += [
"--extra-verification-manifest",
rebase_path(invoker.extra_verification_manifest, root_build_dir),
]
if (defined(invoker.extra_verification_manifest_dep)) {
deps += [ invoker.extra_verification_manifest_dep ]
}
}
}
_deps += [ ":$_expectations_target" ]
}
......
......@@ -2473,6 +2473,8 @@ if (enable_java_templates) {
"enforce_resource_overlays_in_tests",
"expected_android_manifest",
"expected_android_manifest_base",
"extra_verification_manifest",
"extra_verification_manifest_dep",
"manifest_package",
"max_sdk_version",
"no_xml_namespaces",
......@@ -3608,6 +3610,8 @@ if (enable_java_templates) {
"enable_multidex",
"expected_android_manifest",
"expected_android_manifest_base",
"extra_verification_manifest",
"extra_verification_manifest_dep",
"generate_buildconfig_java",
"generate_final_jni",
"input_jars_paths",
......
......@@ -501,6 +501,16 @@ template("monochrome_public_common_apk_or_module_tmpl") {
# TODO(crbug.com/1150459): Remove this once internal repo is updated.
not_needed(invoker, [ "module_descs" ])
# If the manifest is being verified, add the chrome module's manifest.
if (defined(invoker.expected_android_manifest)) {
_bundle_target_gen_dir =
get_label_info(invoker.bundle_target, "target_gen_dir")
_bundle_name = get_label_info(invoker.bundle_target, "name")
extra_verification_manifest = "${_bundle_target_gen_dir}/${_bundle_name}__chrome_bundle_module_manifest/AndroidManifest.xml"
extra_verification_manifest_dep =
"${invoker.bundle_target}__chrome_bundle_module__merge_manifests"
}
# The arcore manifest needs to be merged into the base module because
# the Play Store verifies the com.google.ar.core.min_apk_version
# meta-data tag is in the base manifest.
......@@ -728,6 +738,8 @@ template("monochrome_public_common_apk_or_module_tmpl") {
"alternative_android_sdk_dep",
"app_as_shared_lib",
"deps",
"extra_verification_manifest",
"extra_verification_manifest_dep",
"is_monochrome",
"is_trichrome",
"isolated_splits_enabled",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment