开机向导启动流程
首先来看Android启动流程:
1、Bootloader(系统启动加载器,将Linux加载到RAM);
2、Kernel
3、init进程
4、Zygote(Zygote进程是整个android系统的根进程,fork出System server进程);
5、system_server(Android系统的核心进程,负责启动各种系统服务);
6、System Services(由system_server调用startBootstrapServices()、startCoreServices()、
startOtherServices()三个方法启动各种服务,其中重要的服务启动顺序如下:
ActivityManagerService
PowerManagerService
PackageManagerService
WindowManagerService
StorageManagerService);
接下来就是开机向导的启动过程。
一、在SystemServer类的startOtherServices()方法中,当启动了所有需要的服务后,会调用ActivityManagerService类的systemReady()方法,代码如下:
private void startOtherServices() {
final Context context = mSystemContext;
VibratorService vibrator = null;
...
// 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(() -> {