Android开机画面显示过程分析 - muyu01248/log GitHub Wiki
Android开机画面显示过程分析[http://blog.csdn.net/luoshengyang/article/details/7691321]
- 第一个开机画面的显示过程(加载内核) 编译选项 CONFIG_FRAMEBUFFER_CONSOLE Device Driver-> Graphic Support-> Console Display Driver Support-> Framebuffer Console Support CONFIG_LOGO Device Driver-> Graphic Support-> Bootup logo
drivers/video/fbmem.c
fbmem_init()
proc_create("fb",...) /proc/fb
register_chrdev("fb")
create_class(,"graphics") /sys/class/graphics
EXPORT_SYMBOL("register_framebuffer") registered_fb fb_info FB_MAJOR(29); 从设备号:0,1,2; /dev/grapic/fb0,fb1,fb2 fb_notifier_call_chain -> 帧缓冲区控制台 /drivers/video/console/fbcon.c
devices/video/fbmem/fbcon.c fb_console_init() create_device()[fb_class:类别为graphic,"fb_con":设备名] fb_register_client(&fbcon_event_notifier)[fb_register_notifier.notfy_call ->fbcon_event_notify():帧缓冲区硬件注册时通知控制台]
fbcon_event_notify() fbcon_fb_registered() fb_select_primary() [COFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY] info_idx con2fb_map_boot[], con2fb_map[] fist_fb_vc, last_fb_vc set_con2fb_map() fbcon_take_over() logo_show: FBCON_LOGO_CANSHOW, FBCON_LOGO_DONTSHOW fbcon_takeover()[注册回调,consw fb_con] fb_con.fbcon_init(),fbcon_switch() fbcon_init() fbcon_prepare_logo() fb_prepare_logo() fb_find_logo() /drivers/logo/ppm pdm fbcon_switch() fb_show_logo()
- 第二个开机画面的显示过程 init进程实现文件:system/core/init/init.c main(argv[0])[argv[0]:进程名,'ueventd',ueventd_main()] ueventd[符号链接文件] 解析启动脚本/init.rc
ueventd进程,处理uevent时间,即管理系统设备,/system/core/init/ueventd.c ueventd进程, socket接口来和内核通信,以便可以监控系统设备事件. 驱动.device_create("hello") -> (ueventd).socket -> ueventd.ueventd_main() -> /dev/hello
init.c.main() -> queue_builtin_action(console_init_action, "console_init") console_init_action() -> 显示开机画面
queue_builtin_action() [system/core/init/init_parser.c] action_list[ init.rc->action,内建的action ] action_queue[ action_list, console_init_action ]
init.c.main() [A]execute_one_command() action_queue[] -> console_init_action() -> 显示开机画面
[B]restart_process()[/init.rc 重新启动进程]
[C]property_set() -> socket(get_property_set_fd()) -> init.c -> handle_property_set_fd()
第三个开机画面,SurfaceFliper服务通过设置ctl.start ctl.stop属性值启动和停止第三个开机画面
[D]chorded keyboard, 不同的铵键组合来描述不同的命令
/dev/keychord[设备文件]
get_keychord_fd[设备文件描述符]
handle_keychord[事件处理]
[E]回收僵尸进程 SIGCHLD信号接收器, get_signal_fd() -> socket -> SIGCHLD信号 -> handle_signal()
console_init_action() /proc/cmdline[内核启动参数] "androidboot.console" /dev/ /dev/console load_565rle_image()[system/core/init/init.h [#define INIT_IMAGE_FILE "/initlogo.rle" ]] vt_set_mode(1) open()[initlogo.lre] fb_open() -> dev/graphics/fb0,(fb_fix_screeninfo)FBIOGET_FSCREENINFO和FBIOGET_VSCREENINFO(fb_var_screeninfo)
#define fb_width(fb) ((fb)->vi.xres)
#define fb_height(fb) ((fb)->vi.yres)
mmap(initlog.lre)
lre格式:4字节,2字节长度,2字节颜色
android_memset16
- 第三个开机画面的显示过程 SurfaceFlinger::onFirstRef() run() mReadyToRunBarrier()
SurfaceFlinger::readyToRun() property_set("ctl.start", "bootanim");
init进程::void handle_property_set_fd()
prop_msg, name, value
check_control_perms,check_perms
handle_control_message
msg_star
bootanim
service_find_by_name
service_start
BootAnimation::main()[frameworks/base/cmds/bootanimation/bootanimation_main.c] sp boot = new BootAnimation(); BootAnimation.onFirstRef()frameworks/base/cmds/bootanimation/BootAnimation.cpp mSession->linkToComposerDeath(this)[mSession::SurfaceComposerClient,SurfaceFlinger,Binder进程间通信的] [SurfaceComposerClient - ISurfaceComposerClient -> mClient - SurfaceFlinger]
BootAnimation.readyToRun()
sp<SurfaceControl> control = session()->createSurface()[SurfaceComposer-IserfaceComposer-mClient->SurfaceFlinger <= SurfaceLayer]
sp<Surface> s = control->getSurface();[s.mSurface:SurfaceLayer][Surface-ANativeWindow]
[SurfaceLayer - Surface - ANativeWindow - Android窗口系统] - EGL - OpenGL
[EGLDisplay对象display
EGLConfig
EGLSurface
EGLContext]
EGLSurface - Surface
android()/movie()
initTexture
ndroid-logo-mask.png
android-logo-shine.png
mZip ->bootanimation.zip
[desc.txt
600 480 24
p 1 0 part1
p 0 10 part2]
[png - nimation::Frame]
Region对象clearReg()
glGenTextures()
Animation::Frame对象的成员变量tid
glBindTexture
glDrawTexiOES()和eglSwapBuffers()