预加载类和资源
ZygoteInit#preload()
static void preload() {
beginIcuCachePinning();
preloadClasses(); //加载所需的各种class文件
preloadResources(); //加载资源文件
preloadOpenGL(); //初始化OpenGL
preloadSharedLibraries(); //加载系统Libraries
preloadTextResources(); //加载文字资源
// Ask the WebViewFactory to do any initialization that must run in the zygote process,
// for memory sharing purposes.
WebViewFactory.prepareWebViewInZygote(); //初始化WebView
endIcuCachePinning();
warmUpJcaProviders();
Log.d(TAG, “end preload”);
}
启动SystemServer进程
ZygoteInit#startSystemServer()
private static boolean startSystemServer(String abiList, String socketName)
throws MethodAndArgsCaller, RuntimeException {
long capabilities = posixCapabilitiesAsBits(
OsConstants.CAP_IPC_LOCK,
OsConstants.CAP_KILL,
OsConstants.CAP_NET_ADMIN,
OsConstants.CAP_NET_BIND_SERVICE,
OsConstants.CAP_NET_BROADCAST,
OsConstants.CAP_NET_RAW,
OsConstants.CAP_SYS_MODULE,
OsConstants.CAP_SYS_NICE,
OsConstants.CAP_SYS_RESOURCE,
OsConstants.CAP_SYS_TIME,
OsConstants.CAP_SYS_TTY_CONFIG
);
/* Containers run without this