framework——ATMS啟動流程
1 前言
2 ATMS 啟動流程
(1)step 1:main()
/frameworks/base/services/java/com/android/server/SystemServer.java
public static void main(String[] args) {
new SystemServer().run();
}
(2)step 2:run()
/frameworks/base/services/java/com/android/server/SystemServer.java
private void run() {
try {
...
// 建立Looper
Looper.prepareMainLooper();
// 載入libandroid_servers.so
System.loadLibrary("android_servers");
// 建立系統的 Context
createSystemContext();
// 建立 SystemServiceManager
mSystemServiceManager = new SystemServiceManager(mSystemContext);
LocalServices.addService(SystemServiceManager.class, mSystemServiceManager);
...
}
...
try {
//啟動引導服務,ActivityManagerService、PackageManagerService、PowerManagerService 等
startBootstrapServices();
//啟動核心服務,BatteryService、UsageStatusService 等
startCoreServices();
//啟動其他服務,WindowManagerService、CameraService、AlarmManagerService 等
startOtherServices();
...
}
...
// 開啟訊息迴圈
Looper.loop();
}
(3)step 3:startBootstrapServices()
/frameworks/base/services/java/com/android/server/SystemServer.java
private void startBootstrapServices() {
...
//啟動 ATMS
ActivityTaskManagerService atm = mSystemServiceManager.startService(ActivityTaskManagerService.Lifecycle.class).getService();
//啟動 AMS,並將 ATMS 注入
mActivityManagerService = ActivityManagerService.Lifecycle.startService(mSystemServiceManager, atm);
...
}
(4)step 4:startService()
/frameworks/base/services/core/java/com/android/server/SystemServiceManager.java
public <T extends SystemService> T startService(Class<T> serviceClass) {
try {
final String name = serviceClass.getName();
...
final T service;
try {
Constructor<T> constructor = serviceClass.getConstructor(Context.class);
service = constructor.newInstance(mContext);
}
...
startService(service);
return service;
}
...
}
public void startService(SystemService service) {
mServices.add(service); //mServices: ArrayList<SystemService>
...
try {
service.onStart();
}
...
}
(5)Lifecycle
/frameworks/base/services/core/java/com/android/server/wm/ActivityTaskManagerService.Lifecycle.java
public static final class Lifecycle extends SystemService {
private final ActivityTaskManagerService mService;
public Lifecycle(Context context) {
super(context);
mService = new ActivityTaskManagerService(context);
}
public void onStart() {
publishBinderService(Context.ACTIVITY_TASK_SERVICE, mService);
mService.start();
}
...
public ActivityTaskManagerService getService() {
return mService;
}
}
3 ATMS 初始化
4 ATMS 初始化
相關文章
- framework——應用程式啟動流程Framework
- ATMS中去拉起新的程式,並在新程式啟動後呼叫attachApplication時,resume待啟動的ActivityAPP
- linux啟動流程Linux
- IOC 啟動流程
- kernel 啟動流程
- flowable 啟動流程
- springboot啟動流程Spring Boot
- Service啟動流程
- AMS啟動流程
- zygote啟動流程Go
- App啟動流程APP
- Flutter啟動流程Flutter
- Android系統啟動流程(四)Launcher啟動過程與系統啟動流程Android
- 主流流程引擎 flowable 啟動流程
- windows 啟動流程三Windows
- Unbound啟動流程分析
- Linux 核心啟動流程Linux
- Spring Boot啟動流程Spring Boot
- Laravel 的啟動流程Laravel
- FlutterEngin啟動流程&androidFlutterAndroid
- FlutterApp啟動流程分析FlutterAPP
- Flutter 引擎啟動流程Flutter
- Activity啟動流程分析
- nodejs啟動流程分析NodeJS
- guide-rpc-framework 流程梳理GUIIDERPCFramework
- ATMS中去pause Activity A.
- app啟動流程,activity啟動流程時序圖,binder相關資料APP時序圖
- 淺析Spring Framework框架容器啟動過程SpringFramework框架
- ac79啟動流程
- 系統的啟動流程
- SpringBoot啟動流程總結Spring Boot
- Android 9.0 init 啟動流程Android
- Android 應用啟動流程Android
- Flutter之引擎啟動流程Flutter
- flutter 應用啟動流程Flutter
- Linux:uboot啟動流程分析Linuxboot
- Tomcat啟動流程簡析Tomcat
- Flutter啟動流程簡析Flutter