android启动流程

BootROM 这个固化在rom里

Bootloader 启动kernel前的准备工作,包括正常启动与recovery,烧写等不同做出判断

启动kernel会传些参数

重点是android启动流程

1. 驱动加载

 比如usb, light, audio, camera, bt, wifi等

2. init  见system/core/init/init.cpp main()

两个阶段

第一个阶段,mkdir, mount分区

第二个阶段, selinux, log, property, start srevice

其中比较重要的有 servicemanager,zygote

/system/core/rootdir/init.zygote64.rc

  重要日志,见

init    : init first stage started!
init    : Loading SELinux policy
init    : init second stage started!
init    : Parsing file /init.rc

Parsing file /init.environ.rc
Parsing file /init.usb.rc
Parsing file /init.m7642.rc

Parsing file /init.zygote32.rc

Parsing file /system/etc/init/audioserver.rc
Parsing file /system/etc/init/bootanim.rc
Parsing file /system/etc/init/cameraserver.rc
Parsing file /system/etc/init/hwservicemanager.rc
Parsing file /system/etc/init/logcatd.rc
Parsing file /system/etc/init/netd.rc
Parsing file /system/etc/init/vold.rc
Parsing file /system/etc/init/wificond.rc
Parsing file /vendor/etc/init/[email protected]
Parsing file /vendor/etc/init/vndservicemanager.rc

starting service 'ueventd'
starting service 'console'
starting service 'servicemanager'
starting service 'hwservicemanager'
starting service 'vndservicemanager'

init    : starting service 'zygote'.

init    : starting service 'audioserver'...
init    : starting service 'surfaceflinger'...
init    : starting service 'thermalservice'...
init    : starting service 'wificond'...

init    : starting service 'bootanim'... 这个是我们看到的启动动画,通常显示公司logo.

3. android Java层七档

zygote会启动systemServer

/frameworks/base/services/java/com/android/server/SystemServer.java

 startBootstrapServices()  //Installer,DeviceIdentifiersPolicyService,ActivityManagerService,PowerManagerService,RecoverySystemService,LightsService,DisplayManagerService,PackageManagerService,UserManagerService,OverlayManagerService

startCoreServices() //BatteryService,UsageStatsService,WebViewUpdateService,BinderCallsStatsService

startOtherServices();

这个过程会有类似日志

----- Boot animation finish -----
wm_boot_animation_done: 24345
SystemServiceManager: Starting phase 1000

PHASE_BOOT_COMPLETED

此时会再次调用init.rc里的类似下面

init    : processing action (sys.boot_completed=1) from (/init.rc:727)
init    : processing action (sys.boot_completed=1) from (/vendor/etc/init/hw/init.m7642.rc:333)

ActivityManager会启动home(launcher)

ActivityManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.HOME] flg=0x10000100 cmp=.....desktop/.MainActivity} from uid 0

下面是一篇比较好的文章

Android系统启动流程_android启动流程-CSDN博客

你可能感兴趣的:(android启动流程)