Android AMS 也是一个系统服务,这里我们主要看一下 ActivityManagerService 的启动流程。
一、AMS启动流程
ActivityManagerService 既然是系统服务,那么肯定是通过 SystemServer 启动的,所以我们首先看一下 SystemServer 服务中启动 ActivityManagerService 相关代码。
SystemServer
源码路径:/frameworks/base/services/java/com/android/server/SystemServer.java
public final class SystemServer {......private ActivityManagerService mActivityManagerService;private void startBootstrapServices() {……// // 创建AMS服务ActivityTaskManagerService atm = mSystemServiceManager.startService(ActivityTaskManagerService.Lifecycle.class).getService();mActivityManagerService = ActivityManagerService.Lifecycle.startService(mSystemServiceManager, atm);mActivityManagerService.setSystemServiceManager(mSystemServiceManager);mActivityManagerService.setInstaller(installer);……}......
}