#line 526:528 # Now we can start zygote.triggerzygote-start
#line 1087:1095# to start-zygote in device's init.rc to unblock zygote start.onzygote-start
wait_for_propodsign.verification.done1# A/B update verifier that marks a successful boot.exec_startupdate_verifier
startstatsd
startzygote
startzygote_secondary
servicezygote/system/bin/app_process-Xzygote/system/bin--zygote--start-system-server
classmain
priority-20
userroot
grouprootreadprocreserved_disk
socketzygotestream660rootsystem
socketusap_pool_primarystream660rootsystem
onrestartexec_background-systemsystem--/system/bin/vdcvolumeabort_fuse
onrestartwrite/sys/power/stateon
# NOTE: If the wakelock name here is changed, then also# update it in SystemSuspend.cpponrestartwrite/sys/power/wake_lockzygote_kwl
onrestartrestartaudioserver
onrestartrestartcameraserver
onrestartrestartmedia
onrestartrestart--only-if-runningmedia.tuner
onrestartrestartnetd
onrestartrestartwificond
task_profilesProcessCapacityHighMaxPerformance
criticalwindow=${zygote.critical_window.minute:-off}target=zygote-fatal
servicezygote/system/bin/app_process64-Xzygote/system/bin--zygote--start-system-server--socket-name=zygote
classmain
priority-20
userroot
grouprootreadprocreserved_disk
socketzygotestream660rootsystem
socketusap_pool_primarystream660rootsystem
onrestartexec_background-systemsystem--/system/bin/vdcvolumeabort_fuse
onrestartwrite/sys/power/stateon
# NOTE: If the wakelock name here is changed, then also# update it in SystemSuspend.cpponrestartwrite/sys/power/wake_lockzygote_kwl
onrestartrestartaudioserver
onrestartrestartcameraserver
onrestartrestartmedia
onrestartrestart--only-if-runningmedia.tuner
onrestartrestartnetd
onrestartrestartwificond
task_profilesProcessCapacityHighMaxPerformance
criticalwindow=${zygote.critical_window.minute:-off}target=zygote-fatal
//line 263:282++i;// Skip unused "parent dir" argument.while(i<argc){constchar*arg=argv[i++];if(strcmp(arg,"--zygote")==0){zygote=true;niceName=ZYGOTE_NICE_NAME;}elseif(strcmp(arg,"--start-system-server")==0){startSystemServer=true;}elseif(strcmp(arg,"--application")==0){application=true;}elseif(strncmp(arg,"--nice-name=",12)==0){niceName=(arg+12);}elseif(strncmp(arg,"--",2)!=0){className=arg;break;}else{--i;break;}}//line 309:311if(startSystemServer){args.add(String8("start-system-server"));}//line 335:343if(zygote){runtime.start("com.android.internal.os.ZygoteInit",args,zygote);}elseif(!className.empty()){runtime.start("com.android.internal.os.RuntimeInit",args,zygote);}else{fprintf(stderr,"Error: no class name or --zygote supplied.\n");app_usage();LOG_ALWAYS_FATAL("app_process: no class name or --zygote supplied.");}
// 检查参数 line 848:860for(inti=1;i<argv.length;i++){if("start-system-server".equals(argv[i])){startSystemServer=true;}elseif("--enable-lazy-preload".equals(argv[i])){enableLazyPreload=true;}elseif(argv[i].startsWith(ABI_LIST_ARG)){abiList=argv[i].substring(ABI_LIST_ARG.length());}elseif(argv[i].startsWith(SOCKET_NAME_ARG)){zygoteSocketName=argv[i].substring(SOCKET_NAME_ARG.length());}else{thrownewRuntimeException("Unknown command line argument: "+argv[i]);}}// 预加载资源供后续孵化用 line 879:889// In some configurations, we avoid preloading resources and classes eagerly.// In such cases, we will preload things prior to our first fork.if(!enableLazyPreload){bootTimingsTraceLog.traceBegin("ZygotePreload");EventLog.writeEvent(LOG_BOOT_PROGRESS_PRELOAD_START,SystemClock.uptimeMillis());preload(bootTimingsTraceLog);EventLog.writeEvent(LOG_BOOT_PROGRESS_PRELOAD_END,SystemClock.uptimeMillis());bootTimingsTraceLog.traceEnd();// ZygotePreload}// 循环等待创建请求 line 917:919// The select loop returns early in the child process after a fork and// loops forever in the zygote.caller=zygoteServer.runSelectLoop(abiList);
main 启动中会判断了传入参数有没有 --start-system-server,如果有则会孵化 SystemServer 进程。
// line 817publicstaticvoidmain(String[]argv){// 检查 argv 里是否存在 `--start-system-server` 设置 startSystemServer 标志 line 848:850for(inti=1;i<argv.length;i++){if("start-system-server".equals(argv[i])){startSystemServer=true;// 孵化 SystemServer line 902:913zygoteServer=newZygoteServer(isPrimaryZygote);if(startSystemServer){Runnabler=forkSystemServer(abiList,zygoteSocketName,zygoteServer);// {@code r == null} in the parent (zygote) process, and {@code r != null} in the// child (system_server) process.if(r!=null){r.run();return;}}