Zygotepublic final class Zygote extends Object
Fields Summary |
---|
private static final String | TAG | public static final int | DEBUG_ENABLE_DEBUGGERenable debugging over JDWP | public static final int | DEBUG_ENABLE_CHECKJNIenable JNI checks | public static final int | DEBUG_ENABLE_ASSERTenable Java programming language "assert" statements | public static final int | DEBUG_ENABLE_SAFEMODEdisable the JIT compiler | public static final int | DEBUG_ENABLE_JNI_LOGGINGEnable logging of third-party JNI activity. | public static final int | MOUNT_EXTERNAL_NONENo external storage should be mounted. | public static final int | MOUNT_EXTERNAL_SINGLEUSERSingle-user external storage should be mounted. | public static final int | MOUNT_EXTERNAL_MULTIUSERMulti-user external storage should be mounted. | public static final int | MOUNT_EXTERNAL_MULTIUSER_ALLAll multi-user external storage should be mounted. | private static final dalvik.system.ZygoteHooks | VM_HOOKS |
Constructors Summary |
---|
private Zygote()
|
Methods Summary |
---|
public static void | appendQuotedShellArgs(java.lang.StringBuilder command, java.lang.String[] args)Appends quotes shell arguments to the specified string builder.
The arguments are quoted using single-quotes, escaped if necessary,
prefixed with a space, and appended to the command.
for (String arg : args) {
command.append(" '").append(arg.replace("'", "'\\''")).append("'");
}
| private static void | callPostForkChildHooks(int debugFlags, java.lang.String instructionSet)
long startTime = SystemClock.elapsedRealtime();
VM_HOOKS.postForkChild(debugFlags, instructionSet);
checkTime(startTime, "Zygote.callPostForkChildHooks");
| private static void | checkTime(long startTime, java.lang.String where)Temporary hack: check time since start time and log if over a fixed threshold.
long now = SystemClock.elapsedRealtime();
if ((now-startTime) > 1000) {
// If we are taking more than a second, log about it.
Slog.w(TAG, "Slow operation: " + (now-startTime) + "ms so far, now at " + where);
}
| public static void | execShell(java.lang.String command)Executes "/system/bin/sh -c <command>" using the exec() system call.
This method throws a runtime exception if exec() failed, otherwise, this
method never returns.
String[] args = { "/system/bin/sh", "-c", command };
try {
Os.execv(args[0], args);
} catch (ErrnoException e) {
throw new RuntimeException(e);
}
| public static int | forkAndSpecialize(int uid, int gid, int[] gids, int debugFlags, int[][] rlimits, int mountExternal, java.lang.String seInfo, java.lang.String niceName, int[] fdsToClose, java.lang.String instructionSet, java.lang.String appDataDir)Forks a new VM instance. The current VM must have been started
with the -Xzygote flag. NOTE: new instance keeps all
root capabilities. The new process is expected to call capset().
long startTime = SystemClock.elapsedRealtime();
VM_HOOKS.preFork();
checkTime(startTime, "Zygote.preFork");
int pid = nativeForkAndSpecialize(
uid, gid, gids, debugFlags, rlimits, mountExternal, seInfo, niceName, fdsToClose,
instructionSet, appDataDir);
checkTime(startTime, "Zygote.nativeForkAndSpecialize");
VM_HOOKS.postForkCommon();
checkTime(startTime, "Zygote.postForkCommon");
return pid;
| public static int | forkSystemServer(int uid, int gid, int[] gids, int debugFlags, int[][] rlimits, long permittedCapabilities, long effectiveCapabilities)Special method to start the system server process. In addition to the
common actions performed in forkAndSpecialize, the pid of the child
process is recorded such that the death of the child process will cause
zygote to exit.
VM_HOOKS.preFork();
int pid = nativeForkSystemServer(
uid, gid, gids, debugFlags, rlimits, permittedCapabilities, effectiveCapabilities);
VM_HOOKS.postForkCommon();
return pid;
| private static native int | nativeForkAndSpecialize(int uid, int gid, int[] gids, int debugFlags, int[][] rlimits, int mountExternal, java.lang.String seInfo, java.lang.String niceName, int[] fdsToClose, java.lang.String instructionSet, java.lang.String appDataDir)
| private static native int | nativeForkSystemServer(int uid, int gid, int[] gids, int debugFlags, int[][] rlimits, long permittedCapabilities, long effectiveCapabilities)
|
|