david.dev
Back to all posts

Understanding Binder IPC in Android

May 14, 2026
AOSPBinderC++Architecture

Understanding Binder IPC in Android

The Android platform is built heavily on top of a single Inter-Process Communication (IPC) mechanism known as Binder. Unlike standard Linux IPC mechanisms like pipes, sockets, or shared memory, Binder is specifically optimized for Android's component-based architecture.

Why Binder?

When Google created Android, they needed an IPC system that was:

  • Fast: Low overhead for frequent UI and system calls.
  • Memory Efficient: Mobile devices had strict memory limitations.
  • Secure: Each process runs in its own sandbox with unique UIDs.

Binder accomplishes this through a specialized kernel driver (/dev/binder) and a user-space framework (libbinder).

How a Binder Call Works

A typical Binder call involves passing data from a client process to a server process.

// Example C++ Binder Client code
sp<IServiceManager> sm = defaultServiceManager();
sp<IBinder> binder = sm->getService(String16("my_service"));

Parcel data, reply;
data.writeInterfaceToken(String16("com.example.IMyService"));
data.writeInt32(42);

// Send the transaction
binder->transact(1, data, &reply);

// Read the reply
int32_t result = reply.readInt32();

When you call transact(), the data is packed into a Parcel. The kernel driver intercepts this call, handles process context switching, securely maps memory (often zero-copy where applicable via Ashmem buffers), and invokes the onTransact() method in the destination process.

Security Context

Binder automatically passes the UID and PID of the calling process to the receiving process. This allows services to explicitly check if the caller has the required permissions to execute an action.

// Example Java Binder Server side check
int callingUid = Binder.getCallingUid();
if (callingUid != Process.SYSTEM_UID) {
    throw new SecurityException("Only system can call this method");
}

Summary

Binder is the nervous system of Android. Every time you start an Activity, bind a Service, or even check the battery level, you are performing dozens of Binder transactions under the hood. Understanding it is critical to becoming a true Platform Engineer.