Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1389)

Unified Diff: build/android/incremental_install/generate_android_manifest.py

Issue 1409603002: GN Incremental Install: Add support for running with instrumentation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review 1 Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: build/android/incremental_install/generate_android_manifest.py
diff --git a/build/android/incremental_install/generate_android_manifest.py b/build/android/incremental_install/generate_android_manifest.py
index 17eabd4d9ab8ba6d7372c30e7375de1bb36ecce8..163b4c34be4b06992d9f4e1cf0112b9627f2ebc8 100755
--- a/build/android/incremental_install/generate_android_manifest.py
+++ b/build/android/incremental_install/generate_android_manifest.py
@@ -21,8 +21,10 @@ _ANDROID_NAMESPACE = 'http://schemas.android.com/apk/res/android'
ElementTree.register_namespace('android', _ANDROID_NAMESPACE)
_INCREMENTAL_APP_NAME = 'org.chromium.incrementalinstall.BootstrapApplication'
-_META_DATA_NAME = 'incremental-install-real-app'
+_META_DATA_APP_NAME = 'incremental-install-real-app'
+_META_DATA_INSTRUMENTATION_NAME = 'incremental-install-real-instrumentation'
_DEFAULT_APPLICATION_CLASS = 'android.app.Application'
+_DEFAULT_INSTRUMENTATION_CLASS = 'android.app.Instrumentation'
def _AddNamespace(name):
@@ -45,6 +47,12 @@ def _ParseArgs():
return parser.parse_args()
+def _CreateMetaData(parent, name, value):
+ meta_data_node = ElementTree.SubElement(parent, 'meta-data')
+ meta_data_node.set(_AddNamespace('name'), name)
+ meta_data_node.set(_AddNamespace('value'), value)
+
+
def _ProcessManifest(main_manifest, disable_isolated_processes):
"""Returns a transformed AndroidManifest.xml for use with _incremental apks.
@@ -68,10 +76,18 @@ def _ProcessManifest(main_manifest, disable_isolated_processes):
real_app_class = app_node.get(_AddNamespace('name'),
_DEFAULT_APPLICATION_CLASS)
app_node.set(_AddNamespace('name'), _INCREMENTAL_APP_NAME)
+ _CreateMetaData(app_node, _META_DATA_APP_NAME, real_app_class)
+
+ # Seems to be a bug in ElementTree, as doc.find() doesn't work here.
+ instrumentation_nodes = doc.findall('instrumentation')
+ if instrumentation_nodes:
+ instrumentation_node = instrumentation_nodes[0]
+ real_instrumentation_class = instrumentation_node.get(_AddNamespace('name'))
+ instrumentation_node.set(_AddNamespace('name'),
+ _DEFAULT_INSTRUMENTATION_CLASS)
+ _CreateMetaData(app_node, _META_DATA_INSTRUMENTATION_NAME,
+ real_instrumentation_class)
- meta_data_node = ElementTree.SubElement(app_node, 'meta-data')
- meta_data_node.set(_AddNamespace('name'), _META_DATA_NAME)
- meta_data_node.set(_AddNamespace('value'), real_app_class)
return ElementTree.tostring(doc, encoding='UTF-8')

Powered by Google App Engine
This is Rietveld 408576698