SystemServier.java分析

來源:互聯網
上載者:User

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.

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.