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

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

Merge "Use shared namespace for bundled app classloader"

parents 56cd51a7 75b10ecc
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -27,7 +27,7 @@ class ApplicationLoaders
        return gApplicationLoaders;
    }

    public ClassLoader getClassLoader(String zip, String librarySearchPath,
    public ClassLoader getClassLoader(String zip, boolean isBundled, String librarySearchPath,
                                      String libraryPermittedPath, ClassLoader parent)
    {
        /*
@@ -56,7 +56,8 @@ class ApplicationLoaders
    
                Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, zip);
                PathClassLoader pathClassloader =
                    new PathClassLoader(zip, librarySearchPath, libraryPermittedPath, parent);
                    new PathClassLoader(zip, isBundled, librarySearchPath,
                                        libraryPermittedPath, parent);
                Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER);

                mLoaders.put(zip, pathClassloader);
+11 −4
Original line number Diff line number Diff line
@@ -366,12 +366,21 @@ public final class LoadedApk {
                    }
                }

                String libraryPermittedPath = mAppDir + File.pathSeparator + mDataDir;
                boolean isBundledApp = false;

                if (mApplicationInfo.isSystemApp()) {
                    isBundledApp = true;
                    // Add path to system libraries to libPaths;
                    // Access to system libs should be limited
                    // to bundled applications; this is why updated
                    // system apps are not included.
                    libPaths.add(System.getProperty("java.library.path"));

                    // This is necessary to grant bundled apps access to
                    // libraries located in subdirectories of /system/lib
                    libraryPermittedPath += File.pathSeparator +
                                            System.getProperty("java.library.path");
                }

                final String librarySearchPath = TextUtils.join(File.pathSeparator, libPaths);
@@ -389,10 +398,8 @@ public final class LoadedApk {
                // as this is early and necessary.
                StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();

                String libraryPermittedPath = mAppDir + File.pathSeparator + mDataDir;

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

                StrictMode.setThreadPolicy(oldPolicy);
            } else {
+1 −1
Original line number Diff line number Diff line
@@ -270,7 +270,7 @@ loadNativeCode_native(JNIEnv* env, jobject clazz, jstring path, jstring funcName
    bool needNativeBridge = false;

    void* handle = OpenNativeLibrary(env, sdkVersion, pathStr, classLoader,
                                     libraryPath, isolationPath);
                                     false, libraryPath, isolationPath);
    if (handle == NULL) {
        if (NativeBridgeIsSupported(pathStr)) {
            handle = NativeBridgeLoadLibrary(pathStr, RTLD_LAZY);