
上QQ阅读APP看本书,新人免费读10天
设备和账号都新为新人
3.4 添加服务的过程
下面分析一下BpServiceManager的addService函数:

这里的remote函数返回的就是前面创建的BpBinder(0)对象:

接着看看talkWithDriver的实现,顾名思义,是与driver谈话:

IPCThreadState::joinThreadPool、ProcessState::self->startThreadPool进入线程循环,talkWithDriver等待客户端Client请求,从Binder读取命令请求进行处理。
到现在为止,MediaPlayerService的服务器端已经向服务总管ServiceManager注册了。