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

Commit 83e16c73 authored by Dimitry Ivanov's avatar Dimitry Ivanov Committed by android-build-merger
Browse files

Merge "Restore fix for native activity without a java-code" into nyc-dev am: 53ea5a2f

am: fd167d05

* commit 'fd167d05':
  Restore fix for native activity without a java-code
parents 6ba2aecb fd167d05
Loading
Loading
Loading
Loading
+76 −78
Original line number Diff line number Diff line
@@ -281,7 +281,7 @@ public final class LoadedApk {
            addedPaths.addAll(newPaths);
        }
        synchronized (this) {
            mClassLoader = createOrUpdateClassLoaderLocked(addedPaths);
            createOrUpdateClassLoaderLocked(addedPaths);
            if (mResources != null) {
                mResources = mActivityThread.getTopLevelResources(mResDir, mSplitResDirs,
                        mOverlayDirs, mApplicationInfo.sharedLibraryFiles, Display.DEFAULT_DISPLAY,
@@ -402,13 +402,24 @@ public final class LoadedApk {
                }
            }
        }
    }

    private void createOrUpdateClassLoaderLocked(List<String> addedPaths) {
        if (mPackageName.equals("android")) {
            if (mClassLoader != null) {
                // nothing to update
                return;
            }

            if (mBaseClassLoader != null) {
                mClassLoader = mBaseClassLoader;
            } else {
                mClassLoader = ClassLoader.getSystemClassLoader();
            }

        final String zip = TextUtils.join(File.pathSeparator, outZipPaths);
            return;
        }

    private ClassLoader createOrUpdateClassLoaderLocked(List<String> addedPaths) {
        final ClassLoader classLoader;
        if (mIncludeCode && !mPackageName.equals("android")) {
        // Avoid the binder call when the package is the current application package.
        // The activity manager will perform ensure that dexopt is performed before
        // spinning up the process.
@@ -433,7 +444,7 @@ public final class LoadedApk {
        }

        makePaths(mActivityThread, mApplicationInfo, zipPaths, libPaths);
            final String zip = TextUtils.join(File.pathSeparator, zipPaths);
        final String zip = mIncludeCode ? TextUtils.join(File.pathSeparator, zipPaths) : "";
        final boolean isBundledApp = mApplicationInfo.isSystemApp()
                && !mApplicationInfo.isUpdatedSystemApp();
        String libraryPermittedPath = mDataDir;
@@ -467,36 +478,23 @@ public final class LoadedApk {
            // as this is early and necessary.
            StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();

                classLoader = ApplicationLoaders.getDefault().getClassLoader(zip,
            mClassLoader = ApplicationLoaders.getDefault().getClassLoader(zip,
                    mApplicationInfo.targetSdkVersion, isBundledApp, librarySearchPath,
                    libraryPermittedPath, mBaseClassLoader);

            StrictMode.setThreadPolicy(oldPolicy);
            } else if (addedPaths != null && addedPaths.size() > 0) {
        }

        if (addedPaths != null && addedPaths.size() > 0) {
            final String add = TextUtils.join(File.pathSeparator, addedPaths);
            ApplicationLoaders.getDefault().addPath(mClassLoader, add);
                classLoader = mClassLoader;
            } else {
                classLoader = mClassLoader;
            }
        } else {
            if (mClassLoader == null) {
                if (mBaseClassLoader == null) {
                    classLoader = ClassLoader.getSystemClassLoader();
                } else {
                    classLoader = mBaseClassLoader;
                }
            } else {
                classLoader = mClassLoader;
            }
        }
        return classLoader;
    }

    public ClassLoader getClassLoader() {
        synchronized (this) {
            if (mClassLoader == null) {
                mClassLoader = createOrUpdateClassLoaderLocked(null /*addedPaths*/);
                createOrUpdateClassLoaderLocked(null /*addedPaths*/);
            }
            return mClassLoader;
        }