Android应用程序进程启动过程的源代码分析(七)

从peers.get(index)得到的是一个ZygoteConnection对象,表示一个Socket连接,接下来就是调用ZygoteConnection.runOnce函数进一步处理了。

上文调用了handleChildProc函数。

Step 7. ZygoteConnection.handleChildProc

这个函数定义在frameworks/base/core/java/com/android/internal/os/ZygoteConnection.java文件中:

 
 
  1. [java] view plaincopyclass ZygoteConnection { 
  2.   ...... 
  3.   private void handleChildProc(Arguments parsedArgs, 
  4.   FileDescriptor[] descriptors, PrintStream newStderr) 
  5.   throws ZygoteInit.MethodAndArgsCaller { 
  6.   ...... 
  7.   if (parsedArgs.runtimeInit) { 
  8.   RuntimeInit.zygoteInit(parsedArgs.remainingArgs); 
  9.   } else { 
  10.   ...... 
  11.   } 
  12.   } 
  13.   ...... 
  14.   } 

由于在前面的Step 3中,指定了"--runtime-init"参数,表示要为新创建的进程初始化运行时库,因此,这里的parseArgs.runtimeInit值为true,于是就继续执行RuntimeInit.zygoteInit进一步处理了。

THE END