AOSP Architecture Explained with Source Code | Android Internals From Scratch Ep 2
Summary
This video guides viewers through the Android Open Source Project (AOSP) source code, mapping each architectural layer to its physical location. It covers the applications layer (packages/apps), application framework (frameworks/base), native libraries (system/core), hardware abstraction layer (hardware/interfaces), and the Linux kernel. The explanation details key components like SystemServer, HAL interfaces defined with AIDL, and the role of each layer in Android's functionality, aiming to equip viewers with the ability to navigate and understand the AOSP codebase like a professional developer.
Key Insights
The core Android framework, including system services, resides in 'frameworks/base'.
The Application Framework layer is located in the 'frameworks' directory, specifically within the 'frameworks/base' subdirectory. This contains fundamental classes (e.g., context, intent in 'core'), Android system services (e.g., ActivityManagerService, PowerManagerService, PackageManagerService in 'services'), API definitions, and system UI components. These services are crucial for Android's operation.
System Server is the central process that initializes all core Android system services.
The SystemServer.java process, located within the 'frameworks/base/services/core/java/com/android/server/' directory, is the brain of Android. After the zygote process starts, SystemServer is the first major Java process launched. It is responsible for starting all core Android system services, such as ActivityManagerService, PackageManagerService, and WindowManagerService, by calling methods like 'start bootstrap service'.
The HAL provides a standard interface for Android to interact with diverse hardware.
The Hardware Abstraction Layer (HAL) is crucial for Android's portability across different hardware. It provides a standard interface between the Android framework and device hardware. Manufacturers implement these standard interfaces for their specific hardware (e.g., camera, audio, sensors). The framework interacts with hardware through these uniform HAL interfaces, rather than specific drivers.
Sections
Introduction to AOSP and Android Architecture
AOSP is the complete source code for the Android OS, used by Google and manufacturers.
The Android Open Source Project (AOSP) is the complete source code of the Android operating system. This is the same source code that Google uses to build Android, and it is the same source code that phone manufacturers like Samsung, Xiaomi, and OnePlus use to build Android for their devices. Looking at the AOSP directory reveals many folders, but key ones include frameworks, system, packages, hardware, kernel, and device.
Android architectures consists of layers: Applications, Framework, Native Libraries, HAL, and Kernel.
Android architecture is structured in multiple layers like a stack. At the top is the Applications layer (user-facing apps). Below that is the Application Framework layer (APIs for developers). Next are the Native Libraries (C/C++ for low-level tasks like graphics and media). Below that is the Hardware Abstraction Layer (HAL), bridging framework and hardware. At the bottom is the Linux Kernel, managing hardware resources, processes, memory, and security.
Mapping Layers to AOSP Directories
System applications are found in the 'packages' directory, built like regular apps.
The Applications layer, containing all Android system applications (e.g., settings, launcher, dialer, camera), is located in the 'packages' directory. Each sub-directory represents an app, like 'settings' or 'Launcher3'. These system apps are built using the same Android framework APIs as regular apps, with the key difference being their pre-installation and access to additional system-level permissions.
The core Android framework, including system services, resides in 'frameworks/base'.
The Application Framework layer is located in the 'frameworks' directory, specifically within the 'frameworks/base' subdirectory. This contains fundamental classes (e.g., context, intent in 'core'), Android system services (e.g., ActivityManagerService, PowerManagerService, PackageManagerService in 'services'), API definitions, and system UI components. These services are crucial for Android's operation.
System Server is the central process that initializes all core Android system services.
The SystemServer.java process, located within the 'frameworks/base/services/core/java/com/android/server/' directory, is the brain of Android. After the zygote process starts, SystemServer is the first major Java process launched. It is responsible for starting all core Android system services, such as ActivityManagerService, PackageManagerService, and WindowManagerService, by calling methods like 'start bootstrap service'.
Native libraries for low-level operations are in 'system/core', written in C/C++.
The Native Libraries layer, handling low-level system operations requiring performance or direct hardware access, is located in the 'system' directory, particularly 'system/core'. This includes fundamental native components like the 'init' process, utility functions ('libutils'), crash handlers ('debuggerd'), command-line tools ('toolbox'), and logging libraries ('liblog'). These are written in C/C++ for efficiency.
The HAL provides a standard interface for Android to interact with diverse hardware.
The Hardware Abstraction Layer (HAL) is crucial for Android's portability across different hardware. It provides a standard interface between the Android framework and device hardware. Manufacturers implement these standard interfaces for their specific hardware (e.g., camera, audio, sensors). The framework interacts with hardware through these uniform HAL interfaces, rather than specific drivers.
HAL interfaces are defined using AIDL in modern Android versions.
HAL interfaces are defined using the Android Interface Definition Language (AIDL). While earlier versions used HIDL, AIDL is the modern standard for defining these interfaces in current Android versions. This allows for better performance and easier integration with the Android framework, enabling manufacturers to implement hardware-specific details without altering the framework's interaction layer.
The Linux kernel, located in the 'kernel' directory, is the foundation managing all system resources.
The Linux kernel, residing in the 'kernel' directory, is the lowest software layer of Android. It is written in C and assembly and is responsible for core system functions: process management, memory management, device drivers for hardware communication, and security. All Android components ultimately rely on the kernel for hardware interaction and resource management.
Summary of Layer-to-Code Mapping
Mapped Android layers to specific AOSP directories for practical understanding.
Summarizing the mapping: Applications layer is in 'packages/apps', Application Framework in 'frameworks/base', Native Libraries in 'system/core', HAL interfaces in 'hardware/interfaces', and the Linux kernel in 'kernel'. This direct correlation between architectural theory and source code location provides a practical understanding of Android's internal structure.
Ask a Question
*Uses 1 Wisdom coin from your coin balance











