Android from the foundation · check

Know Apps and their code already?

One question for each of the 7 puzzles in this module. A right answer marks that puzzle as passed, so you can jump ahead. A wrong one tells you which puzzle to start with. Nothing is sent anywhere: it's saved in this browser.

Puzzle 6: Each app gets its own account

The bank app isn't running. Can the game open the bank's saved files now?

Not quite. The walls aren't guarded by the bank app; the kernel checks the key on every file, running or not. Learn it in puzzle 6 →

Right. The kernel checks the UID whether or not the owner is running.

Puzzle 7: Letters between apps

A game sends an Intent asking to start a phone call, but the user never granted it the phone-call permission. What happens?

Right. system_server checks the sender's permissions before acting.

Not quite. The kernel guards files and memory. Permissions for actions are checked by system_server. Learn it in puzzle 7 →

Not quite. Delivery isn't automatic: the town hall checks permissions first. Learn it in puzzle 7 →

Puzzle 8: What's inside the APK

You ship the same APK to two phones with different CPUs. Why does it run on both?

Not quite. Nobody rebuilds it: ART on the phone runs the same DEX. Learn it in puzzle 8 →

Not quite. Then it would only run on the CPUs it was built for. DEX isn't for any CPU. Learn it in puzzle 8 →

Right. DEX isn't tied to a CPU; ART on each phone runs it.

Puzzle 9: Faster code, now and later

Your app gets faster a few days after install, without an update. Why?

Right. The profile survives; AOT translation from it is what makes the next starts faster.

Not quite. CPUs don't learn. The difference is which code is already translated. Learn it in puzzle 9 →

Not quite. JIT's machine code lives in memory while the app runs and is lost when it stops. The notebook is what's kept. Learn it in puzzle 9 →

Puzzle 10: Zygote, the process every app starts from

You open three apps. How many times does Android load the framework from scratch?

Not quite. Every app uses Android's own code, like the Activity class. Zygote loads it once. Learn it in puzzle 10 →

Not quite. Each app is a copy of Zygote, which already has the framework loaded. Learn it in puzzle 10 →

Right. Zygote loads it once; every app process starts as a copy.

Puzzle 11: Sharing memory without sharing mistakes

Twenty apps are running. How many copies of the framework's pages are in memory?

Not quite. Forking shares pages; it doesn't duplicate them. Learn it in puzzle 11 →

Right. Untouched pages stay shared after a fork.

Puzzle 12: Starting an app, cold, warm and hot

You put slow setup (opening a big saved-data file) in Application.onCreate(). Which starts get slower?

Right. Application.onCreate() runs once per process, in a cold start, before any screen.

Not quite. Hot starts create nothing new. The Application only appears in a cold start. Learn it in puzzle 12 →

Not quite. The Application is created once per process. Warm and hot starts reuse the living process. Learn it in puzzle 12 →

Back to the overview →