1. Zygote itself is a native application, independent of the driver, kernel, created by the Init process according to the INIT.RC configuration items.
2. Zygote is the step to create the Java world with Pangu, creating the Java World:
(1) Create the Appruntime object and call it start. Subsequent activities are controlled by Appruntime.
(2) Call STARTVM to create the Java virtual machine, and then call Startreg to register the JNI function.
(3) The main function of the Com.android.internal.os.ZygoteInit class is called through JNI to enter the Java world.
(4) Call Registerzygotesocket to establish a socket as the IPC Communication Service, through which zygote can respond to future generations ' requests. At the same time, zygote pre-load classes and resources by calling Preloadclasses and Preloadresouces.
(5) Create a process system_server through Startsystemserver to serve the Java world. The process is at the core of the framework and the services of the system in the Java world reside in that process.
(6) Zygote calls the Runselectloopmode function into the loop, and this function uses the socket in (4). This function is primarily used to handle customer connections and customer requests. The client is represented by the Zygoteconnection object in Zygote, and the client's request is handled by Zygoteconnection's RunOnce.
3. Systemserver (system_server) Birth process:
(1) Zygoteinit call Startsystemserver to create the system_server process.
(2) System_server call Handlesystemprocess to complete his mission.
(3) Handlesystemprocess throws an exception and eventually calls Com.android.SystemServer's main function.
(4) The main function loads the libandroid_server.so and calls the native Init1 function.
(5) The INIT1 function invokes Com.android.SystemServer's init2 function through JNI, and the Init2 function creates a thread for loading various services.
(6) The INIT1 function eventually joins the main thread of the process into the binder communication system.
4. Zygote Split Breeding Example
Activitymanagerservice is created by Systemserver and resides in the Systemserver process. Use StartActivity to start a new activity, which is attached to a process that has not yet started, which starts the process:
(1) Activitymanagerservice sends a request message to zygote.
(2) Whenever a request data is sent, Zygote's Runselectloopmode function calls Zygoteconnection's RunOnce function fork to create the child process.
(3) The child process calls the main function of Android.app.ActivityThread. Android.app.ActivityThread is actually the process corresponding to the APK program in Android, and its main function is the main function of the APK program. Since then, the new activity has run.
Deep understanding of Android Learning Note (iii) ——— zygote