Set threads' contextClassLoader during LoadedApk.makeApplication.

We used to set this from LoadedApk.getClassLoader. This had
the unfortunate side effect of clobbering the threads default
classloader when Context.createPackageContext().getClassLoader()
was called. This happens, for example, to every app that uses
a updatable webview.

bug: 17986934
Change-Id: If2b5938a19f836ea5fe60c94ea53a7125c2098c0
This commit is contained in:
Narayan Kamath
2014-10-15 11:38:44 +01:00
parent 5873c3e862
commit 8091edbffb

View File

@@ -360,7 +360,6 @@ public final class LoadedApk {
mClassLoader = ApplicationLoaders.getDefault().getClassLoader(zip, lib,
mBaseClassLoader);
initializeJavaContextClassLoader();
StrictMode.setThreadPolicy(oldPolicy);
} else {
@@ -552,6 +551,9 @@ public final class LoadedApk {
try {
java.lang.ClassLoader cl = getClassLoader();
if (!mPackageName.equals("android")) {
initializeJavaContextClassLoader();
}
ContextImpl appContext = ContextImpl.createAppContext(mActivityThread, this);
app = mActivityThread.mInstrumentation.newApplication(
cl, appClass, appContext);