Chromium Code Reviews| 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 67c60e5e14e1eefa256ba9546ca2d791f6ee1a11..a9477ba9968bfac3906c429bcd9026b6ca4dd998 100644 |
| --- a/build/android/incremental_install/java/org/chromium/incrementalinstall/BootstrapApplication.java |
| +++ b/build/android/incremental_install/java/org/chromium/incrementalinstall/BootstrapApplication.java |
| @@ -118,7 +118,7 @@ public final class BootstrapApplication extends Application { |
| ApplicationInfo appInfo = getPackageManager().getApplicationInfo(getPackageName(), |
| PackageManager.GET_META_DATA); |
| String value = appInfo.metaData.getString(key); |
| - if (!value.contains(".")) { |
| + if (value != null && !value.contains(".")) { |
| value = getPackageName() + "." + value; |
| } |
| return value; |
| @@ -129,11 +129,22 @@ public final class BootstrapApplication extends Application { |
| */ |
| private void initInstrumentation(String realInstrumentationName) |
| throws ReflectiveOperationException { |
| + Instrumentation oldInstrumentation = |
| + (Instrumentation) Reflect.getField(mActivityThread, "mInstrumentation"); |
| + if (realInstrumentationName == null) { |
| + // This is the case when an incremental app is used as a target for an instrumentation |
| + // test. In this case, ActivityThread can instantiate the proper class just fine since |
| + // it exists within the test apk (as apposed to the incremental apk-under-test). |
|
dgn
2016/01/06 20:46:09
s/as apposed/as opposed/ ?
agrieve
2016/01/06 20:50:58
Done.
|
| + Log.i(TAG, "Running with external instrumentation"); |
| + mRealInstrumentation = oldInstrumentation; |
| + return; |
| + } |
| + // For unit tests, the instrumentation class is replaced in the manifest by a build step |
| + // because ActivityThread tries to instantiate it before we get a chance to load the |
| + // incremental dex files. |
| Log.i(TAG, "Instantiating instrumentation " + realInstrumentationName); |
| mRealInstrumentation = (Instrumentation) Reflect.newInstance( |
| Class.forName(realInstrumentationName)); |
| - Instrumentation oldInstrumentation = |
| - (Instrumentation) Reflect.getField(mActivityThread, "mInstrumentation"); |
| // Initialize the fields that are set by Instrumentation.init(). |
| String[] initFields = {"mThread", "mMessageQueue", "mInstrContext", "mAppContext", |