In Depth : Android Boot Sequence / Process
In Depth : Android Boot Sequence / Process
What is Android boot sequence ?
What is linux kernel ?
What is different between desktop linux kernel and Android linux kernel ?
What is bootloader ?
What is Zygote ?
What is x86 and ARM linux ?
What is init.rc ?
What is System Server ?
Many questions pop-up in mind when we think about Android boot sequence.
Android Boot Sequence / Process |
When power start Boot ROM code start execution from pre defined location which is hardwired on ROM. It load Bootloader into RAM and start execution
Step 2 : Bootloader
Bootloader is small program which runs before Android operating system running. Bootloader is first program to run so It is specific for board and processor. Device manufacturer either use popular bootloaders like redboot,uboot, qi bootloader or they develop own bootloaders, It’s not part of Android Operating System. bootloader is the place where OEMs and Carriers put there locks and restrictions.
Bootloader perform execution in two stages, first stage It to detect external RAM and load program which helps in second stage, In second stage bootloader setup network, memory, etc. which requires to run kernel, bootloader is able to provide configuration parameters or inputs to the kernel for specific purpose.
Android bootloader can be found at
2. main.c - Initializes hardware (clocks, board, keypad, console), creates Linux tags
Refer this link to know more about Android bootloader :
https://motorola-global-portal.custhelp.com/app/answers/detail/a_id/86208/~/bootloader-frequently-asked-questions
Step 3: Kernel
Android kernel start similar way as desktop linux kernel starts, as kernel launch it start setup cache, protected memory, scheduling, loads drivers. When kernel finish system setup first thing it look for “init” in system files and launch root process or first process of system.
Step 4: init process
init it very first process, we can say it is root process or grandmother of all processes. init process has two responsibilities 1. mount directories like /sys, /dev, /proc and 2. run init.rc script.
- init process can be found at init : <android source>/system/core/init
- init.rc file can be found in source tree at <android source>/system/core/rootdir/init.rc
- readme.txtfile can be found in source tree at <andorid source>/system/core/init/readme.txt
Android has specific format and rules for init.rc files. In Android we call it as “Android Init Language”
The Android Init Language consists of four broad classes of statements,which are Actions, Commands, Services, and Options.
Action : Actions are named sequences of commands. Actions have a trigger which is used to determine when the action should occur.
Syntax
on <trigger>
<command>
<command>
<command>
Service : Services are programs which init launches and (optionally) restarts when they exit. Syntax
service <name> <pathname> [ <argument> ]*
<option>
<option>
...
Options : Options are modifiers to services. They affect how and when init runs the service.
Let’s take a look of default init.rc file. Here I have listed only major events and services.
Action / Service | Description |
on early-init | Set init and its forked children's oom_adj. Set the security context for the init process. |
on init | setup the global environment Create cgroup mount point for cpu accounting and many |
on fs | mount mtd partitions |
on post-fs | change permissions of system directories |
on post-fs-data | change permission of /data folders and sub folders |
on boot | basic network init ,Memory Management ,etc |
service servicemanager | start system manager to manage all native services like location, audio, shared preference etc.. |
service zygote | start zygote as app_process |
At this stage you can see “Android” logo on device screen.
Step 5: Zygote and Dalvik
1. Load ZygoteInit class,
Source Code :<Android Source> /frameworks/base/core/java/com/android/internal/os/ZygoteInit.java
2. registerZygoteSocket() - Registers a server socket for zygote command connections
3. preloadClasses() - “preloaded-classes” is simple text file contains list of classes that need to be preloaded, you cna find “preloaded-classes” file at <Android Source>/frameworks/base
4. preloadResources() - preloadReaources means native themes and layouts, everything that include android.R file will be load using this method.
Step 6: System Service or Services
Other services
Step 7 : Boot Completed
Once System Services up and running in memory, Android has completed booting process, At this time “ACTION_BOOT_COMPLETED” standard broadcast action will fire.
In Depth : Android Boot Sequence / Process的更多相关文章
- In Depth : Android Shutdown Sequence
What happened when I long press power button ?What is shutdown sequence ?How is it different from de ...
- Android Stduio 发生 Process 'command 'somePath:java.exe'' finished with non-zero exit value 2 异常的解决办法
有时你会发现,在你使用Android Studio 进行编译的时候提示: Error:Execution failed for task ':demo:dexDebug'.> com.andro ...
- com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command ' finished with non-zero exit value 1
Error:Execution failed for task ':lenovoAlbum:processReleaseResources'. > com.android.ide.common. ...
- Error:Execution failed for task ':app:dexDebug'. > com.android.ide.common.process.ProcessException
异常Log: Error:Execution failed for task ‘:app:dexDebug’. > com.android.ide.common.process.ProcessE ...
- Error:Execution failed for task ':app:dexDebug'. > com.android.ide.common.process.ProcessException
异常Log: Error:Execution failed for task ':app:dexDebug'. > com.android.ide.common.process.ProcessE ...
- ionic 打包 报错Execution failed for task ':processDebugResources'. > com.android.ide.common.process.ProcessException: Failed to execute aapt
在platform --> android目录下找到build.gradle文件,打开并在def promptForReleaseKeyPassword() {...}函数前加入以下内容: 完整 ...
- java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException 的解决办法之一
在查看别人的代码的时候,遇到了把工程导入到 Android Studio ,报:ExecutionException: com.android.ide.common.process.ProcessEx ...
- om.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException
Error:Execution failed for task ':app:dexDebug'.> com.android.ide.common.process.ProcessException ...
- 高德地图Demo运行报错 com.android.ide.common.process.ProcessException: Failed to execute aapt
最近由于有需求去做导航方面的Android开发,很是无奈,以前也的确是没有搞过,领导开大会当着所有人的面说这是给我分配的第一个工作,无论如何要做好,突然间感觉压力好大,自己已经多年没有敲过代码,而且A ...
随机推荐
- 【Lucene4.8教程之六】QueryParser与Query子类:如何生成Query对象
一.概述 1.对于一个搜索而言,其核心语句为: searcher.search(query, 10); 此时,其最重要的参数为一个Qeury对象.构造一个Query对象有2种方法: (1)使用Quer ...
- 判断字符串解析是JsonObject或者JsonArray
如下,用 JSONTokener 实现: Object json = new JSONTokener(stringData).nextValue(); if(json instanceof JSONO ...
- IBM Minus One(water)
IBM Minus One Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tot ...
- JVM GC之一找出不可达对象并回收
JAVA运行时数据区域 1.程序计数器:当前线程所执行的字节码的行号指示器.一个处理器只会执行一条线程中的指令,为了线程切换后能回复到正确的执行位置,所以每条线程都需要一个独立的计数器.各条线程之间互 ...
- UVA 1572 Self-Assembly
拓扑排序,以边上标号为点,正方形为边,拓扑图中存在有向环时unbounded,否则bounded: 注意:仔细处理输入: 遍历一个点时,下一次遍历拼上的下一个方形边:即假设遍历到 A+ 时,下次从 ...
- CLR读书笔记——委托
协变性和逆变性 协变性是指方法能返回从委托返回类型派生的一个类型. 逆变性是指获取的参数可以是委托参数类型的基类. 举个例子吧,看以下定义的委托,以及方法. delegate Object MyCal ...
- Java application 性能分析分享
性能分析的主要方式 监视:监视是一种用来查看应用程序运行时行为的一般方法.通常会有多个视图(View)分别实时地显示 CPU 使用情况.内存使用情况.线程状态以及其他一些有用的信息,以便用户能很快地发 ...
- webshell 匿名用户(入侵者)
“web”的含义是显然需要服务器开放web服务,“shell”的含义是取得对服务器某种程度上操作权限.webshell常常被称为匿名用户(入侵者)通过网站端口对网站服务器的某种程度上操作的权限.由于w ...
- 栈的C数组实现
栈是一种先进后出的数据结构.栈的基本操作包括:入栈,出栈,初始化栈,清空栈,遍历栈. C代码如下: #include <stdio.h> #define MaxSize 20 typede ...
- poj1581
A Contesting Decision Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 2519 Accepted: ...