ContextImpl#startService(Intent service)流程
2019-09-23 09:43:06 0 举报
ContextImpl#startService(Intent service)流程
作者其他创作
大纲/内容
false
重载
ActivityManagerService#newProcessRecordLocked()
H#handleCreateService()
ContextImpl#validateServiceIntent(Intent service)
ActiveServices#retrieveServiceLocked()
app启动过
Service#onCreate()
通过Zygote机制启动一个新进程
ActivityManagerService#startProcessLocked()
跨进程
Client
ActiveServices#startServiceInnerLocked()
new出一个ProcessRecord对象
ActiveServices#startServiceLocked()
ActiveServices#bringUpServiceLocked()
ContextImpl#startService(Intent service)
ActiveServices#sendServiceArgsLocked()
ApplicationThread#scheduleCreateService()
ActiveServices#realStartServiceLocked
ApplicationThread#scheduleServiceArgs()
检查传入的Intent是否合法,检查的标准是Intent中的ComponentName mComponent属性和String mPackage属性是否为空,如果都为空在api 21以上会抛出异常
app != null && app.thread != null
ActiveServices#attachApplicationLocked()
SystemServer
Service#onStartCommand()
ProcessRecord != null
ActivityThread#attach()
Process#start()
ActivityManagerService#attachApplication()
r.app != null&&r.app.thread != null
ActivityManagerService#getProcessRecordLocked()
ActivityThread#main()
H#handleServiceArgs()
Server
ActivityManagerService#startProcess()
ActivityManagerService#startService()
ActivityManagerService中的`ActiveServices mServices`对象是在ActivityManagerService的构造方法中初始化的
跨进程调用ApplicationThread#scheduleCreateService()时阻塞,待结果返回后调用
ZygoteProcess.start()
0 条评论
下一页