SystemServer::init2 將會啟動一個新的線程來啟動下面的所有JAVA服務:
Core 服務:
1. Starting Power Manager(電源管理)
2. Creating Activity Manager(活動服務)
3. Starting Telephony Registry(電話註冊服務)
4. Starting Package Manager(包管理器)
5. Set Activity Manager Service as System Process
6. Starting Context Manager
7. Starting System Context Providers
8. Starting Battery Service(電池服務)
9. Starting Alarm Manager(鬧鐘服務)
10. Starting Sensor Service
11. Starting Window Manager(啟動視窗管理器)
12. Starting Bluetooth Service(藍芽服務)
13. Starting Mount Service
其他services:
1. Starting Status Bar Service(狀態服務)
2. Starting Hardware Service(硬體服務)
3. Starting NetStat Service(網路狀態服務)
4. Starting Connectivity Service
5. Starting Notification Manager
6. Starting DeviceStorageMonitor Service
7. Starting Location Manager
8. Starting Search Service(查詢服務)
9. Starting Clipboard Service
10. Starting Checkin Service
11. Starting Wallpaper Service
12. Starting Audio Service
13. Starting HeadsetObserver
14. Starting AdbSettingsObserver
最後SystemServer::init2 將會調用 ActivityManagerService.systemReady 通過發送
Intent.CATEGORY_HOME intent來啟動第一個 activity.還有另外一種啟動system server的方法是:
通過名為 system_server的程式(原始碼:device/servers/system/system_main.cpp)它也是通過
調用 system_init 來啟動 system services,這時候就有個問題:為什麼android 有兩種方式啟動system services?
我的猜想是:
My guess is that directly start system_server may have synchronous problem with zygote because system_server will call JNI to start SystemServer::init2, while at that time zygote may not start JAVA VM yet. So Android uses another method. After zynote is initialized, fork a new process to start system services.