当前位置:网站首页>Systemserver service and servicemanager service analysis
Systemserver service and servicemanager service analysis
2022-07-02 02:33:00 【Standing on the shoulders of giants, review the past and know t】
1 SystemServer Service analysis
SystemServer yes zygote The first one to start Android Service process , The main work is as follows :
(1) Create all core services of the system
(2) Add services to ServiceManager in
(3) Initialize service
1.1 SystemServer Services started
(1)power
PowerManagerService: Power management
BatteryService: Battery service
(2)ActivityManagerService
Activity management service
(3)PackageManagerService
Package management service , And bottom installd Establish communication
(4)WindowManagerService
Window management service , And surfaceflinger Service interaction
(5)TelephonyRegistry
telephony support
(6)ContentService
Data exchange between processes
(7)Sensor
LightsService: Light sense
VibratorService: Vibration
(8)Network
NetworkManagementService: Mobile network management services
NetworkStatsService: Mobile network status service
WifiP2pService:p2p service
WifiService:wifi service
ConnectivityService: Network connection status service
(9)BluetoothService
Bluetooth service
1.2 SystemServer Start process
(1)SystemServer.main()
(2)dalvik.set()
(3)System.loadlibrary("android_servers");
(4)nativeInit()
(5)initAndLoop()
Start various services of the system , Add services to ServiceManager in .
2 ServiceManager Service analysis
2.1 ServiceManager Service Overview
(1) Service process , yes android One of the core services of the system
(2) System service management : Manage the services added to the system by the system and Applications
(3) Query for services : Respond to client Request and return the corresponding service
Android If an application wants to get a system service , This system service needs to be added to ServiceManager in . If the service exits abnormally several times in a row , The system will restart . If the service is restarted , The system will restart zygote,surfaceflinger,media Etc .
2.2 ServiceManager When was it created ?
ServiceManager By init Process by parsing init.rc File , The corresponding executable program /system/bin/servicemanager, The corresponding source file is service_manager.c.
service servicemanager /system/bin/servicemanager
class core
user system
group system
critical
onrestart restart healthd
onrestart restart zygote
onrestart restart media
onrestart restart surfaceflinger
onrestart restart drm2.3 ServiceManager The boot process
(1) open binder
ServiceManager be based on Binder Mechanism realization
binder_open()
open("/dev/binder")
mmap()
(2)binder_become_context_manager()
(3) Cyclic reception binder news
Received binder Message type : Add service , Query services and obtain services
adopt binder_loop() To receive messages sent by other processes binder news
(4) Handle binder news
adopt svcmgr_handler() Handle those sent by other processes binder news
2.4 ServiceManager management service
chart 1 ServiceManager management service
(1) System or Android The application process sends a request to add system services , adopt binder Interprocess communication to ServiceManager Process processing , Then check the permissions of the process that initiated the request , Then check whether the service already exists , If there is a direct return ; If it doesn't exist , Add this service to Service List in .
(2) This service is also obtained through binder Interprocess communication to ServiceManager Process processing , Inquire about Service List Find out what to do Service, Then return .
边栏推荐
- how to come in an investnent bank team
- Is bone conduction earphone better than traditional earphones? The sound production principle of bone conduction earphones is popular science
- Es interview questions
- How to build and use redis environment
- [opencv] - comprehensive examples of five image filters
- 【带你学c带你飞】1day 第2章 (练习2.2 求华氏温度 100°F 对应的摄氏温度
- Build a modern data architecture on the cloud with Amazon AppFlow, Amazon lake formation and Amazon redshift
- 【带你学c带你飞】3day第2章 用C语言编写程序(练习 2.3 计算分段函数)
- Iterative unified writing method of binary tree
- LFM信号加噪、时频分析、滤波
猜你喜欢

Pychart creates new projects & loads faster & fonts larger & changes appearance

OpenCASCADE7.6编译

QT implementation interface jump

New programmer magazine | Li Penghui talks about open source cloud native message flow system

软件开发生命周期 --瀑布模型

LFM signal denoising, time-frequency analysis, filtering

Spend a week painstakingly sorting out the interview questions and answers of high-frequency software testing / automated testing

How to turn off debug information in rtl8189fs

Comparative analysis of MVC, MVP and MVVM, source code analysis

【带你学c带你飞】1day 第2章 (练习2.2 求华氏温度 100°F 对应的摄氏温度
随机推荐
【毕业季】研究生学长分享怎样让本科更有意义
Additional: information desensitization;
Open那啥的搭建文档
Architecture evolution from MVC to DDD
leetcode373. Find and minimum k-pair numbers (medium)
【无标题】
[learn C and fly] 4day Chapter 2 program in C language (exercise 2.5 generate power table and factorial table
Types of exhibition items available in the multimedia interactive exhibition hall
OpenCASCADE7.6编译
essay structure
New programmer magazine | Li Penghui talks about open source cloud native message flow system
Start from scratch - Web Host - 01
Software testing learning notes - network knowledge
Set status bar color
Open that kind of construction document
The middle element and the rightmost element of the shutter
Pat a-1165 block reversing (25 points)
软件开发生命周期 --瀑布模型
AcWing 245. Can you answer these questions (line segment tree)
Connected block template and variants (4 questions in total)