Android Binder C++原理

104 阅读1分钟

image.png

image.png

添加服务,将BBinder添加到ServiceManager中: image.png

获取服务,ServiceManager返回的IBinder实际为BpBinder: image.png

image.png

使用ServiceManager返回的BpBinder初始化BpxxService/Client, 这样,Bp端调用remote()获取到的是BpBinder: image.png //queryLocalInterface是在IBinder中定义的,默认返回NULL,但在BBinder的子类BnInterface中,重载了该方法,返回this,而BpBinder没有重载,使用IBinder的默认实现,返回NULL

java部分见此,等后续更新: www.cnblogs.com/blogs-of-lx…