
可以看到从C++进入Java世界的入口是ZygoteInit.java
下面从ZygoteInit.java的main方法开始
public static void main(String argv[]) {
if ("start-system-server".equals(argv[i])) {
startSystemServer = true;
}
if (startSystemServer) {
//创建出SystemServer进程
Runnable r = forkSystemServer(abiList, zygoteSocketName, zygoteServer);
}
}
然后会从C代码层,反射调用SystemServer.java的入口方法main()
SystemServer.java
/**
* The main entry point from zygote.
*/
public static void main(String[] args) {
new SystemServer().run();
}
//启动各类系统服务(100+)
startBootstrapServices();
startCoreServices();
startOtherServices();
在 startOtherServices()方法最后,所有系统服务都已经启动完成,开始通知ActivityManagerService启动launch应用
// We now tell the activity manager it is okay to run third party
// code. It will call back into us once it has gotten to the state
// where third party code can really run (but before it has actually
// started launching the initial applications), for us to complete our
// initialization.
mActivityManagerService.systemReady(() -> {
//started launching
}
后面继续launcher应用的启动。
网友评论