Android - System Architecture Linux Kernel Layer Manages core system services such as security, memory management, process management, network stack, and driver model. Provides an abstraction layer between the hardware and the rest of the software stack. Start the swapper process of the kernel (pid=0): idle process. It is used to initialize process management, memory management, and load Display, Camera Driver, Binder Driver and other related tasks. Start the kthreadd process (pid=2): Create kernel worker threads kworker, soft interrupt threads ksoftirqd, thermal and other kernel daemons Hardware Abstraction Layer (HAL) Purpose: Standard interface for hardware. Structure: Multiple modules for specific hardware types (e.g., WiFi, Bluetooth). Function: Loads appropriate module when hardware access is requested. Android Runtime(ART) & System Libraries ART: Each app runs in its own VM (via DEX files). Features: Ahead-of-Time (AOT) and Just-in-Time (JIT) compilation, optimized garbage collection (GC), and debugging-related support. Native System Libraries: User space daemons, HAL, boot animation. Init Process (pid=1): Parent of all user processes. Starts daemons (ueventd, logd, healthd, installd, adbd, and lmkd) and services (servicemanager, bootanim). Starts the Zygote process (parent of all Java processes). Framework Layer Zygote Process: Forked by init (in init.rc), loads VM, preloads classes/resources, starts Zygote socket. System Server: Forked from Zygote, manages Java framework including ActivityManager, WindowManager, PackageManager, PowerManager and other services. Media Server: Forked from init, manages C++ services (AudioFlinger, CameraService, etc.). App Layer Launcher: First app process from Zygote (user’s desktop). Other Apps: Browser, Phone, Email, etc., each in its own process, all forked from Zygote. Syscall & JNI Syscall: Interface between Native (user space) and Kernel. JNI: Bridge between Java and Native (C/C++) code. Appendix JNI - Java Native Interface It defines a way for the bytecode that Android compiles from managed code (written in the Java or Kotlin programming languages) to interact with native code (written in C/C++). JNI is vendor-neutral, has support for loading code from dynamic shared libraries, and while cumbersome at times is reasonably efficient.
...