WrapperInitpublic class WrapperInit extends Object Startup class for the wrapper process. |
Fields Summary |
---|
private static final String | TAG |
Constructors Summary |
---|
private WrapperInit()Class not instantiable.
|
Methods Summary |
---|
public static void | execApplication(java.lang.String invokeWith, java.lang.String niceName, int targetSdkVersion, java.io.FileDescriptor pipeFd, java.lang.String[] args)Executes a runtime application with a wrapper command.
This method never returns.
StringBuilder command = new StringBuilder(invokeWith);
command.append(" /system/bin/app_process /system/bin --application");
if (niceName != null) {
command.append(" '--nice-name=").append(niceName).append("'");
}
command.append(" com.android.internal.os.WrapperInit ");
command.append(pipeFd != null ? pipeFd.getInt$() : 0);
command.append(' ");
command.append(targetSdkVersion);
Zygote.appendQuotedShellArgs(command, args);
Zygote.execShell(command.toString());
| public static void | execStandalone(java.lang.String invokeWith, java.lang.String classPath, java.lang.String className, java.lang.String[] args)Executes a standalone application with a wrapper command.
This method never returns.
StringBuilder command = new StringBuilder(invokeWith);
command.append(" /system/bin/dalvikvm -classpath '").append(classPath);
command.append("' ").append(className);
Zygote.appendQuotedShellArgs(command, args);
Zygote.execShell(command.toString());
| public static void | main(java.lang.String[] args)The main function called when starting a runtime application through a
wrapper process instead of by forking Zygote.
The first argument specifies the file descriptor for a pipe that should receive
the pid of this process, or 0 if none.
The second argument is the target SDK version for the app.
The remaining arguments are passed to the runtime.
try {
// Parse our mandatory arguments.
int fdNum = Integer.parseInt(args[0], 10);
int targetSdkVersion = Integer.parseInt(args[1], 10);
// Tell the Zygote what our actual PID is (since it only knows about the
// wrapper that it directly forked).
if (fdNum != 0) {
try {
FileDescriptor fd = ZygoteInit.createFileDescriptor(fdNum);
DataOutputStream os = new DataOutputStream(new FileOutputStream(fd));
os.writeInt(Process.myPid());
os.close();
IoUtils.closeQuietly(fd);
} catch (IOException ex) {
Slog.d(TAG, "Could not write pid of wrapped process to Zygote pipe.", ex);
}
}
// Mimic Zygote preloading.
ZygoteInit.preload();
// Launch the application.
String[] runtimeArgs = new String[args.length - 2];
System.arraycopy(args, 2, runtimeArgs, 0, runtimeArgs.length);
RuntimeInit.wrapperInit(targetSdkVersion, runtimeArgs);
} catch (ZygoteInit.MethodAndArgsCaller caller) {
caller.run();
}
|
|