When Android is started, the kernel of the kernel is automatically loaded into the memory for running. Its main function is to initialize the drivers of various devices, such as cameras, Bluetooth, and telephones.
Start the system process according to the init. rc file after the startup.
The path of init. rc is platform/system/core/rootdir/init. rc. Now, this file is analyzed.
The following format is displayed in this file:
Service zygote/system/bin/app_process-Xzygote/system/bin -- zygote -- start-system-server
Socket zygote stream 66
Onrestart write/sys/android_power/request_start wake
Onrestart write/sys/power/state on
Onrestart restart media
Onrestart restart netd
This format indicates that a series of system-level services are to be started,
Service zygoet: a zygote service is started,
/System/bin/app_process: The specific path of the Process binfile. zygote corresponds to the app_process process,
The remaining parameters will be explained later,
The path of the app_pocess file is/platform/frameworks/base/cmds/app_process/app_main.cpp. Open this file,
We can see the main () function in this file. We can conclude that this main () function is the entry to the zygote service,
Then, the parameters in the service in init. rc just now will be clear.
Main (int argc, const char * const argv []) parameters are used.
In addition, this file also has an important class, which is defined as follows:
Class AppRuntime: public AndroidRuntime {}
The path of the AndroidRuntime class is/platform/frameworks/base/core/jni/AndroidRuntime. cpp.
This class is used to start the java Runtime Environment. The most important code is:
Main (int argc, const char * const argv []) {
.....
AppRuntime runtime;
Runtime. start ("com. android. internal. OS. Zygoteinit", startSystemServer );
......
}
Execute the ZygoetInit class to initialize the Zygote service. The following describes the ZygoteInit class: