Merge change I83ba96fe into eclair
* changes: Fix issue #2246723: Only one Application object gets onCreate called
This commit is contained in:
@@ -485,7 +485,8 @@ public final class ActivityThread {
|
||||
return mResources;
|
||||
}
|
||||
|
||||
public Application makeApplication(boolean forceDefaultAppClass) {
|
||||
public Application makeApplication(boolean forceDefaultAppClass,
|
||||
Instrumentation instrumentation) {
|
||||
if (mApplication != null) {
|
||||
return mApplication;
|
||||
}
|
||||
@@ -512,7 +513,21 @@ public final class ActivityThread {
|
||||
}
|
||||
}
|
||||
mActivityThread.mAllApplications.add(app);
|
||||
return mApplication = app;
|
||||
mApplication = app;
|
||||
|
||||
if (instrumentation != null) {
|
||||
try {
|
||||
instrumentation.callApplicationOnCreate(app);
|
||||
} catch (Exception e) {
|
||||
if (!instrumentation.onException(app, e)) {
|
||||
throw new RuntimeException(
|
||||
"Unable to create application " + app.getClass().getName()
|
||||
+ ": " + e.toString(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return app;
|
||||
}
|
||||
|
||||
public void removeContextRegistrations(Context context,
|
||||
@@ -2378,7 +2393,7 @@ public final class ActivityThread {
|
||||
}
|
||||
|
||||
try {
|
||||
Application app = r.packageInfo.makeApplication(false);
|
||||
Application app = r.packageInfo.makeApplication(false, mInstrumentation);
|
||||
|
||||
if (localLOGV) Log.v(TAG, "Performing launch of " + r);
|
||||
if (localLOGV) Log.v(
|
||||
@@ -2576,7 +2591,7 @@ public final class ActivityThread {
|
||||
}
|
||||
|
||||
try {
|
||||
Application app = packageInfo.makeApplication(false);
|
||||
Application app = packageInfo.makeApplication(false, mInstrumentation);
|
||||
|
||||
if (localLOGV) Log.v(
|
||||
TAG, "Performing receive of " + data.intent
|
||||
@@ -2730,7 +2745,7 @@ public final class ActivityThread {
|
||||
ApplicationContext context = new ApplicationContext();
|
||||
context.init(packageInfo, null, this);
|
||||
|
||||
Application app = packageInfo.makeApplication(false);
|
||||
Application app = packageInfo.makeApplication(false, mInstrumentation);
|
||||
context.setOuterContext(service);
|
||||
service.attach(context, this, data.info.name, data.token, app,
|
||||
ActivityManagerNative.getDefault());
|
||||
@@ -3940,7 +3955,7 @@ public final class ActivityThread {
|
||||
|
||||
// If the app is being launched for full backup or restore, bring it up in
|
||||
// a restricted environment with the base application class.
|
||||
Application app = data.info.makeApplication(data.restrictedBackupMode);
|
||||
Application app = data.info.makeApplication(data.restrictedBackupMode, null);
|
||||
mInitialApplication = app;
|
||||
|
||||
List<ProviderInfo> providers = data.providers;
|
||||
|
||||
Reference in New Issue
Block a user