[url]http://blog.youkuaiyun.com/luoshengyang/article/details/6747696[/url]
简要整理:
简要整理:
ActivityManagerService.java.startProcessLocked()(此方法本身在运行在SystemService进程中)
|
Process.java.start()
|
通过localSocket发生命令(参数"android.app.ActivityThread") 至native的Zygote进程(Zygote进程中ZygoteInit.java.runSelectLoopMode()无限循环侦听socket请求)
|
收到请求后得到一个socket连接ZygoteConnection.java对象,并执行此对象的runOnce方法
|
fork()一个子进程,至此,新的应用程序进程诞生,不过后面还有很多初始话的工作要做
|
RuntimeInit.java.zygoteInit()
|
{RuntimeInit.java.zygoteInitNative(), RuntimeInit.java.invokeStaticMain()}
| |
AndroidRuntime.cpp.onZygoteInit() 先通过异常清理堆栈
| |
app_main.cpp.AppRuntime.onZygoteInit() ZygoteInit.java.main()捕获异常,反射android.app.ActivityThread.main()
| |
ProcessState.cpp.startThreadPool() ActivityThread.java.main()消息循环(等待启动Activity或者Service了)
|
ProcessState.cpp.spawnPooledThread()
|
ProcessState.cpp.PoolThread.threadLoop()
|
IPCThreadState.cpp.joinThreadPool()#此处为无限循环
|
IPCThreadState.cpp.talkWithDriver()#与Binder驱动程序交互