Android Internals 101 : Android Boot Process
Hello Droids! Welcome to the brand new series of android internals 101.
Let’s begin our adventurous trip of android’s internal framework, as we all know android is the worlds most favorite operating system, and it’s designed in way that till this date no other competitor tackled with google for these scale.
About this blog, it is a first publication of multipart series which will cover all major topics of AOSP fundamentals. For now seat tight and enjoy.
First thing first, it becomes very important for us to understand. What is daemon’s before understanding android boot process ?
A daemon is a process of linux or unix that runs in background, And all daemon process ends with d.
ex :- httpd, sshd
In android daemons are responsible for managing various system level tasks, such as system clocks, input/output operations, network connectivity, etc. (To learn more about it click here: linux.org/daemon)
Enough about side story. Let’s dive into the flow …
Boot Rom :
- Boot rom / bios is a small piece of firmware stored in a chip of computers / smartphone motherboard.
- Boot rom loads the bootloader into the ram for execution.
Boot Loader :
- A bootloader is a piece of code that runs before any operating system.
- It is responsible for loading an OS of a device.
Kernel :
- It is very important layer of OS generally resides in bottom that has responsibility to connect hardware with software layers.
- As soon as bootloader loads the OS from device, it means the kernel is the very first process that executed when OS loads.
- Once kernel setup. It starts setup caches, load drivers, mount file system, start kernel daemons. Basically essential functions of the system including process management, memory management, etc.
- Once it finishes system setup, It start lookup for init process in the system files and launch the root process.
without kernel, software won’t have any chance to communicate with the hardware
Init :
- The init process is very crucial, usually identified as pid1.
- It launches various system level processes such as loading configuration files, setting up the file system, etc. It is also responsible to launch the very first zygote.
Zygote VM :
- When the command app_process launches the zygote, first VM instance created.
- It means zygote is the special process created by init, which has primary purpose to serve as a template for launching android processes.
- When a new android app is launched, Zygote forked itself to create a new Runtime / VM instance for that app which is responsible for running android app.
System Server :
- System server is the first service started by the zygote and the first thing that system server do is to start native library called android_servers to make native calls through JNI.
- Hence it becomes a very crucial component in android framework.
- System servers also starts to initialize each system services and various daemons.
- This services include Package Manager, Activity Manager, Window Manager, Notification Manager, etc. It ensures that these services are running and available to the android system and applications.
- Android system and applications often need to communicate with each other. The system server provides IPC mechanism that allows different processes to exchange data and interact.
- Some crucial functioning such as launching apps, sending notification, android handling system events.
- System server enforce android security model to ensure that applications have the appropriate permissions to perform actions and access resources on the device.
Activity Manager :
- Activity manager responsible for activity lifecycle management, and activity stack management.
- At the end. It launches an intent to start Home Launcher and register onclick listener to it.
- Whenever a click is detected, it launches a new app on tap of icon from home screen.
- The click events are transferred to Activity Manager via Binder IPC
Boot Completion .
In this way a device boot’s up, generally from power button press to home launcher.
Hope, we got the basic of android bootup process, below mentioned detailed flow diagram will help us to cement the concepts.
In the next article we’ll see such interesting topics of android internal’s, stay tuned. If you like please share with your friends, Please write your feedback for further improvements. Happy learning.
Let me know your experience about reading of this blog on my email.