源码流程

bindService()

ContextImpl#bindServiceCommon()

ActivityManagerNative.getDefault().bindService

 ActivityManagerNative.getDefault()--》Proxy.bindService

IActivityManager==ILeoAidl  aidl 接口

ActivityManagerNative == Stub

ActivityManagerProxy == Proxy


bindService(app, token, service, resolvedType, conn, fl,
                    callingPackage, userId);===Service

ActivityManagerService === Service
ActivityManagerService#bindServiceLocked()

1.ActiveServices#bringUpServiceLocked()

2.ActiveServices#requestServiceBindingLocked(s, b.intent, callerFg, true);
1
// APP 已经创建了
app != null && app.thread != null
 realStartServiceLocked(r, app, execInFg);
    app.thread.scheduleCreateService()
    
    //创建服务的方法
    handleCreateService()
    
    service = (Service) cl.loadClass(data.info.name).newInstance();--->LeoAidlService
    
//APP没有创建
 if (app == null)
2
//绑定与否
handleBindService();

IBinder binder = s.onBind(data.intent);===>iBinder


 ActivityManagerNative.getDefault().publishService()===>AMS.publishService()


c.conn.connected(r.name, service);===>Client=>onServiceConnected()

IServiceConnection conn; 
ConnectionRecord c

connection.onServiceConnected()


IServiceConnection===ServiceDispatcher.InnerConnection

你可能感兴趣的:(源码流程)