The Android IPC system
The information below comes from a number of sources, including my own experiments with the Android IPC and some disparate internet sources.
The overall architecture of the Android IPC system is shown in the diagram below. It consists of four major blocks; one in kernel space, and the other three in user space. The dashed lines represent the logical RPC calls. The solid lines represent the actual data flow.
BinderDriver: This is the core of IPC system. It passes data between aServiceProvider(s) and aServiceUser(s). This kernel component is provided by Android.ServiceProvider: Provides some kind of service. It parses the received RPC data from theBinderDriverand does the real work. Application developers will either make use of existing service providers (such as theCameraorAudioFlinger), or in some cases will write their own.ServiceManager: This is a special singleton ServiceProvider that provides service manager services for other service providers. This component is provided by Android.ServiceUser: This is the client. It remote calls theServiceProviderby generating an RPC and sending it to theBinderDriver. Application developers typically write their ownServiceUseras part of their application.
Here is a typical flow of events for a fictitious MultServiceProvider (a service provider that multiplies two numbers for a client) and a MultServiceUser client which doesn’t know how to do multiplication (maybe because the numbers are quaternions) and needs to use the MultServiceProvider:
ServiceManagerruns first (at power-up) and registers a special node (node O) with theBinderDriver.- The
MultServiceProvidergets anIServiceManagerproxy object for the special node O by calling the globaldefaultServiceManager()function. - The
MultServiceProviderthen callsdefaultServiceManager()->addService("Multiplier", new MultServiceProvider())to add itself as a service provider and then waits in an infinite loop for someone to request its services. TheaddServiceRPC call is routed to theServiceManagerthrough theBinderDriver. - The
BinderDrivernotices that the RPC is for theServiceManagerto add a new service, so besides routing the RPC to theServiceManagerit generates another node (let’s call it node M), for the newMultServiceProvider. - The
ServiceManagerreads the data from theBinderDriverand processes theIServiceManager::addServiceRPC call. - The
MultServiceUserclient process gets anIServiceManagerproxy object for the special node O (again by usingdefaultServiceManager()). - The client does an
IServiceManager::getService("Multiplier")RPC call to get theMultServiceProvider. This call is routed to theServiceManagerthrough theBinderDriver. - The
ServiceManagerreads the RPC data from theBinderDriver, processes theIServiceManager::getServicerequest and returns back the node representing theMultServiceProvider. MultServiceUsercallsMultServiceProvider::multiply(a, b). This call is routed to theMultServiceProviderby theBinderDriver.- The
MultServiceProviderhandles theMultServiceProvider::multiplyRPC call and sends the product of the 2 numbers in a reply to theBinderDriver. - The
BinderDriverroutes the reply back to the client. - The client reads the data from the
BinderDriverwhich contains the result of “a * b”.
In a future post I hope to discuss the whole architecture in more detail, with concrete code examples for how to use IBinder, IInterface, BBinder, BpInterface, BnInterface, etc… to create a ServiceProvider and a ServiceUser all in native C++ code on Android.

Nice article. HIghly simplified. Eagerly waiting for a sample that shows the same in the native code in android
Nice article. Waiting for the continuation of this article.
Is it possible to provide the simple example to understand the concept….
It will be highly helpful.. PLs help ….
Thanks.,
Ganesh kumar R.
Nice article. BTW, did you write the article with concrete code examples for how to use IBinder, IInterface, BBinder, BpInterface, BnInterface, etc… to create a ServiceProvider and a ServiceUser all in native C++ code on Android. ?
Thanks
Oliver
I just posted sample code to go with this post to GitHub: https://github.com/gburca/BinderDemo
Hi, it seems that this model of IPC is only the “one way”. (The client triggers the service)
Is there any way add to async. call back from service to client? (For e.g. if my service is doing work that take some time, I would like that service will be able to call client once the work is done)
Thanks for the post. BTW You use “Node O”, but the OH should be a ZERO, i.e. “Node 0”.
the best tutorial ever !
Hi,
http://ebixio.com/blog/2012/07/07/using-android-ipc-binders-from-native-code/
This website is not opening. could you please share the contents of above url.
Fixed the issue. The article is now available.