I haven't studied this file carefully yet, but a netizen suddenly asked me a question, and I still know about it.
An important process in android system applications is zygote. All java application processes are derived from zygote. The role of zygote is "son ". For more information about how an app comes out, see my previous article-Android app initialization and form event distribution.
First, you need to understand the basic knowledge of the initialization language:
A service is a program that is started during initialization and restarted upon exit (optional ). Services are as follows:
Service <name> <pathname> [<argument>] *
<Option>
<Option>
Options is an option. For more information, see linux service commands.
The zygote process is started through this file after linux kernel startup. For details, see the section in init. rc:
Service zygote/system/bin/app_process-Xzygote/system/bin -- zygote -- start-system-server
Socket zygote stream 666
Onrestart write/sys/android_power/request_state wake
Onrestart write/sys/power/state on
A piece of analysis code:
Service zygote/system/bin/app_process-Xzygote/system/bin -- zygote -- start-system-server
The binfile path of the startup service name zygote./system/bin/app_process process is followed by the startup parameter-Xzygote/system/bin -- zygote -- start-system-server. What is the function of this parameter? Check the code app_main.cpp.
If (I <argc ){
Arg = argv [I ++];
If (0 = strcmp ("-- zygote", arg )){
Bool startSystemServer = (I <argc )?
Strcmp (argv [I], "-- start-system-server") = 0: false;
SetArgv0 (argv0, "zygote ");
Set_process_name ("zygote ");
Runtime. start ("com. android. internal. OS. ZygoteInit ",
StartSystemServer );
} Else {
Set_process_name (argv0 );
Runtime. mClassName = arg;
// Remainder of args get passed to startup class main ()
Runtime. mArgC = argc-I;
Runtime. mArgV = argv + I;
LOGV ("App process is starting with pid = % d, class = % s./n ",
Getpid (), runtime. getClassName ());
Runtime. start ();
}
}
-The significance of Xzygote is to set gDvm. zygote = true in jvm. For the specific role of this parameter, read the code. The process is androidRuntime-> start () call ---> JNI_CreateJavaVM () call ----> dvmStartup () (davilin VM initialization) call ----> dvmProcessOptions ().
/System/bin: Maybe the path of the system application. If you see it, let me know.
Onrestart write/sys/android_power/request_state wake:
If the service is restarted, open the/sys/android_power/request_state file and write the wake string.