第5课第1节_Binder系统_C程序示例_框架分析

Android系统--Binder系统具体框架分析(一) - 林凯强 - 博客园  http://www.cnblogs.com/lkq1220/p/6414112.html

 

Binder系统核心:IPC        RPC远程过程调用(调用其他进程的函数)

IPC : Inter-Process Communication, 进程间通信
RPC : Remote Procedure Call, 远程过程调用

IPC

RPC

 

 

 

 

 

 

 


frameworks\native\cmds\servicemanager
service_manager.c :
a. binder_open
b. binder_become_context_manager
c. binder_loop(bs, svcmgr_handler);
c.1 res = ioctl(bs->fd, BINDER_WRITE_READ, &bwr);
c.2 binder_parse
// 解析
// 处理 : svcmgr_handler
SVC_MGR_GET_SERVICE/SVC_MGR_CHECK_SERVICE : 获取服务
SVC_MGR_ADD_SERVICE : 注册服务
// 回复

bctest.c
注册服务的过程:
a. binder_open
b. binder_call(bs, &msg, &reply, 0, SVC_MGR_ADD_SERVICE)
// 含有服务的名字
// 它会含有servicemanager回复的数据
// 0表示servicemanager
// code: 表示要调用servicemanager中的"addservice函数"


获取服务的过程:
a. binder_open
b. binder_call(bs, &msg, &reply, target, SVC_MGR_CHECK_SERVICE)
// 含有服务的名字
// 它会含有servicemanager回复的数据, 表示提供服务的进程
// 0表示servicemanager  (target=0)
// code: 表示要调用servicemanager中的"getservice函数"

binder.c (封装好的C函数)

binder_call分析

库文件binder.c分析:

 

 

binder_call实现:

 

 

 

 

 

 

 

 

 

posted on 2017-06-23 11:28  竹林海宝  阅读(339)  评论(0编辑  收藏  举报

导航