在SystemUIApplication创建完成后,SystemUIService的onCreate()方法会被调用,进而启动config.xml中定义的一些子模块。下面我们来看一下SystemUIService启动流程。
第零步:Zygote调用SystemServer的main方法启动SystemServer
static int forkSystemServer(int uid, int gid, int[] gids, int runtimeFlags,
int[][] rlimits, long permittedCapabilities, long effectiveCapabilities) {
ZygoteHooks.preFork();
int pid = nativeForkSystemServer(
uid, gid, gids, runtimeFlags, rlimits,
permittedCapabilities, effectiveCapabilities);
// Set the Java Language thread priority to the default value for new apps.
Thread.currentThread().setPriority(Thread.NORM_PRIORITY);
ZygoteHooks.postForkCommon();
return pid;
}
第一步:SystemServer的main()方法中调用SystemServer.run(),run()中调用startOtherServices()
/**
* The main entry point from zygote.
*/
public static void main(String[] args) {
new SystemServer().run();
}
private void run() {
... ...
// Start services.
try {
startBootstrapServices(t);
startCoreServices(t);
startOtherServices(t); //run()中调用了startOtherServices()