Android from the foundation · Puzzle 7 of 16
Letters between apps
Apps can't reach into each other, but they can ask the town hall to deliver a request. For some requests, the town hall first checks whether the app is allowed.
The problem
In puzzle 6, the sandbox kept every app inside its walls. But a link in a chat opens the browser, and a chat app can start a phone call. If apps can't reach each other, how do they work together?
See it
The chat app wants to call a friend. It can't reach into the phone app: they're in separate sandboxes. So it writes an Intent, a request to the town hall: "open the Phone app's call screen and call this number".
Step 1 of 5The Intent goes to the town hall, system_server, by Binder, like every message to it.
Step 2 of 5A call can cost money, so it needs a permission: a right an app must be granted, here by the user tapping Allow. The town hall checks its list: has Chat been granted the phone-call permission? Predict: what if it hadn't?
Step 3 of 5Chat is allowed, so the town hall delivers the request, again by Binder, and the call starts in the phone app.
Step 4 of 5A game without the permission asks the same: the town hall refuses.
Step 5 of 5
The building block
An app sends an Intent: a message to system_server asking it to open a screen, in another app or in your own. It travels by Binder, like every message to the town hall.
Opening another app's screen often needs nothing special: a link in a chat opens the browser for anyone. But some actions need a permission: a right the app has to be granted. Placing a call straight away needs the phone-call permission, because calls can cost money. Some permissions are granted at install; risky ones, like this one, the user grants by tapping Allow in a prompt. system_server checks them before it acts. It knows which app sent the Intent from the app's UID, which Binder tells it (puzzle 13 shows how).
The analogy
You can't walk into the neighbour's house, but you can send the town hall a letter: "please put a call through for me". The town hall checks its list of who's allowed what, then passes it on, or sends it back.
Check yourself
Sources
What you now know
An Intent is a letter to the town hall: "open this screen". system_server checks the sender's permissions, then delivers it, or doesn't.
Answer every question above correctly to unlock the next puzzle.