Posts tagged ‘IPC’

October 2, 2013

The Binder (I)

High level view on the Android Binder

The Binder is one of the most interesting mechanisms in Android. Binder is an RPC/IPC mechanism. It might be surprising to many but the concept is not an Android innovation. It’s roots date back to BeOS before it was acquire by Palm. That Binder code was released as Open Source weeks before Palm’s death and named as OpenBinder. The project was started by George Hoffman and continued by Dianne Hackborn and the team at PalmSource. She was the one who actually opened it to The World before it disappeared. In any case, Android’s Binder is not a fork of OpenBinder but it is an implementation of that concept from the ground up. Yeap Dianne works at Android now 🙂

If you want to know more about the original OpenBinder, you should go and read the Documentation (http://www.angryredplanet.com/~hackbod/openbinder), it remains a must-read. 

The Binder in Android is like the Rosette Stone. It allows Apps to talk to System Server and it enable Apps to talk to each other. Developers don’t need to know any of this. They just use different interfaces for the services but under the hood, those interfaces use the Binder under the hood. Developers just don’t see it.

Android Binder

Android Binder (from Embedded Android)

As you can see in the picture above, The Binder (/dev/binder), is placed in the middle of all the action and it is used in almost everything that happens across processes in the core platform.

For example, let say an application wants to instantiate the Window Service, the next line would be the necessary code:

WindowManager mWindowManager = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE)

The application now can use all WindowManager services like:

  • mWindowManager.addView(mDecor, l);
  • mWindowManager.removeView(mDecor);
  • mWindowManager.updateViewLayout(mDecor, params);
  • ...

When an application instantiates a Service, that process is going through the Binder to the Service Manager, look it up, and sends a reference to the App, then the App can go and requests remote calls from that object. like updateViewLaout(). If you need to know more about IPC/RPC I recommend you to read a developer’s introduction to RPC and XDR, from SGI IRIX documentation.

This is overall the first part of this Binder posts. The Binder is too complex to talk about it in just one post so lets keep them dropping step by step.

Tags: , ,