#############################################
This article is extremely ice original, reproduced please indicate the source
#############################################
Systemserver is also an important daemon for the system, from the systemserver process, we see the system's various key service launches.
In addition, based on the previous analysis of zygote, we know that Systemserver is sure to start during Android startup.
Because in init.rc, it has been specified to Start-system-server = True.
So in zygote, we see the following code
if (startsystemserver) { ///If Startsystemserver is true, we will start Systemserver startsystemserver (abilist, socketname); }
We see a function that executes the startsystemserver, so let's take a look at the implementation of this function.
603 int pid;604605 try {606 Parsedargs = new zygoteconnection.arguments (args); 607 Zygo Teconnection.applydebuggersystemproperty (Parsedargs); 608 Zygoteconnection.applyinvokewithsystemproperty (ParsedA RGS); 609610/* Request to fork the system server process */611 PID = zygote.forksystemserver (// From this side we can see that systemserver is hatched by zygote to a child process 612 parsedargs.uid, parsedargs.gid,613 Pars edargs.gids,614 parsedargs.debugflags,615 null,616 Parsedargs.per mittedcapabilities,617 parsedargs.effectivecapabilities); 618} catch (IllegalArgumentException E x) {619 throw new RuntimeException (ex); 620}621622/* for child process */623 if (PID = = 0 {//In the hatching child process inside 624 if (Hassecondzygote (abilist)) {625 waitforsecondaryzygote (socketname); 626 }627628 Handlesystemserverprocess (Parsedargs); will perform operation to handlesystemserverprocess 629}Through the above, we can easily know that in the system startup process, is a zygote split out of a sub-process to deal with.
Then, in the subprocess, execute handsystemserverprocess for the next operation.
So,what is handsystemserverprocess doing?
In this process, we use a flowchart instead.
I believe this flowchart can clearly show the system startup process, after the Invokestaticmain function, we enter into the main function of Systemserver.
169 public static void Main (string[] args) { systemserver (). run (); 171 }
This way it's easy to understand.
In the run function, some of the following methods are used to start up other key processes in the system.
252 //Start services.253 try {254 startbootstrapservices (); 255 startcoreservices (); Startotherservices (); 257 } catch (Throwable ex) {258 slog.e ("System", "************************************ "); 259 slog.e (" System "," ************ Failure starting System Services ", ex); 260 throw ex;261 }
And we're going to do a detailed analysis of each key process in the system framework.
Android startup Process Analysis (12) Systemserver