Android 启动过程介绍

来源:互联网 发布:linux切割图片 编辑:程序博客网 时间:2024/06/01 09:58

一般开机过程大致可以分为三个大阶段:

1. OS级别,由bootloader载入linux kernel后,kernel开始初始化, 并载入built-in的驱动程序。Kernel完成开机后,载入init process,切换至user-space后,结束kernel 的循序过程(sequence),进入排程模式(process scheduling)。

2. Android-level,由init process 开始,读取init.rc,Native服务启动,并启动重要的外部程序,例如:servicemanager、Zygote以及System Server。

3. Zygote-Mode,Zygote启动完System Server后,进入Zygote Mode,在Socket 等候命令。随后,使用者将看到一个桌面环境(Home Screen)。桌面环境由一个名为Launcher的应用程序负责提供。

 

注:Zygote主要负责启动System server和执行android程序(APK)。成功启动System server后会使用socket方式监听(monitorandroid apps/prcesses)


查看init.rc文件显示,系统首先启动servicemanager,然后启动zygote:

service ueventd /sbin/ueventd    class core    criticalservice console /system/bin/sh    class core    console    disabled    user shell    group logservice adbd /sbin/adbd    class core    disabledservice servicemanager /system/bin/servicemanager    class core    user system    group system    critical    onrestart restart zygote    onrestart restart media    onrestart restart surfaceflinger    onrestart restart drmservice vold /system/bin/vold    class core    socket vold stream 0660 root mount    ioprio be 2service netd /system/bin/netd    class main    socket netd stream 0660 root system    socket dnsproxyd stream 0660 root inet    socket mdns stream 0660 root systemservice debuggerd /system/bin/debuggerd    class mainservice surfaceflinger /system/bin/surfaceflinger    class main    user system    group graphics    onrestart restart zygoteservice zygote /system/bin/app_process -Xzygote /system/bin --zygote --start-system-server    class main    socket zygote stream 660 root system    onrestart write /sys/android_power/request_state wake    onrestart write /sys/power/state on    onrestart restart media    onrestart restart netdservice drm /system/bin/drmserver    class main    user drm    group drm system inet drmrpc sdcard_rservice media /system/bin/mediaserver    class main    user media    group audio camera inet net_bt net_bt_admin net_bw_acct drmrpc system    ioprio rt 4service bootanim /system/bin/bootanimation    class main    user graphics    group graphics    disabled    oneshotservice dbus /system/bin/dbus-daemon --system --nofork    class main    socket dbus stream 660 bluetooth bluetooth    user bluetooth    group bluetooth net_bt_adminservice bluetoothd /system/bin/bluetoothd -n    class main    socket bluetooth stream 660 bluetooth bluetooth    socket dbus_bluetooth stream 660 bluetooth bluetooth    # init.rc does not yet support applying capabilities, so run as root and    # let bluetoothd drop uid to bluetooth with the right linux capabilities    group bluetooth net_bt_admin misc    disabledservice installd /system/bin/installd    class main    socket installd stream 600 system systemservice flash_recovery /system/etc/install-recovery.sh    class main    oneshotservice racoon /system/bin/racoon    class main    socket racoon stream 600 system system    # IKE uses UDP port 500. Racoon will setuid to vpn after binding the port.    group vpn net_admin inet    disabled    oneshotservice mtpd /system/bin/mtpd    class main    socket mtpd stream 600 system system    user vpn    group vpn net_admin inet net_raw    disabled    oneshotservice keystore /system/bin/keystore /data/misc/keystore    class main    user keystore    group keystore drmrpc    socket keystore stream 666service dumpstate /system/bin/dumpstate -s    class main    socket dumpstate stream 0660 shell log    disabled    oneshotservice sshd /system/bin/start-ssh    class main    disabledservice mdnsd /system/bin/mdnsd    class main    user mdnsr    group inet net_raw    socket mdnsd stream 0660 mdnsr inet    disabled    oneshotservice vtserver /system/bin/vtserver    user root    disabled    oneshot