Understanding the AOSP Architecture

Gopalakrishnan M
09. September 2024
Categories:Technology,  Embedded Android,  Android Internals,  Embedded Software


AOSP Architecture: The Android Software Stack

The Android Open Source Project (AOSP) is the backbone of Android, defining its software stack and enabling developers to create a consistent user experience across devices. For developers working on custom Android builds or deep system integrations, understanding the aosp architecture is vital. This blog will break down the aosp architecture layer by layer, providing a clear mapping of key components like the Linux kernel, HAL, Android runtime, and android system services, illustrated with practical examples.

ASOP Stack Architecture

ASOP Stack Architecture


Overview of the AOSP Architecture Stack

The aosp architecture is divided into distinct layers, each responsible for a specific set of functionalities. These layers work in harmony to enable app execution, hardware interaction, and android system services. Here's the stack at a glance:

  1. Linux Kernel
  2. Hardware Abstraction Layer (HAL)
  3. Android System Services and Daemons
  4. Android Runtime (ART)
  5. System APIs
  6. Android Framework
  7. Applications (System Apps, Manufacturer Apps, Privileged Apps)

Let's explore each layer in detail with an example to illustrate its role.

Linux Kernel

At the foundation of the aosp architecture, the Linux Kernel manages hardware resources and system-level processes. It includes device drivers for managing peripherals like audio, cameras, displays, and network hardware. The AOSP kernel is split into hardware-agnostic modules and vendor-specific modules.

The native libraries provide the low-level functionality of Android and are written primarily in C or C++. These libraries reside in the system/core and libcore directories and are used for tasks that require high performance, such as multimedia and cryptography.

Common native libraries include:

  • libc: Standard C library.
  • libm: Mathematical library for high-precision calculations.
  • libmedia: Handles multimedia services.
  • libssl: Provides secure socket layer (SSL) for encryption.
Key Responsibilities:
  • Device Drivers: Handle hardware communication.
  • Power Management: Optimizes energy efficiency.
  • Security: Implements features like SELinux for policy enforcement.
Example:

Consider a developer working on a custom device with a proprietary touchscreen. They must ensure the kernel includes a compatible driver for the touchscreen. Once the driver is integrated, higher layers can use it seamlessly.

Native Development with the Android NDK

The Android NDK (Native Development Kit) enables developers to implement performance-critical components of an android mobile application in C or C++, interfacing directly with native libraries in the aosp architecture such as libc, libmedia, and libssl. The Android NDK is particularly valuable when building computationally intensive features — such as signal processing, image recognition, or real-time sensor fusion — that benefit from native execution rather than the ART runtime. Teams building embedded products on AOSP frequently use the Android NDK to integrate hardware-accelerated DSP or GPU workloads into system-level components.

Hardware Abstraction Layer (HAL)

The HAL acts as a bridge between the hardware and software layers within the aosp architecture. It provides hardware-specific implementations through standardized APIs, allowing the Android framework to interact with hardware without knowing its specifics.

Key Responsibilities:
  • Standardizes hardware interaction.
  • Power Management: Optimizes energy efficiency.
  • Provides modularity, enabling support for different hardware configurations.
Example:

If you're developing for a custom camera module, you need to implement the Camera HAL to expose hardware features like zoom and focus to the Android framework. Apps using the camera APIs, like Camera2, rely on the HAL for actual hardware interaction.

Android System Services and Daemons

Android system services are processes that run in the background to provide core platform functionality — managing power, notifications, display rendering, audio, and telephony. These android system services are written in native code (C/C++) or Java and interact with multiple layers of the aosp architecture. Embien's Edge Computing Services rely on android system services for connectivity management, real-time data routing, and edge runtime coordination on AOSP-based deployments.

Key android system services:
  • SurfaceFlinger: Manages display rendering.
  • AudioFlinger: Handles audio playback and recording.
  • PowerManagerService: Manages device power states.
Example:

A developer customizing the power-saving features of a smartphone might need to modify the PowerManagerService — one of the core android system services — to implement custom battery-saving modes, such as limiting CPU usage during idle times.

Android Runtime (ART)

The Android Runtime (ART) executes Android applications. It compiles app code into native instructions and handles memory management and garbage collection.

Key Responsibilities:
  • Ahead-of-Time (AOT) Compilation: Converts app code to native machine code during installation for better performance.
  • Garbage Collection: Frees unused memory to optimize performance.
Example:

