DEV Community

Cover image for Android: The System Architecture
Hodeem
Hodeem

Posted on • Edited on

Android: The System Architecture

Introduction

After working with React Native, I was curious about how the Android system worked. This guide aims to demystify the Android system architecture.

The Android system is a layered architecture, with each layer building upon the capabilities of the layers below it. Let's examine each layer in detail.

Hardware

At the foundation of the Android system lies the physical hardware - the tangible components that form the device's infrastructure. This includes the Central Processing Unit (CPU), Graphics Processing Unit (GPU), Random Access Memory (RAM) etc.

Kernel

Kernel & Hardware

The kernel serves as the core of the Android operating system, acting as an intermediary between the hardware and higher-level software components. Some of its major responsibilities include process management, memory management and device driver management.
The kernel also provides essential drivers for hardware components such as the camera, keypad, display and Wi-Fi.

Native Daemons & Libraries

Native daemons

Native daemons, written in C and C++, are long-running processes that operate in the background on system startup. They primarily interact with the kernel and are responsible for handling critical system tasks. An example of a native daemon is init which is responsible for initializing the Android system.

Native libraries, also written in C and C++, provide core functionalities to both the Android system and third-party apps. An example of a native library is libc (the C library), which provides basic C library functions for memory management, string manipulation, and file I/O.

Hardware Abstraction Layer (HAL)

Hardware abstraction layer

The HAL sits above the kernel, allowing Android to be hardware-agnostic. This abstraction enables a consistent API regardless of the underlying hardware, facilitating improved compatibility across diverse Android devices.

Examples of HAL implementations include Bluetooth HAL and Camera HAL.

Android Runtime

Android Runtime

Android Rutnime (ART) is responsible for executing and managing applications written in Java. It translates bytecode (compiled code from developers) into machine code that the device's processor can understand.

System Services

System services

Android System Services are fundamental components that manage various aspects of the Android environment. They operate in the background, ensuring smooth system operation and providing essential functionalities to applications. Examples include the
ActivityManagerService, the WindowManagerService and the PowerManagerService.

Android Framework

Android Framework

The Android Framework sits at the top. It provides high-level services to applications in the form of Java classes, interfaces and precompiled code, thereby abstracting complexity of the underlying systems. Some of the major components include the Activity Manager, the Window Manager and Content Providers.

Some of the framework is available through the use of the Android API, and other portions of the framework can only be accessed by the System API.

Android API and System APIs

The Android API, sometimes referred to as the framework API, is the public interface that app developers use to interact with the Android system. It includes functionalities for tasks such as UI creation, data storage, and hardware interaction.

System APIs, on the other hand, are interfaces intended for use by the Android system and privileged apps. They provide access to lower-level functionalities and are not available to third-party applications for security reasons.

Applications

Applications

At the very top of the stack are the applications themselves, both system apps and user-installed apps. These utilize the APIs provided by the Android Framework to interact with the underlying system.

Special mention: Binder IPC Proxies

The Binder Inter-Process Communication (IPC) mechanism facilitates efficient and secure communication between different processes and components within the Android system. It enables interaction between applications and system services.

For example, when an app requests location data, it communicates with the LocationManagerService via Binder IPC. The service processes the request and returns the location data back to the app, all mediated by the Binder mechanism.

Conclusion

Android's layered architecture is pretty fascinating when you dive into it. From the hardware all the way up to the apps we use daily, each component plays its part. Hopefully, this post made it easier to understand what's going on behind the scenes.

Sources

https://source.android.com/docs/core/architecture
https://developer.android.com/guide/platform#system-services
https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels

Top comments (0)