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

Commit 53ea5a2f authored by Dimitry Ivanov's avatar Dimitry Ivanov Committed by Android (Google) Code Review
Browse files

Merge "Restore fix for native activity without a java-code" into nyc-dev

parents 68b36ee0 43b28b17
Loading
Loading
Loading
Loading
+76 −78
Original line number Original line Diff line number Diff line
@@ -281,7 +281,7 @@ public final class LoadedApk {
            addedPaths.addAll(newPaths);
            addedPaths.addAll(newPaths);
        }
        }
        synchronized (this) {
        synchronized (this) {
            mClassLoader = createOrUpdateClassLoaderLocked(addedPaths);
            createOrUpdateClassLoaderLocked(addedPaths);
            if (mResources != null) {
            if (mResources != null) {
                mResources = mActivityThread.getTopLevelResources(mResDir, mSplitResDirs,
                mResources = mActivityThread.getTopLevelResources(mResDir, mSplitResDirs,
                        mOverlayDirs, mApplicationInfo.sharedLibraryFiles, Display.DEFAULT_DISPLAY,
                        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.
        // Avoid the binder call when the package is the current application package.
        // The activity manager will perform ensure that dexopt is performed before
        // The activity manager will perform ensure that dexopt is performed before
        // spinning up the process.
        // spinning up the process.
@@ -433,7 +444,7 @@ public final class LoadedApk {
        }
        }


        makePaths(mActivityThread, mApplicationInfo, zipPaths, libPaths);
        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()
        final boolean isBundledApp = mApplicationInfo.isSystemApp()
                && !mApplicationInfo.isUpdatedSystemApp();
                && !mApplicationInfo.isUpdatedSystemApp();
        String libraryPermittedPath = mDataDir;
        String libraryPermittedPath = mDataDir;
@@ -467,36 +478,23 @@ public final class LoadedApk {
            // as this is early and necessary.
            // as this is early and necessary.
            StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
            StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();


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


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

        if (addedPaths != null && addedPaths.size() > 0) {
            final String add = TextUtils.join(File.pathSeparator, addedPaths);
            final String add = TextUtils.join(File.pathSeparator, addedPaths);
            ApplicationLoaders.getDefault().addPath(mClassLoader, add);
            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() {
    public ClassLoader getClassLoader() {
        synchronized (this) {
        synchronized (this) {
            if (mClassLoader == null) {
            if (mClassLoader == null) {
                mClassLoader = createOrUpdateClassLoaderLocked(null /*addedPaths*/);
                createOrUpdateClassLoaderLocked(null /*addedPaths*/);
            }
            }
            return mClassLoader;
            return mClassLoader;
        }
        }