当前位置:网站首页>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 .
边栏推荐
- Software development life cycle -- waterfall model
- Which brand of running headphones is good? How many professional running headphones are recommended
- DNS domain name resolution
- 2022低压电工考试题模拟考试题库模拟考试平台操作
- CSDN insertion directory in 1 second
- 2022 low voltage electrician test question simulation test question bank simulation test platform operation
- 连通块模板及变式(共4题)
- AR增强现实可应用的场景
- Start from scratch - Web Host - 01
- [learn C and fly] 2day Chapter 8 pointer (practice 8.1 password unlocking)
猜你喜欢

How to batch add background and transition effects to videos?

QT implementation interface jump
![[liuyubobobo play with leetcode algorithm interview] [00] Course Overview](/img/1c/c8cab92c74b6658c3ef608c5255f1f.png)
[liuyubobobo play with leetcode algorithm interview] [00] Course Overview

Cesium dynamic diffusion point effect

【读书笔记】程序员修炼手册—实战式学习最有效(项目驱动)

Sword finger offer 62 The last remaining number in the circle

STM32__05—PWM控制直流电机

How to execute an SQL in MySQL

Software development life cycle -- waterfall model

WebGPU(一):基本概念
随机推荐
STM32__05—PWM控制直流电机
CVPR 2022 | 大连理工提出自校准照明框架,用于现实场景的微光图像增强
query词权重, 搜索词权重计算
flutter 中間一個元素,最右邊一個元素
【带你学c带你飞】day 5 第2章 用C语言编写程序(习题2)
How to turn off debug information in rtl8189fs
LFM signal denoising, time-frequency analysis, filtering
JVM面试篇
【做题打卡】集成每日5题分享(第二期)
Realize the code scanning function of a custom layout
剑指 Offer 31. 栈的压入、弹出序列
使用开源项目【Banner】实现轮播图效果(带小圆点)
LeetCode刷题(十)——顺序刷题46至50
[punch in questions] integrated daily 5-question sharing (phase II)
Basic 01: print string
[deep learning] Infomap face clustering facecluster
AcWing 245. Can you answer these questions (line segment tree)
Provincial election + noi Part IV graph theory
Iterative unified writing method of binary tree
2022 safety officer-c certificate examination questions and mock examination