Understanding IPC in Android. Looking under the hood of Intents | by Ayaan Javed | May, 2024

Now that we have a fair idea of a process and its sandboxing, lets move on to their communication.

For our scenario let us take two apps, “Ayaan” and “Javed”.

“Ayaan” wants to send a hello message to “Javed”. But as we have seen, it seems impossible for an app to access the memory space of another app.

What we need is a mediator. The mediator needs to have access to the whole memory space, so it can take a message from one part of memory to another.

A bit about Linux processes

For this, we need to dive a bit into the underlying Linux OS.

The OS divides all the running software into two broad categories —

Kernel space is like this closed knit group of trusted people who manage the core functionalities of the OS.

They have unrestricted access to the whole memory space. This group generally consists of kernel (of course) and many device drivers.

User space is the rest of the public which has tight restrictions upon it. Applications running in this space, like Android, cannot access the memory of others, including the kernel space software.

Since the requirement for method of IPC is that the mediator should have access to all memory space, the Android team added a driver to that close knit group.

This came to be known as the Binder driver.

The Binder driver was given the sole responsibility of handling all IPC in Android.

Firing intent to start another activity? Binder will do that for you.

Sending a system wide broadcast? Binder’s your guy.

Interacting with any system service(like location manager)? Binder is there for you.

How does it do all of this?

Say phone app needs to send a message to maps. We know that both these processes are going to be in their sandbox.

Now with binder being in the kernel space, it has access to whole memory, including the memory stack of these apps. It takes the message from memory space of phone app and puts it in the memory of maps.

Binder is quite reliable to work with. But it gets a bit complex and cumbersome at times.

As in everything software, we have layers of abstraction over it making our life easier. Which layer you want to interact with depends on your use case. It also determines the amount of granularity(control) you get.

In the next few articles we’ll move from theory to actual code. First we’ll try and tackle the AIDL layer.

Until then, here are a few great posts if you want to know about binder –

Leave a Comment

Scroll to Top