AOSP Foundations
3 min read

The frameworks/ Directory

A deep dive into the massive frameworks directory, home to the core Java APIs, native services, and multimedia engines.

If you ask a software engineer what "Android" actually is, they are usually referring to the code located inside the frameworks/ directory. This is the largest, most complex, and most heavily modified directory in the entire AOSP tree.

The frameworks/ directory contains the massive libraries, background services, and APIs that provide the actual smartphone experience.

Key Subdirectories

Because it is so large, frameworks/ is broken down into several massive sub-projects.

frameworks/base

This is the absolute heart of the Android Java API.

  • The SDK: Every class an app developer uses (like Activity, TextView, Intent, BroadcastReceiver) is defined here. When you compile an app in Android Studio, you are compiling against the code in this folder.
  • System Services: It contains the source code for the massive background managers running inside the system_server process, such as the ActivityManagerService (which decides which apps are running) and the WindowManagerService (which decides where app windows are drawn on screen).
  • System UI: The code for the notification shade, the lock screen, and the navigation bar lives inside frameworks/base/packages/SystemUI.
// Typical code found inside frameworks/base
public class Activity extends ContextThemeWrapper {
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        // Core initialization logic for every Android app
    }
}

frameworks/native

While Java powers the apps, high-performance background tasks require C++.

  • SurfaceFlinger: Located here, this is the master compositor. It takes the graphics buffers from every running app (and the system UI) and merges them together 60 to 120 times per second to draw the final screen output.
  • InputFlinger: This service constantly reads data from the touchscreen hardware and routes the touch coordinates to the correct app window.
  • Binder: The core C++ implementation of Android's Inter-Process Communication (IPC) system lives here.

frameworks/av

The "av" stands for Audio and Video. This directory houses the massive multimedia engine known as Stagefright.

  • MediaCodec: Handles the hardware-accelerated decoding and encoding of video formats like H.264, HEVC, and VP9.
  • AudioFlinger: The master audio mixer. It takes sound streams from YouTube, Spotify, and system notifications, mixes them together, applies volume levels, and sends the final digital signal to the hardware speakers.
  • CameraService: The daemon that manages concurrent access to the physical camera sensors and processes the raw image streams.

frameworks/hardware

This directory contains the higher-level framework interfaces for interacting with physical hardware sensors (like the accelerometer, gyroscope, and ambient light sensors) before the requests are passed down to the lower-level Hardware Abstraction Layers (HALs).

As an AOSP platform engineer, you will spend the vast majority of your career navigating, debugging, and modifying the code within the frameworks/ directory.

# Example: Tracing the ActivityManagerService logs natively
adb logcat -s ActivityManager