Progress Β· 0/7 phases
π€ π€ AOSP Learning Roadmap
29 min read Β· Notion
Goal: Go from Android app developer β AOSP contributor / platform engineer who understands Android internals deeply.
This roadmap is divided into 6 Phases spanning roughly 6β9 months of focused study. Each phase builds on the previous one.
πΊοΈ Roadmap Overview
| Phase | Topic | Duration | Level |
|---|---|---|---|
| Phase 1 | Prerequisites & Environment Setup | 2β3 weeks | Foundation |
| Phase 2 | AOSP Architecture & Source Code | 3β4 weeks | Intermediate |
| Phase 3 | Android Boot Process & Linux Kernel | 4β5 weeks | Intermediate |
| Phase 4 | HAL, Binder IPC & System Services | 4β6 weeks | Advanced |
| Phase 5 | Framework Internals (AMS, WMS, PMS) | 4β6 weeks | Advanced |
| Phase 6 | Customization, OTA & Contributing | 3β4 weeks | Expert |
π§ How to Use This Roadmap
- Follow phases sequentially β each phase is a prerequisite for the next.
- Each phase page has concepts, hands-on tasks, key files to read, and resources.
- Use the checklist at the bottom of each phase to track progress.
- Set up your AOSP build environment early (Phase 1) β it takes hours to download and build.
π οΈ Your End Goal Skills
- Build AOSP from source and flash to a device / emulator
- Read and navigate the AOSP codebase confidently
- Understand Android boot sequence end-to-end
- Write and integrate a custom HAL module
- Understand Binder IPC and add a system service
- Modify the Android Framework (AMS, WMS)
- Build a custom Android ROM
- Submit a patch to AOSP
π Sub-Pages
- π§ Phase 1 β Prerequisites & Environment Setup
- ποΈ Phase 2 β AOSP Architecture & Source Code
- π₯Ύ Phase 3 β Boot Process & Linux Kernel
- π Phase 4 β HAL, Binder IPC & System Services
- βοΈ Phase 5 β Framework Internals (AMS, WMS, PMS)
- π Phase 6 β Customization, OTA & Contributing
- π AOSP Master Checklist
π§ Phase 1 β Prerequisites & Environment Setup
Phase 1 β Prerequisites & Environment Setup
Duration: 2β3 weeks | Level: Foundation
You cannot learn AOSP without a working build. Get the machine ready first, then learn the theory.
π Prerequisites You Must Have
Linux / Command Line
- Comfortable with
bash,grep,find,make,git - Understand file permissions, symlinks, environment variables
- Know how to read a
Makefile
C / C++ Basics
- Pointers, memory management, structs
- Compilation pipeline: preprocessor β compiler β linker
- Reading
.hheader files - AOSP Framework and HAL are heavily C/C++
Java / Kotlin (you already have this β )
- Android Framework APIs are Java/Kotlin
- Android System Services are written in Java
Git
git log,git diff,git cherry-pick,git rebase- AOSP uses
repotool (a wrapper around multiple git repos)
π₯οΈ Machine Requirements
| Requirement | Minimum | Recommended |
|---|---|---|
| OS | Ubuntu 20.04 LTS | Ubuntu 22.04 LTS |
| RAM | 16 GB | 32β64 GB |
| Disk | 250 GB free | 500 GB SSD |
| CPU | 8 cores | 16+ cores |
| Build time | ~3β5 hours | ~1β2 hours |
β οΈ macOS is officially unsupported for building recent AOSP versions. Use Linux or a Linux VM/WSL2.
βοΈ Environment Setup Steps
Step 1 β Install build dependencies
sudo apt-get update
sudo apt-get install -y git-core gnupg flex bison build-essential \
zip curl zlib1g-dev libc6-dev-i386 libncurses5 \
lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z1-dev \
libgl1-mesa-dev libxml2-utils xsltproc unzip fontconfig \
python3 python-is-python3 openjdk-11-jdkStep 2 β Install repo tool
mkdir -p ~/.bin
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/.bin/repo
chmod a+x ~/.bin/repo
export PATH="${HOME}/.bin:${PATH}"Step 3 β Initialize AOSP source
mkdir ~/aosp && cd ~/aosp
repo init -u https://android.googlesource.com/platform/manifest \
-b android-14.0.0_r1 # pick a stable branch
repo sync -c -j$(nproc) --force-sync --no-clone-bundle
# This downloads ~100 GB. Leave it overnight.Step 4 β Set up build environment
cd ~/aosp
source build/envsetup.sh
lunch aosp_x86_64-eng # for emulator
# or: lunch aosp_arm64-engStep 5 β Build AOSP
m -j$(nproc) # full build β takes 1β5 hours
# Incremental: m -j$(nproc) frameworkStep 6 β Run on emulator
emulator &π AOSP Source Tree β First Look
aosp/
βββ art/ # Android Runtime (ART) β Java bytecode execution
βββ bionic/ # Android's C library (replaces glibc)
βββ build/ # Build system (Soong + Make)
βββ device/ # Device-specific configs
βββ frameworks/ # Android Framework (Java APIs, System Services)
β βββ base/ # Core framework β AMS, WMS, PMS, etc.
β βββ native/ # Native framework (SurfaceFlinger, etc.)
βββ hardware/ # HAL interfaces and implementations
βββ kernel/ # Linux kernel
βββ packages/ # Built-in apps (Settings, SystemUI, etc.)
βββ system/ # Low-level system (init, vold, netd)
βββ vendor/ # OEM/vendor-specific code
βββ external/ # Third-party open-source libsπ οΈ Key Tools to Learn
| Tool | Purpose |
|---|---|
repo | Manage multi-git AOSP workspace |
lunch | Select build target (device + variant) |
m / mm / mmm | Build entire tree / current module / specific module |
adb | Connect to device/emulator, push/pull files |
fastboot | Flash system partitions |
logcat | View system logs |
Android Studio | Browse AOSP source with indexing |
OpenGrok | Web-based AOSP code search (cs.android.com) |
β Phase 1 Checklist
- Ubuntu machine or VM ready with 250 GB+ free
- All build dependencies installed
-
repotool installed - AOSP source synced (android-14 branch)
-
source build/envsetup.sh&&lunchworking - Full AOSP build completed (
m) - Emulator launches successfully
- Can
adb shellinto the emulator - Familiar with top-level directory structure
- Can use
cs.android.comto search source code - Read a simple
Android.bpbuild file - Made a trivial code change + incremental build
ποΈ Phase 2 β AOSP Architecture & Source Code
Phase 2 β AOSP Architecture & Source Code
Duration: 3β4 weeks | Level: Intermediate
Understand the layered architecture of Android before diving into any single component.
ποΈ Android System Architecture (Layers)
ββββββββββββββββββββββββββββββββββββββββββββ
β Applications β β APKs (your apps)
ββββββββββββββββββββββββββββββββββββββββββββ€
β Application Framework β β Java APIs: AMS, WMS, PMS, etc.
ββββββββββββββββββββββββββββββββββββββββββββ€
β Native Libraries β Android Runtime β β C/C++ libs + ART/Dalvik
ββββββββββββββββββββββββββββββββββββββββββββ€
β Hardware Abstraction Layer β β HAL: camera, audio, sensors
ββββββββββββββββββββββββββββββββββββββββββββ€
β Linux Kernel β β Drivers, memory, power
ββββββββββββββββββββββββββββββββββββββββββββAndroid is built in layers. Each layer only communicates with the layer directly below it through well-defined interfaces.
ποΈ Build System: Soong + Make
Android's build system has two components:
Android.mk (legacy Make)
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := hello_world
LOCAL_SRC_FILES := hello.cpp
include $(BUILD_EXECUTABLE)Android.bp (Soong β modern)
cc_binary {
name: "hello_world",
srcs: ["hello.cpp"],
shared_libs: ["liblog"],
}Soong uses Blueprint language. Most new modules use .bp. Key build rules:
cc_binary,cc_library_shared,cc_library_staticβ C/C++ targetsjava_library,android_appβ Java/app targetshidl_interface,aidl_interfaceβ IPC interface definitions
π¦ Key Directories Deep Dive
frameworks/base/
The heart of the Android Framework. Read these:
frameworks/base/
βββ core/java/android/ # Public Android APIs
βββ services/core/java/ # System services (AMS, WMS, PMS)
βββ core/jni/ # JNI bridge to native code
βββ cmds/ # System command-line toolssystem/core/
Low-level system daemons:
system/core/
βββ init/ # Android init process (PID 1)
βββ adb/ # ADB daemon
βββ fastboot/ # Fastboot protocol
βββ libutils/ # Base utility librarieshardware/interfaces/
HIDL/AIDL HAL interface definitions:
hardware/interfaces/
βββ audio/
βββ camera/
βββ sensors/
βββ wifi/π Reading AOSP Source Code
How to find anything fast
# Find all files with a class name
find . -name "ActivityManagerService.java"
# grep with context
grep -rn "startActivity" frameworks/base/services/core/ --include="*.java" | head -30
# Use cs.android.com (best for navigation)Key source files to read first
| File | Why |
|---|---|
system/core/init/main.cpp | Entry point of Android userspace |
frameworks/base/core/java/android/app/ActivityThread.java | App process main loop |
frameworks/base/services/core/java/com/android/server/SystemServer.java | Launches all system services |
frameworks/base/core/java/android/os/Binder.java | IPC base class |
build/soong/Android.bp | Build system entry |
π§© Android Runtime (ART)
ART replaced Dalvik in Android 5.0+.
- AOT compilation: On install,
.dexbytecode β native machine code viadex2oat - JIT compilation: At runtime, hot paths get JIT compiled
- Garbage Collection: Concurrent, generational GC
- Profile-guided optimization (PGO): After first run, frequently-used paths get AOT compiled
Key ART files: art/runtime/, art/compiler/
π οΈ Hands-On Tasks
-
Add a log line to
SystemServer.javaand rebuild framework only:mmm frameworks/base/services adb sync system adb reboot -
Add a new
cc_binaryhello world using Soong (Android.bp), build and push to emulator. -
Explore
ActivityThread.javaβ find whereonCreate()is called. -
Read
SystemServer.javaβ list all services started instartOtherServices().
β Phase 2 Checklist
- Can explain all 5 layers of Android architecture
- Understand Soong build system (
Android.bp) - Can build a single module (
mmm) - Know top-level dirs:
frameworks/,system/,hardware/,art/ - Read
SystemServer.javaand listed all started services - Read
ActivityThread.javaβ understand app main loop - Added a custom
Android.bpmodule and built it - Can use
cs.android.comfor code navigation - Understand what ART does vs Dalvik
π₯Ύ Phase 3 β Boot Process & Linux Kernel
Phase 3 β Boot Process & Linux Kernel
Duration: 4β5 weeks | Level: Intermediate
Understanding boot sequence is the skeleton key to all AOSP internals. Every component you study later fits into this sequence.
π Android Full Boot Sequence
Power ON
β
BootROM (chip-level, vendor code)
β
Bootloader (e.g. U-Boot / LK / UEFI)
β
Linux Kernel
β
init (PID 1) β parses init.rc
β
Zygote (app process incubator)
β
System Server (all Java system services)
β
Activity Manager Service (AMS)
β
Home Launcher (first Activity)Each step is a separate deep area. Learn them from bottom to top.
1οΈβ£ BootROM & Bootloader
BootROM
- Burned into SoC (System-on-Chip) at manufacture time
- Loads the bootloader from flash into SRAM and executes it
- Handles secure boot verification (on modern devices)
Bootloader
- Sets up hardware (RAM, clocks, peripherals)
- Displays the boot logo
- Decides boot mode: normal boot, recovery, fastboot
- Verifies kernel signature (Android Verified Boot / AVB)
- Loads kernel image + initrd into RAM and jumps to kernel entry
Key concepts:
fastbootmode = bootloader-level USB protocol for flashing- Unlocking bootloader disables AVB signature verification
- OEMs implement their own bootloaders (LK, UEFI-based)
2οΈβ£ Linux Kernel
Android runs a modified Linux kernel with Android-specific patches:
| Feature | Description |
|---|---|
| Binder | Android's IPC mechanism (not in mainline Linux) |
| Ashmem | Anonymous shared memory |
| Logger | logcat kernel driver (/dev/log) |
| Wakelocks | Power management β prevents CPU sleep |
| ION allocator | Shared memory between CPU and GPU/camera |
| Low Memory Killer (LMK) | Kills background processes when memory is low |
Kernel Boot Steps
Kernel entry (arch/arm64/kernel/head.S)
β
Start kernel (init/main.c: start_kernel())
β
Mount initial RAM disk (initramfs / initrd)
β
Run /init (userspace begins)Key kernel files to read
kernel/drivers/android/binder.c # Binder IPC driver
kernel/drivers/android/ashmem.c # Shared memory
kernel/drivers/staging/android/ion/ # ION allocator3οΈβ£ init β PID 1
init is the first userspace process. Source: system/core/init/
What init does
- Mounts filesystems (
/proc,/sys,/dev) - Parses
init.rcand device-specific.rcfiles - Starts critical daemons:
ueventd,servicemanager,vold,netd - Starts Zygote
- Monitors services β restarts them on crash
init.rc syntax
# Service definition
service zygote /system/bin/app_process64 -Xzygote /system/bin --zygote --start-system-server
class main
socket zygote stream 660 root system
onrestart write /sys/android_power/request_state wake
onrestart restart media
# Action trigger
on boot
write /proc/sys/kernel/panic_on_oops 1
start zygoteKey files:
system/core/init/main.cppβ entry pointsystem/core/init/init.cppβ rc file parsingsystem/core/rootdir/init.rcβ main rc file
4οΈβ£ Zygote
Zygote is the parent of all Android app processes.
Why Zygote exists
- Starting a JVM process is slow (seconds).
- Zygote pre-loads all Android framework classes and resources once at boot.
- When launching a new app, the OS forks Zygote β a fork is milliseconds.
- The forked process has all framework code already loaded in memory (Copy-on-Write).
Zygote startup
app_process64 starts
β
ZygoteInit.main() (frameworks/base/core/java/com/android/internal/os/ZygoteInit.java)
β
Preload classes (preloaded-classes file ~7000 classes)
Preload resources (drawables, colors)
β
Start SystemServer in a fork
β
Open Zygote socket and wait for fork requestsLaunching an app
AMS sends fork request via Zygote socket
β
Zygote forks itself
β
Child process: ActivityThread.main() runs
β
App's Application.onCreate() β Activity.onCreate()Key file: frameworks/base/core/java/com/android/internal/os/ZygoteInit.java
5οΈβ£ SystemServer
SystemServer runs in a Zygote-forked process and starts all Java system services:
// frameworks/base/services/java/com/android/server/SystemServer.java
private void startBootstrapServices() {
mActivityManagerService = ActivityManagerService.Lifecycle.startService(...);
mPackageManagerService = PackageManagerService.main(...);
// ...
}
private void startCoreServices() { ... }
private void startOtherServices() {
// WindowManagerService, InputManagerService,
// NetworkManagementService, AudioService, etc.
}All system services register themselves with ServiceManager (the IPC registry).
π οΈ Hands-On Tasks
-
Add a log to
ZygoteInit.java, rebuild, and watch it inlogcat -b all:adb logcat -s Zygote -
Read
init.rcand list every service that starts before Zygote. -
Trace the
startActivitycall from app β AMS β Zygote fork β ActivityThread. -
Read
ActivityThread.main()and understand what the main Looper is doing. -
Use
adb shell pson the emulator β identify PID 1 (init), Zygote, and SystemServer.
β Phase 3 Checklist
- Can draw the full boot sequence from power-on to launcher
- Understand BootROM vs Bootloader roles
- Know Android-specific Linux kernel additions (Binder, Wakelocks, LMK)
- Read
system/core/init/main.cpp - Understand
init.rcservice/action syntax - Know why Zygote exists and how forking saves time
- Read
ZygoteInit.javaand understand preloading - Read
SystemServer.javaβ list bootstrap, core, and other services - Run
adb shell psand identify all key processes - Traced
startActivityfrom app process to Zygote fork
π Phase 4 β HAL, Binder IPC & System Services
Duration: 4β6 weeks | Level: Advanced
Binder is the backbone of Android. Everything talks through it. HAL is how the framework talks to hardware. Master both.
π Binder IPC β The Core of Android IPC
What is Binder?
Binder is Android's primary inter-process communication (IPC) mechanism. It's a Linux kernel driver (drivers/android/binder.c) that enables:
- Fast, safe, synchronous RPC between processes
- Identity-based security (callerUID, callerPID tracking)
- Object references across process boundaries
Why not UNIX sockets or pipes?
- Binder is ~10x faster than D-Bus (used on Linux desktop)
- Supports passing file descriptors and complex objects
- Enforces permissions via
uid/pidof the calling process - One copy instead of two (copy-on-write via kernel memory mapping)
π± Binder Architecture
App Process (Client) System Server (Service)
ββββββββββββββββββββββ ββββββββββββββββββββββ
β Proxy (IActivityManager)β β Stub (ActivityManager)β
β calls transact() β β onTransact() handlesβ
ββββββββββββββββββββββ ββββββββββββββββββββββ
β Binder kernel driver β
/dev/binder (mmap shared buffer)Binder Transaction Flow
- Client calls method on Proxy object
- Proxy serializes arguments into a
Parcel - Calls
IBinder.transact()β syscall into kernel - Kernel driver copies data to service process's memory
- Service's Stub
onTransact()deserializes and calls real method - Result parceled back the same way
π AIDL β Android Interface Definition Language
AIDL auto-generates Proxy + Stub boilerplate from an interface definition:
// IMyService.aidl
interface IMyService {
String getMessage(int id);
void setData(in ParcelableData data);
}Build generates:
IMyService.javaβ interfaceIMyService.Stubβ extend this in your serviceIMyService.Stub.Proxyβ used by clients automatically
AIDL in AOSP context
- Framework services (AMS, WMS) define AIDL in
frameworks/base/core/java/android/ - New AIDL-based HAL interfaces live in
hardware/interfaces/
π ServiceManager β The IPC Registry
ServiceManager is the Binder name registry (like DNS for services):
// Registering (done in SystemServer)
ServiceManager.addService("activity", mActivityManagerService);
// Getting a service (done in client)
IBinder binder = ServiceManager.getService("activity");
IActivityManager am = IActivityManager.Stub.asInterface(binder);Key files:
frameworks/native/cmds/servicemanager/servicemanager.cppframeworks/base/core/java/android/os/ServiceManager.java
π Hardware Abstraction Layer (HAL)
Why HAL exists
- Different phones have different hardware (cameras, sensors, audio chips).
- HAL provides a standard interface between Android Framework and hardware drivers.
- OEMs implement HAL for their specific hardware in
vendor/without modifying framework.
HAL Evolution
| Generation | Interface | Location |
|---|---|---|
| Legacy HAL | C struct (hw_module_t) | hardware/libhardware/ |
| HIDL HAL (8.0+) | HIDL (HAL Interface Definition Language) | hardware/interfaces/ |
| AIDL HAL (11.0+) | AIDL (same as framework AIDL) | hardware/interfaces/ |
HIDL HAL example
hardware/interfaces/sensors/2.0/
βββ ISensors.hal # Interface definition
βββ types.hal # Data types
βββ default/
βββ Sensors.h # Implementation header
βββ Sensors.cpp # OEM-provided implementationWriting a simple Legacy HAL module
// my_hal.c
#include <hardware/hardware.h>
static struct hw_module_methods_t my_module_methods = {
.open = my_device_open,
};
struct hw_module_t HAL_MODULE_INFO_SYM = {
.tag = HARDWARE_MODULE_TAG,
.id = "com.example.my_hal",
.name = "My HAL Module",
.methods = &my_module_methods,
};π οΈ Hands-On Tasks
- Trace a Binder call: Use
adb shell amto start an Activity and trace it throughActivityManagerService. - Write a custom AIDL service:
- Define
IHelloService.aidl - Implement
HelloService.javaextendingStub - Register in
SystemServer.java - Access it from an app
- Define
- Read a real system service AIDL: Browse
frameworks/base/core/java/android/app/IActivityManager.aidl - Implement a stub Legacy HAL: Write a
.cfile withhw_module_t, addAndroid.bp, build and push to/vendor/lib/hw/. - Use
adb shell service listto see all registered Binder services.
β Phase 4 Checklist
- Can explain Binder IPC flow (client proxy β kernel β service stub)
- Know why Android uses Binder instead of UNIX sockets
- Understand
Parceland how data is serialized - Can write a basic AIDL interface + service
- Read
IActivityManager.aidland traced a real call - Understand
ServiceManageras a name registry - Know the difference between Legacy HAL, HIDL, and AIDL HAL
- Read a HIDL
.halinterface file - Implemented a stub Legacy HAL module
- Registered a custom service in
SystemServer.java - Used
service listandservice callfrom adb shell
βοΈ Phase 5 β Framework Internals (AMS, WMS, PMS)
Duration: 4β6 weeks | Level: Advanced
The Android Framework is the bridge between your app and the OS. Understanding it makes you a 10x Android engineer.
ποΈ The Big Three System Services
| Service | Acronym | Responsibility |
|---|---|---|
| ActivityManagerService | AMS | Manages Activities, app lifecycle, processes |
| WindowManagerService | WMS | Manages windows, layers, display |
| PackageManagerService | PMS | Manages APK install/uninstall, permissions, component resolution |
All three live in frameworks/base/services/core/java/com/android/server/
β³ ActivityManagerService (AMS)
AMS is the most complex service in Android. It manages:
- Activity stack management (back stack, tasks)
- Starting / killing app processes
- Broadcasting (
sendBroadcast) - Starting Services
- App lifecycle (foreground/background)
- Process memory pressure (LRU cache of processes)
startActivity() deep dive
Activity.startActivity(intent)
β
Instrumentation.execStartActivity()
β
ActivityTaskManager.getService().startActivity() # Binder call to AMS
β
ActivityTaskManagerService.startActivity()
β
ActivityStarter.execute()
β
RootWindowContainer.resumeFocusedTasksTopActivities()
β
ActivityRecord.makeActiveIfNeeded() β realStartActivityLocked()
β
ClientTransaction sent to app process via Binder
β
ActivityThread handles LaunchActivityItem
β
Instrumentation.callActivityOnCreate() β Activity.onCreate()Key AMS files
frameworks/base/services/core/java/com/android/server/am/
βββ ActivityManagerService.java # Main service
βββ ProcessRecord.java # Represents one app process
βββ BroadcastQueue.java # Broadcast dispatch
βββ ActiveServices.java # Service lifecycle
βββ OomAdjuster.java # Process kill decisions
frameworks/base/services/core/java/com/android/server/wm/
βββ ActivityTaskManagerService.java # Activity-specific (split from AMS in Android 10)
βββ ActivityRecord.java # Represents one Activity instance
βββ Task.java # Back stack task
βββ ActivityStarter.java # Start activity logicπͺ WindowManagerService (WMS)
WMS manages every window on screen:
- Assigns Z-order (layers) to windows
- Handles input event routing to correct window
- Coordinates with SurfaceFlinger (native compositor) for rendering
- Manages window animations and transitions
Window hierarchy
Display
ββ RootDisplayArea
ββ StatusBar window
ββ NavigationBar window
ββ AppWindowToken (per app)
ββ WindowState (per window surface)SurfaceFlinger relationship
- WMS manages which windows exist and their properties
- SurfaceFlinger (native, C++) does the actual compositing (merging layers into final pixels)
- Apps draw into their
Surfacebuffers; SurfaceFlinger reads them
Key files:
frameworks/base/services/core/java/com/android/server/wm/WindowManagerService.java
frameworks/native/services/surfaceflinger/SurfaceFlinger.cppπ¦ PackageManagerService (PMS)
PMS handles everything related to installed apps:
- Parsing
AndroidManifest.xmlof every installed APK - Storing component info (Activities, Services, Receivers, Providers)
- Resolving intents to components
- Enforcing permissions
- APK install/uninstall pipeline
APK install flow
User taps "Install"
β
PackageInstaller UI β PackageInstallerSession
β
PMS.installPackage()
β
PackageParser.parsePackage() # Parses AndroidManifest.xml
β
dex2oat (ART compilation of .dex files)
β
Copy to /data/app/<package>/
β
Update package database (packages.xml)
β
Broadcast ACTION_PACKAGE_ADDEDπ₯ Other Important Framework Components
InputManagerService
- Reads raw input events from kernel (
/dev/input/eventX) - Routes touch/key events to the focused window via WMS
- Key file:
frameworks/base/services/core/java/com/android/server/input/InputManagerService.java
ContentProvider & ContentResolver
- IPC mechanism for structured data sharing between apps
- Uses Binder under the hood
- SQLite + URI-based query interface
BroadcastReceiver dispatch
sendBroadcast(intent)
β
AMS.broadcastIntent()
β
BroadcastQueue.enqueueOrderedBroadcastLocked()
β
BroadcastQueue.processNextBroadcast()
β
App process β ActivityThread.handleReceiver()
β
Receiver.onReceive()π οΈ Hands-On Tasks
- Add a log to
ActivityManagerService.javainstartActivity()and trace a real launch. - Add a log to
PackageManagerService.javainscanPackageLI()β watch it duringadb install. - Read
OomAdjuster.javaβ understand how the system decides which process to kill. - Use
adb shell dumpsys activityto inspect live AMS state. - Use
adb shell dumpsys windowto inspect live WMS window state. - Use
adb shell dumpsys package <your.package>to see parsed manifest info.
β Phase 5 Checklist
- Can explain the roles of AMS, WMS, and PMS
- Traced
startActivity()from app toActivity.onCreate() - Read
ActivityRecord.javaandTask.java - Understand window hierarchy in WMS
- Know SurfaceFlinger's role vs WMS
- Traced APK install flow through PMS
- Understand
OomAdjusterβ how processes are killed - Understand
BroadcastQueuedispatch - Used
dumpsys activity,dumpsys window,dumpsys package - Modified a system service and built incrementally
π Phase 6 β Customization, OTA & Contributing
Phase 6 β Customization, OTA & Contributing
Duration: 3β4 weeks | Level: Expert
Build a custom ROM. Understand OTA updates. Contribute back to AOSP.
π± Building a Custom ROM
What is a custom ROM?
A custom ROM = a full Android OS build (system.img, vendor.img, boot.img) customized beyond stock AOSP.
Popular custom ROMs: LineageOS, GrapheneOS, CalyxOS β all based on AOSP.
ROM customization areas
| Area | What you can change |
|---|---|
| SystemUI | Status bar, notification shade, quick settings |
| Settings | Add custom settings panels |
| Launcher | Replace the home screen |
| Build flags | Feature flags, debug options |
| Init.rc | Service startup behavior |
| Kernel | CPU governor, I/O scheduler |
| HAL | Custom camera/audio processing |
ποΈ SystemUI Customization
SystemUI is the process that renders the status bar, notification shade, lock screen, and navigation bar.
Source: frameworks/base/packages/SystemUI/
packages/SystemUI/src/com/android/systemui/
βββ statusbar/ # Status bar + notification shade
βββ qs/ # Quick Settings tiles
βββ navigationbar/ # Navigation bar
βββ lockscreen/ # Lock screen
βββ keyguard/ # Keyguard (PIN/pattern/biometric)Add a custom Quick Settings tile
// 1. Create class extending TileService
public class MyCustomTile extends TileService {
@Override
public void onTileAdded() { }
@Override
public void onClick() {
// toggle something
getQsTile().setState(Tile.STATE_ACTIVE);
getQsTile().updateTile();
}
}
// 2. Register in SystemUI manifest
// 3. Add to default tile list in configπ¦ OTA (Over-The-Air) Updates
Android OTA architecture
Server generates OTA package (.zip)
β
Device downloads to /data/ota_package/
β
Update Engine (update_engine daemon)
β
A/B partition switch OR Recovery mode flash
β
Device reboots into new systemA/B (Seamless) Updates (Android 7.0+)
- Device has two sets of system partitions (slot A and slot B)
- New system written to inactive slot while device is running
- On next boot, device switches to updated slot
- If boot fails, rolls back to previous slot automatically
- No downtime for user during update
Generating an OTA package
# Full OTA
m otapackage
# Output: out/target/product/<device>/βdeviceβ-ota-*.zip
# Incremental OTA (delta between two builds)
android/tools/releasetools/ota_from_target_files.py \
-i old_build.zip new_build.zip incremental_ota.zipRecovery mode
- Minimal Linux environment separate from main Android
- Can flash system partition from OTA zip
- Source:
bootable/recovery/
π Android Verified Boot (AVB)
AVB ensures the device only boots signed, unmodified system images:
Bootloader verifies kernel signature
β
Kernel verifies dm-verity hash tree of /system partition
β
Any modification to /system β boot fails- Prevents persistent rootkits
- OEM key stored in bootloader (efuse)
- Unlocking bootloader disables AVB and wipes device
π€ Contributing to AOSP
Gerrit β Android's code review system
AOSP uses Gerrit (at android-review.googlesource.com) for all code reviews.
Submit a patch step-by-step
# Step 1: Create a branch
cd frameworks/base
git checkout -b my-fix
# Step 2: Make your change
# edit files...
# Step 3: Commit with proper message
git add -A
git commit -m "Fix: correct NPE in ActivityManagerService
This commit fixes a NullPointerException that occurs when...
Bug: 12345678
Test: atest ActivityManagerServiceTest"
# Step 4: Upload to Gerrit
git push origin HEAD:refs/for/mainAOSP commit message format
<component>: <short description>
<detailed explanation of why the change is needed>
Bug: <bug number or 'None'>
Test: <how to verify the fix>Good first contributions
- Fix typos in comments/documentation
- Fix lint warnings
- Improve error messages
- Fix small bugs in non-critical paths
- Add test coverage
- Browse:
https://issuetracker.google.com/issues?q=status:open%20component:192705
π Key AOSP Resources
| Resource | URL |
|---|---|
| AOSP Source Browser | https://cs.android.com |
| AOSP Documentation | https://source.android.com |
| Gerrit Code Review | https://android-review.googlesource.com |
| Issue Tracker | https://issuetracker.google.com |
| Android Developers Blog | https://android-developers.googleblog.com |
| AOSP on GitHub (mirror) | https://github.com/aosp-mirror |
π οΈ Hands-On Tasks
- Modify
SystemUIstatus bar to show a custom icon permanently. - Customize the Settings app β add a new preference screen.
- Build an OTA package with
m otapackageand flash it on the emulator. - Study LineageOS source β pick one of their custom features and understand how it works.
- Find a real AOSP bug on the issue tracker and study the patch that fixed it on Gerrit.
- Submit your first AOSP change (even a docs typo fix counts!).
β Phase 6 Checklist
- Understand SystemUI process structure
- Modified status bar or added a QS tile
- Understand A/B partition update model
- Know how OTA packages are generated
- Understand Android Verified Boot (AVB)
- Can generate an OTA package with
m otapackage - Set up Gerrit account (
android-review.googlesource.com) - Know AOSP commit message format
- Studied at least one LineageOS custom feature patch
- Submitted or reviewed a change on Gerrit
π AOSP Master Checklist
Track your complete AOSP learning journey. Work through phases sequentially.
π§ Phase 1 β Prerequisites & Environment
- Ubuntu machine ready with 250 GB+ disk
- Build dependencies installed (
apt-get) -
repotool installed - AOSP source synced (android-14 branch, ~100 GB)
-
source build/envsetup.sh&&lunch aosp_x86_64-engworking - Full AOSP build completed (
m) - Emulator runs successfully
-
adb shellworks into emulator - Comfortable with top-level directory structure
- Can use
cs.android.comfor code navigation - Read and understood a simple
Android.bpfile - Made a trivial code change + incremental build
ποΈ Phase 2 β Architecture & Source Code
- Can explain all 5 Android architecture layers
- Understand Soong (
Android.bp) vs Make (Android.mk) - Can build a single module with
mmm - Know purpose of:
frameworks/,system/,hardware/,art/,bionic/ - Read
SystemServer.javaand listed all services - Read
ActivityThread.javaβ understand main loop - Written and built a custom
Android.bpmodule - Understand what ART does, AOT vs JIT compilation
- Know what
bionicis (Android's libc)
π₯Ύ Phase 3 β Boot Process & Linux Kernel
- Can draw boot sequence: BootROM β Bootloader β Kernel β init β Zygote β SystemServer
- Understand BootROM vs Bootloader responsibilities
- Know Android-specific kernel additions: Binder, Wakelocks, LMK, ION, Ashmem
- Read
system/core/init/main.cpp - Understand
init.rcservice/action/trigger syntax - Know why Zygote exists and how forking saves startup time
- Read
ZygoteInit.javaβ understand class preloading - Read
SystemServer.javaβ listed bootstrap/core/other services - Used
adb shell psto identify PID 1, Zygote, SystemServer - Traced
startActivityto Zygote fork
π Phase 4 β HAL, Binder IPC & System Services
- Can explain Binder IPC flow (client proxy β kernel driver β stub)
- Know why Binder is faster than UNIX sockets for Android
- Understand
Parcelserialization - Written a basic AIDL interface + service implementation
- Read
IActivityManager.aidland traced a call - Understand
ServiceManageras a Binder name registry - Know Legacy HAL vs HIDL vs AIDL HAL differences
- Read a HIDL
.halinterface definition - Implemented a stub Legacy HAL module
- Registered a custom service in
SystemServer.java - Used
service listandservice callfrom adb shell
βοΈ Phase 5 β Framework Internals
- Can explain roles of AMS, WMS, PMS
- Traced
startActivity()from app toActivity.onCreate() - Read
ActivityRecord.javaandTask.java - Understand window hierarchy in WMS
- Know SurfaceFlinger's role vs WMS
- Traced APK install flow through PMS
- Understand
OomAdjusterβ process kill decisions - Understand
BroadcastQueuedispatch chain - Used
dumpsys activityto inspect AMS state - Used
dumpsys windowto inspect WMS state - Used
dumpsys package <app>to see parsed manifest - Modified a system service + incremental build
π Phase 6 β Customization, OTA & Contributing
- Understand SystemUI process components (statusbar, QS, lockscreen)
- Modified SystemUI (custom icon or QS tile)
- Understand A/B partition seamless update model
- Know OTA package generation pipeline
- Understand Android Verified Boot (AVB) and dm-verity
- Generated an OTA package with
m otapackage - Set up Gerrit account
- Know AOSP commit message format (
Bug:,Test:fields) - Studied LineageOS source for one custom feature
- Submitted or reviewed a change on Gerrit
π Bonus / Advanced Topics
- SELinux policies in Android (
system/sepolicy/) - Android Keystore and TEE (Trusted Execution Environment)
- Camera HAL3 architecture
- Audio HAL and AudioFlinger
- Graphics pipeline: OpenGL β Vulkan β SurfaceFlinger β HWC2
- Treble architecture (vendor interface / VNDK)
- Android App Sandbox and permissions model
- ART internals: dex2oat, garbage collector
- Android Automotive OS (AAOS)
- Fuchsia / Fuchsia driver model (Google's next-gen OS)
π Essential Reference Files
| File | Why It Matters |
|---|---|
system/core/init/main.cpp | First userspace process |
system/core/rootdir/init.rc | System service definitions |
frameworks/base/core/java/com/android/internal/os/ZygoteInit.java | App process factory |
frameworks/base/services/java/com/android/server/SystemServer.java | All service launches |
frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java | Activity/process mgmt |
frameworks/base/services/core/java/com/android/server/wm/WindowManagerService.java | Window management |
frameworks/base/services/core/java/com/android/server/pm/PackageManagerService.java | APK management |
frameworks/base/core/java/android/app/ActivityThread.java | App main thread |
kernel/drivers/android/binder.c | Binder IPC kernel driver |
frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp | Display compositing |