From 74be507bf420d21eed1a354dc15b4784a6aba4ff Mon Sep 17 00:00:00 2001 From: agrieve Date: Tue, 22 Sep 2015 14:27:00 -0700 Subject: GN: Make _incremental apk targets work when no exists BUG=534849 Review URL: https://codereview.chromium.org/1352043007 Cr-Commit-Position: refs/heads/master@{#350236} --- .../incremental_install/generate_android_manifest.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/build/android/incremental_install/generate_android_manifest.py b/build/android/incremental_install/generate_android_manifest.py index b9061ed..17eabd4 100755 --- a/build/android/incremental_install/generate_android_manifest.py +++ b/build/android/incremental_install/generate_android_manifest.py @@ -22,6 +22,7 @@ ElementTree.register_namespace('android', _ANDROID_NAMESPACE) _INCREMENTAL_APP_NAME = 'org.chromium.incrementalinstall.BootstrapApplication' _META_DATA_NAME = 'incremental-install-real-app' +_DEFAULT_APPLICATION_CLASS = 'android.app.Application' def _AddNamespace(name): @@ -44,13 +45,11 @@ def _ParseArgs(): return parser.parse_args() -def _ProcessManifest(main_manifest, main_manifest_path, - disable_isolated_processes): +def _ProcessManifest(main_manifest, disable_isolated_processes): """Returns a transformed AndroidManifest.xml for use with _incremental apks. Args: main_manifest: Manifest contents to transform. - main_manifest_path: Path to main_manifest (used for error messages). disable_isolated_processes: Whether to set all isolatedProcess attributes to false @@ -64,11 +63,10 @@ def _ProcessManifest(main_manifest, main_manifest_path, doc = ElementTree.fromstring(main_manifest) app_node = doc.find('application') if app_node is None: - raise Exception('Could not find in %s' % main_manifest_path) - real_app_class = app_node.get(_AddNamespace('name')) - if real_app_class is None: - raise Exception('Could not find android:name in in %s' % - main_manifest_path) + app_node = ElementTree.SubElement(doc, 'application') + + real_app_class = app_node.get(_AddNamespace('name'), + _DEFAULT_APPLICATION_CLASS) app_node.set(_AddNamespace('name'), _INCREMENTAL_APP_NAME) meta_data_node = ElementTree.SubElement(app_node, 'meta-data') @@ -81,7 +79,7 @@ def main(): options = _ParseArgs() with open(options.src_manifest) as f: main_manifest_data = f.read() - new_manifest_data = _ProcessManifest(main_manifest_data, options.src_manifest, + new_manifest_data = _ProcessManifest(main_manifest_data, options.disable_isolated_processes) with open(options.out_manifest, 'w') as f: f.write(new_manifest_data) -- cgit v1.1