Loading core/java/com/android/internal/os/Zygote.java +34 −13 Original line number Original line Diff line number Diff line Loading @@ -94,7 +94,7 @@ public final class Zygote { private Zygote() {} private Zygote() {} /** Called for some security initialization before any fork. */ /** Called for some security initialization before any fork. */ native static void nativeSecurityInit(); static native void nativeSecurityInit(); /** /** * Forks a new VM instance. The current VM must have been started * Forks a new VM instance. The current VM must have been started Loading Loading @@ -150,14 +150,19 @@ public final class Zygote { return pid; return pid; } } native private static int nativeForkAndSpecialize(int uid, int gid, int[] gids,int runtimeFlags, private static native int nativeForkAndSpecialize(int uid, int gid, int[] gids, int[][] rlimits, int mountExternal, String seInfo, String niceName, int[] fdsToClose, int runtimeFlags, int[][] rlimits, int mountExternal, String seInfo, String niceName, int[] fdsToIgnore, boolean startChildZygote, String instructionSet, String appDataDir); int[] fdsToClose, int[] fdsToIgnore, boolean startChildZygote, String instructionSet, String appDataDir); private static native void nativeSpecializeBlastula(int uid, int gid, int[] gids, int runtimeFlags, int[][] rlimits, int mountExternal, String seInfo, String niceName, boolean startChildZygote, String instructionSet, String appDataDir); /** /** * Called to do any initialization before starting an application. * Called to do any initialization before starting an application. */ */ native static void nativePreApplicationInit(); static native void nativePreApplicationInit(); /** /** * Special method to start the system server process. In addition to the * Special method to start the system server process. In addition to the Loading Loading @@ -188,7 +193,8 @@ public final class Zygote { // Resets nice priority for zygote process. // Resets nice priority for zygote process. resetNicePriority(); resetNicePriority(); int pid = nativeForkSystemServer( int pid = nativeForkSystemServer( uid, gid, gids, runtimeFlags, rlimits, permittedCapabilities, effectiveCapabilities); uid, gid, gids, runtimeFlags, rlimits, permittedCapabilities, effectiveCapabilities); // Enable tracing as soon as we enter the system_server. // Enable tracing as soon as we enter the system_server. if (pid == 0) { if (pid == 0) { Trace.setTracingEnabled(true, runtimeFlags); Trace.setTracingEnabled(true, runtimeFlags); Loading @@ -197,19 +203,34 @@ public final class Zygote { return pid; return pid; } } native private static int nativeForkSystemServer(int uid, int gid, int[] gids, int runtimeFlags, private static native int nativeForkSystemServer(int uid, int gid, int[] gids, int runtimeFlags, int[][] rlimits, long permittedCapabilities, long effectiveCapabilities); int[][] rlimits, long permittedCapabilities, long effectiveCapabilities); /** /** * Lets children of the zygote inherit open file descriptors to this path. * Lets children of the zygote inherit open file descriptors to this path. */ */ native protected static void nativeAllowFileAcrossFork(String path); protected static native void nativeAllowFileAcrossFork(String path); /** /** * Zygote unmount storage space on initializing. * Zygote unmount storage space on initializing. * This method is called once. * This method is called once. */ */ native protected static void nativeUnmountStorageOnInit(); protected static native void nativeUnmountStorageOnInit(); protected static native void nativeGetSocketFDs(boolean isPrimary); private static native int nativeGetBlastulaPoolCount(); private static native int nativeGetBlastulaPoolEventFD(); private static native int nativeForkBlastula(int readPipeFD, int writePipeFD, int[] sessionSocketRawFDs); private static native int[] nativeGetBlastulaPipeFDs(); private static native boolean nativeRemoveBlastulaTableEntry(int blastulaPID); private static void callPostForkSystemServerHooks() { private static void callPostForkSystemServerHooks() { // SystemServer specific post fork hooks run before child post fork hooks. // SystemServer specific post fork hooks run before child post fork hooks. Loading Loading
core/java/com/android/internal/os/Zygote.java +34 −13 Original line number Original line Diff line number Diff line Loading @@ -94,7 +94,7 @@ public final class Zygote { private Zygote() {} private Zygote() {} /** Called for some security initialization before any fork. */ /** Called for some security initialization before any fork. */ native static void nativeSecurityInit(); static native void nativeSecurityInit(); /** /** * Forks a new VM instance. The current VM must have been started * Forks a new VM instance. The current VM must have been started Loading Loading @@ -150,14 +150,19 @@ public final class Zygote { return pid; return pid; } } native private static int nativeForkAndSpecialize(int uid, int gid, int[] gids,int runtimeFlags, private static native int nativeForkAndSpecialize(int uid, int gid, int[] gids, int[][] rlimits, int mountExternal, String seInfo, String niceName, int[] fdsToClose, int runtimeFlags, int[][] rlimits, int mountExternal, String seInfo, String niceName, int[] fdsToIgnore, boolean startChildZygote, String instructionSet, String appDataDir); int[] fdsToClose, int[] fdsToIgnore, boolean startChildZygote, String instructionSet, String appDataDir); private static native void nativeSpecializeBlastula(int uid, int gid, int[] gids, int runtimeFlags, int[][] rlimits, int mountExternal, String seInfo, String niceName, boolean startChildZygote, String instructionSet, String appDataDir); /** /** * Called to do any initialization before starting an application. * Called to do any initialization before starting an application. */ */ native static void nativePreApplicationInit(); static native void nativePreApplicationInit(); /** /** * Special method to start the system server process. In addition to the * Special method to start the system server process. In addition to the Loading Loading @@ -188,7 +193,8 @@ public final class Zygote { // Resets nice priority for zygote process. // Resets nice priority for zygote process. resetNicePriority(); resetNicePriority(); int pid = nativeForkSystemServer( int pid = nativeForkSystemServer( uid, gid, gids, runtimeFlags, rlimits, permittedCapabilities, effectiveCapabilities); uid, gid, gids, runtimeFlags, rlimits, permittedCapabilities, effectiveCapabilities); // Enable tracing as soon as we enter the system_server. // Enable tracing as soon as we enter the system_server. if (pid == 0) { if (pid == 0) { Trace.setTracingEnabled(true, runtimeFlags); Trace.setTracingEnabled(true, runtimeFlags); Loading @@ -197,19 +203,34 @@ public final class Zygote { return pid; return pid; } } native private static int nativeForkSystemServer(int uid, int gid, int[] gids, int runtimeFlags, private static native int nativeForkSystemServer(int uid, int gid, int[] gids, int runtimeFlags, int[][] rlimits, long permittedCapabilities, long effectiveCapabilities); int[][] rlimits, long permittedCapabilities, long effectiveCapabilities); /** /** * Lets children of the zygote inherit open file descriptors to this path. * Lets children of the zygote inherit open file descriptors to this path. */ */ native protected static void nativeAllowFileAcrossFork(String path); protected static native void nativeAllowFileAcrossFork(String path); /** /** * Zygote unmount storage space on initializing. * Zygote unmount storage space on initializing. * This method is called once. * This method is called once. */ */ native protected static void nativeUnmountStorageOnInit(); protected static native void nativeUnmountStorageOnInit(); protected static native void nativeGetSocketFDs(boolean isPrimary); private static native int nativeGetBlastulaPoolCount(); private static native int nativeGetBlastulaPoolEventFD(); private static native int nativeForkBlastula(int readPipeFD, int writePipeFD, int[] sessionSocketRawFDs); private static native int[] nativeGetBlastulaPipeFDs(); private static native boolean nativeRemoveBlastulaTableEntry(int blastulaPID); private static void callPostForkSystemServerHooks() { private static void callPostForkSystemServerHooks() { // SystemServer specific post fork hooks run before child post fork hooks. // SystemServer specific post fork hooks run before child post fork hooks. Loading