Deep Dive into Android IPC/Binder Framework at Android Builders Summit 2013

Aleksandar (Saša) Gargenta, Marakana Inc.

2013 Marakana, Inc., Creative Commons (Attribution, NonCommercial, ShareAlike) 3.0 License

Last Updated: 2013-02-19

Why are you here?

images/binders.jpg

Objectives

Note Slides and screencast from this class will be posted to: http://mrkn.co/bgnhg

Who am I?

images/aleksandar_gargenta.jpg

Aleksandar Gargenta

What is Binder?

images/Binder.svg

IPC

images/ipc.jpg

Why Binder?

images/AndroidStackArchitecture-with-connections.svg

IPC with Intents and ContentProviders?

images/HighLevelIPC.svg

Messenger IPC

images/MessengerIPC.svg

Binder Terminology

images/BinderTerminology.svg
Binder (Framework)

The overall IPC architecture

Binder Driver

The kernel-level driver that fascinates the communication across process boundaries

Binder Protocol

Low-level protocol (ioctl-based) used to communicate with the Binder driver

IBinder Interface

A well-defined behavior (i.e. methods) that Binder Objects must implement

AIDL

Android Interface Definition Language used to describe business operations on an IBinder Interface

Binder (Object)

A generic implementation of the IBinder interface

Binder Token

An abstract 32-bit integer value that uniquely identifies a Binder object across all processes on the system

Binder Service

An actual implementation of the Binder (Object) that implements the business operations

Binder Client

An object wanting to make use of the behavior offered by a binder service

Binder Transaction

An act of invoking an operation (i.e. a method) on a remote Binder object, which may involve sending/receiving data, over the Binder Protocol

Parcel

"Container for a message (data and object references) that can be sent through an IBinder." A unit of transactional data - one for the outbound request, and another for the inbound reply

Marshalling

A procedure for converting higher level applications data structures (i.e. request/response parameters) into parcels for the purposes of embedding them into Binder transactions

Unmarshalling

A procedure for reconstructing higher-level application data-structures (i.e. request/response parameters) from parcels received through Binder transactions

Proxy

An implementation of the AIDL interface that un/marshals data and maps method calls to transactions submitted via a wrapped IBinder reference to the Binder object

Stub

A partial implementation of the AIDL interface that maps transactions to Binder Service method calls while un/marshalling data

Context Manager (a.k.a. servicemanager)

A special Binder Object with a known handle (registered as handle 0) that is used as a registry/lookup service for other Binder Objects (namehandle mapping)

Binder Communication and Discovery