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

Commit 20f1a5d3 authored by Martijn Coenen's avatar Martijn Coenen Committed by Android (Google) Code Review
Browse files

Merge "Allow app zygote to keep APK / shared libs open across fork."

parents ac07db16 4b988166
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -73,6 +73,9 @@ class AppZygoteInit {
            Log.i(TAG, "Beginning application preload for " + appInfo.packageName);
            LoadedApk loadedApk = new LoadedApk(null, appInfo, null, null, false, true, false);
            ClassLoader loader = loadedApk.getClassLoader();

            Zygote.allowAppFilesAcrossFork(appInfo);

            Class<?> cl;
            Method m;
            try {
+1 −12
Original line number Diff line number Diff line
@@ -78,18 +78,7 @@ class WebViewZygoteInit {
            ClassLoader loader = loadedApk.getClassLoader();
            doPreload(loader, WebViewFactory.getWebViewLibrary(appInfo));

            // Add the APK to the Zygote's list of allowed files for children.
            Zygote.nativeAllowFileAcrossFork(appInfo.sourceDir);
            if (appInfo.splitSourceDirs != null) {
                for (String path : appInfo.splitSourceDirs) {
                    Zygote.nativeAllowFileAcrossFork(path);
                }
            }
            if (appInfo.sharedLibraryFiles != null) {
                for (String path : appInfo.sharedLibraryFiles) {
                    Zygote.nativeAllowFileAcrossFork(path);
                }
            }
            Zygote.allowAppFilesAcrossFork(appInfo);

            Log.i(TAG, "Application preload done");
        }
+22 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import static android.system.OsConstants.O_CLOEXEC;

import static com.android.internal.os.ZygoteConnectionConstants.MAX_ZYGOTE_ARGC;

import android.content.pm.ApplicationInfo;
import android.net.Credentials;
import android.net.LocalServerSocket;
import android.net.LocalSocket;
@@ -369,6 +370,27 @@ public final class Zygote {
     */
    protected static native void nativeAllowFileAcrossFork(String path);

    /**
     * Lets children of the zygote inherit open file descriptors that belong to the
     * ApplicationInfo that is passed in.
     *
     * @param appInfo ApplicationInfo of the application
     */
    protected static void allowAppFilesAcrossFork(ApplicationInfo appInfo) {
        Zygote.nativeAllowFileAcrossFork(appInfo.sourceDir);
        if (appInfo.splitSourceDirs != null) {
            for (String path : appInfo.splitSourceDirs) {
                Zygote.nativeAllowFileAcrossFork(path);
            }
        }
        // As well as its shared libs
        if (appInfo.sharedLibraryFiles != null) {
            for (String path : appInfo.sharedLibraryFiles) {
                Zygote.nativeAllowFileAcrossFork(path);
            }
        }
    }

    /**
     * Installs a seccomp filter that limits setresuid()/setresgid() to the passed-in range
     * @param uidGidMin The smallest allowed uid/gid