If a developer notices a custom app causing memory leaks, understanding ART's garbage collection can help debug and optimize the app's memory usage.

System APIs

System APIs are the low-level interfaces exposed by the aosp architecture to provide services to apps. These APIs allow apps and system components to communicate with android system services like location, sensors, and telephony.

Example:

To create an app that uses geolocation, the developer relies on system APIs like LocationManager to access GPS and network-based location data.

Android Framework

The Android Framework sits atop the lower layers, providing reusable Java/Kotlin components for app development. It acts as the primary interface between an android mobile application and android system services.

Key Responsibilities:
  • Activity Manager: Manages app lifecycle and tasks.
  • Content Providers: Allow apps to share and query data.
  • Notification Manager: Handles system notifications.
Example:

A music android mobile application uses the MediaPlayer framework API to play songs. Behind the scenes, the framework communicates with AudioFlinger through system APIs and HAL.

Building a Custom Android UI with AOSP

A custom Android UI is achieved by modifying the System UI, Launcher, and framework-level overlay resources within the aosp architecture. Whether it is a purpose-built kiosk interface, an industrial HMI panel, or a branded consumer product, custom Android UI development begins with product-level overlays and extends to boot animation, theme customization, and gesture navigation. Embien's Embedded Android Development Services deliver custom Android UI solutions tailored to each customer's hardware and brand requirements — from display form factor adaptation to OEM settings overlays.

Applications: The Android Mobile Application Layer

This layer includes both pre-installed apps and user-installed apps. Each android mobile application interacts with the Android Framework through system APIs, gaining access to the underlying android system services without directly touching hardware. An android mobile application with elevated system privileges — such as a manufacturer app — can access restricted HAL features unavailable to regular third-party apps.

Types of Applications:
  • System Apps: Integral to the OS, such as Settings and Contacts.
  • Manufacturer Apps: Custom apps provided by device manufacturers.
  • Privileged Apps: Apps with access to restricted APIs for special functionality.
Example:

When building an android mobile application for a custom device, manufacturers may grant it privileged access to HAL features not exposed to third-party apps, enabling unique functionalities like enhanced low-light capture or proprietary sensor fusion.

Mapping the Flow: From Hardware to Application

The aosp architecture orchestrates every interaction between hardware and software through its layered stack:

  • User Action: The user opens the camera app and clicks the capture button.
  • Android Framework: The app uses the Camera2 API to request a photo capture.
  • System APIs and android system services: The framework forwards the request to the Camera Service, which interacts with the Camera HAL.
  • HAL Interaction: The Camera HAL communicates with the camera driver in the Linux kernel.
  • Hardware Execution: The kernel accesses the hardware to capture the image.
  • Returning Data: The captured data travels back up through the stack, where the app displays the image.

Why Developers Must Understand the AOSP Architecture

  • Customizations: For developers building custom ROMs or working with unique hardware, deep knowledge of aosp architecture is essential to implement and debug device-specific features.
  • Performance Optimization: Identifying bottlenecks and improving system performance requires understanding how components interact across every layer of the aosp architecture.
  • Scalability: Proper use of the framework and APIs ensures apps are future-proof and compatible across devices.
  • Security: Awareness of privileged and system-level interactions is critical for building secure applications and protecting sensitive data.

Conclusion

The aosp architecture is more than just a collection of layers — it is a meticulously designed system that harmonizes hardware and software. For developers, understanding the aosp architecture is the key to unlocking Android's full potential, whether they are building a custom android mobile application, developing android system services, customizing a custom Android UI, or integrating hardware-specific solutions using the Android NDK. Knowing the roles and interactions of components like the Linux kernel, HAL, Android runtime, and android system services empowers developers to craft efficient, scalable, and secure Android experiences.

Understanding Android is not just about writing code — it is about mastering the platform that runs billions of devices worldwide. In the world of Android development, mastering aosp architecture is your greatest tool.

Related Pages

DIGITAL TRANSFORMATION SERVICES

Embien's Digital Transformation Services apply aosp architecture expertise to deliver connected, scalable Android solutions for enterprise platforms.

Read More

TECHNOLOGY CONSULTING SERVICES

Embien's Technology Consulting Services guide teams through aosp architecture decisions — from android system services design to custom Android UI strategy.

Read More

ANDROID IO MODULE MANAGER DEVELOPMENT

A case study on aosp architecture customization and android system services integration for an Android IO Module Manager.

Read More

Subscribe to our Blog