aidl 详解

aidl 是 android interface define language 的缩写,主要是作为进程间通讯的一个接口规范,这种通讯是一种普通的 client-server 的模式,对于 client 来说只需知道 aidl 即可,无需知道实现细节就能实现调用,之所以用 aidl 是因为系统可以自动完成 decompose/marshal 或者 serialize/unserialize 的工作。

对于 server 端主要是提供 service, 这个 service 可以是 started service, 也可以是 bound service,也可以两者兼具,started service 是一直运行的, bound service 如果不同时是 started service,那么只是在 client 调用 bindService 的时候被创建来提供服务,调用结束后就自动销毁了,对于 bound service 可以支持三种通讯方式,一是进程内通讯,这时不涉及 aidl,二是单线程通讯,这时通过 messenger,本质上也是 aidl 的方式,第三种是 aidl,这种是支持并发调用 service 的

猜你喜欢

转载自www.cnblogs.com/sky-view/p/11437843.html