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

Unified Diff: build/android/incremental_install/java/org/chromium/incrementalinstall/BootstrapApplication.java

Issue 1469113004: GN(Android): Fix incremental install when manifest has short-hand app name. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/incremental_install/java/org/chromium/incrementalinstall/BootstrapApplication.java
diff --git a/build/android/incremental_install/java/org/chromium/incrementalinstall/BootstrapApplication.java b/build/android/incremental_install/java/org/chromium/incrementalinstall/BootstrapApplication.java
index e932c1bde3df5e5950af64171e32a5e126891fda..67c60e5e14e1eefa256ba9546ca2d791f6ee1a11 100644
--- a/build/android/incremental_install/java/org/chromium/incrementalinstall/BootstrapApplication.java
+++ b/build/android/incremental_install/java/org/chromium/incrementalinstall/BootstrapApplication.java
@@ -74,11 +74,12 @@ public final class BootstrapApplication extends Application {
LockFile.clearInstallerLock(firstRunLockFile);
}
- Bundle metadata = getManifestMetadata();
// mInstrumentationAppDir is one of a set of fields that is initialized only when
// instrumentation is active.
if (Reflect.getField(mActivityThread, "mInstrumentationAppDir") != null) {
- initInstrumentation(metadata.getString(REAL_INSTRUMENTATION_META_DATA_NAME));
+ String realInstrumentationName =
+ getClassNameFromMetadata(REAL_INSTRUMENTATION_META_DATA_NAME);
+ initInstrumentation(realInstrumentationName);
} else {
Log.i(TAG, "No instrumentation active.");
}
@@ -92,7 +93,7 @@ public final class BootstrapApplication extends Application {
// attachBaseContext() is called from ActivityThread#handleBindApplication() and
// Application#mApplication is changed right after we return. Thus, we cannot swap
// the Application instances until onCreate() is called.
- String realApplicationName = metadata.getString(REAL_APP_META_DATA_NAME);
+ String realApplicationName = getClassNameFromMetadata(REAL_APP_META_DATA_NAME);
Log.i(TAG, "Instantiating " + realApplicationName);
mRealApplication =
(Application) Reflect.newInstance(Class.forName(realApplicationName));
@@ -110,6 +111,20 @@ public final class BootstrapApplication extends Application {
}
/**
+ * Returns the fully-qualified class name for the given key, stored in a
+ * <meta> witin the manifest.
+ */
+ private String getClassNameFromMetadata(String key) throws NameNotFoundException {
+ ApplicationInfo appInfo = getPackageManager().getApplicationInfo(getPackageName(),
+ PackageManager.GET_META_DATA);
+ String value = appInfo.metaData.getString(key);
+ if (!value.contains(".")) {
+ value = getPackageName() + "." + value;
+ }
+ return value;
+ }
+
+ /**
* Instantiates and initializes mRealInstrumentation (the real Instrumentation class).
*/
private void initInstrumentation(String realInstrumentationName)
@@ -163,16 +178,6 @@ public final class BootstrapApplication extends Application {
}
/**
- * Returns the class name of the real Application class (recorded in the
- * AndroidManifest.xml)
- */
- private Bundle getManifestMetadata() throws NameNotFoundException {
- ApplicationInfo appInfo = getPackageManager().getApplicationInfo(getPackageName(),
- PackageManager.GET_META_DATA);
- return appInfo.metaData;
- }
-
- /**
* Nulls out ActivityThread.mBoundApplication.providers.
*/
private void disableContentProviders() throws ReflectiveOperationException {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698