Context.bindService
ContextImpl.bindServiceCommon
ActivityManagerService.bindIsolatedService
ActiveServices.bindIsolatedService
retrieveServiceLocked 获取服务信息;
bringUpServiceLocked 拉起服务
startProcessLocked创建进程 (进程不存在时)
realStartServiceLocked
app.thread.scheduleCreateService (ActivityThread)创建服务
ActivityThread.handleCreateService
ContextImpl.createAppContext //创建Context 对象
packageInfo.makeApplication //
service.attach
service.onCreate
serviceDoneExecuting //解除之前设置的ANR检查
requestServiceBindingsLocked 绑定服务;
requestServiceBindingLocked
bumpServiceExecutingLocked
ActivityThread.scheduleBindService
s.onBind //回调远程服务的onBind 方法
AMS 的publishService //
ActiveServices.publishService
c.conn.connected(r.name, service); //LoadedApk.ServiceDispatcher.InnerConnection.connected
ServiceDispatcher.connected
RunConnection.run
doConnected
service.linkToDeath //
Connection.onServiceConnected //回调客户端ServiceConnection.onServiceConnected
sendServiceArgsLocked //开启service的生命周期onStartCommand
参考链接:Android四大组件之bindService源码实现详解