Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 346296bd authored by Alan Viverette's avatar Alan Viverette
Browse files

Reset class loader after updating instrumentation paths

Bug: 23688983
Change-Id: I9a0f81b422b5e29f3f8707b987e40c65965e0223
parent d69bb610
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -4718,7 +4718,13 @@ public final class ActivityThread {
            mInstrumentedSplitAppDirs = data.info.getSplitAppDirs();
            mInstrumentedLibDir = data.info.getLibDir();

            ApplicationInfo instrApp = new ApplicationInfo();
            // The app context's info was created against this thread, but
            // the class loader may have already been loaded and cached with
            // outdated paths. Clear it so we can load it again using the
            // instrumentation paths.
            data.info.clearClassLoader();

            final ApplicationInfo instrApp = new ApplicationInfo();
            instrApp.packageName = ii.packageName;
            instrApp.sourceDir = ii.sourceDir;
            instrApp.publicSourceDir = ii.publicSourceDir;
@@ -4731,6 +4737,7 @@ public final class ActivityThread {
            ContextImpl instrContext = ContextImpl.createAppContext(this, pi);

            try {

                java.lang.ClassLoader cl = instrContext.getClassLoader();
                mInstrumentation = (Instrumentation)
                    cl.loadClass(data.instrumentationName.getClassName()).newInstance();
+7 −0
Original line number Diff line number Diff line
@@ -255,6 +255,13 @@ public final class LoadedApk {
        return ai.sharedLibraryFiles;
    }

    /** @hide */
    public void clearClassLoader() {
        synchronized (this) {
            mClassLoader = null;
        }
    }

    public ClassLoader getClassLoader() {
        synchronized (this) {
            if (mClassLoader != null) {