Android 開機會出現3個畫面:
1. Linux 系統啟動,出現Linux小企鵝畫面(reboot)(Android 1.5及以上版本已經取消載入圖片);
2. Android平臺啟動初始化,出現"A N D R I O D"文字字樣畫面;
3. Android平臺圖形系統啟動,出現含閃動的ANDROID字樣的動畫圖片(start)。

 

1、開機圖片(Linux小企鵝) (Android 1.5及以上版本已經取消載入圖片);
Linux Kernel引導啟動後,載入該圖片。
logo.c中定義nologo,在fb_find_logo(int depth)函數中根據nologo的值判斷是否需要載入相應圖片。
代碼如下:
static int nologo;
module_param(nologo, bool, 0);
MODULE_PARM_DESC(nologo, "Disables startup logo");
/* logo's are marked __initdata. Use __init_refok to tell
* modpost that it is intended that this function uses data
* marked __initdata.
*/
const struct linux_logo * __init_refok fb_find_logo(int depth)
{
const struct linux_logo *logo = NULL;
if (nologo)
return NULL;
......
}
相關代碼:
/kernel/drivers/video/fbmem.c
/kernel/drivers/video/logo/logo.c
/kernel/drivers/video/logo/Kconfig
/kernel/include/linux/linux_logo.h

 

2、開機文字("A N D R I O D")
Android 系統啟動後,init.c中main()調用load_565rle_image()函數讀取/initlogo.rle(一張565 rle壓縮的點陣圖),如果讀取成功,則在/dev/graphics/fb0顯示Logo圖片;如果讀取失敗,則將/dev/tty0設為TEXT模式,並打開/dev/tty0,輸出文本“A N D R I O D”字樣。
定義載入圖片檔案名稱
#define INIT_IMAGE_FILE "/initlogo.rle"
int load_565rle_image( char *file_name );
#endif
init.c中main()載入/initlogo.rle檔。




 

if( load_565rle_image(INIT_IMAGE_FILE) ) {//載入initlogo.rle檔 fd = open("/dev/tty0", O_WRONLY);//將/dev/tty0設為text模式 if (fd >= 0) { const char *msg; msg = "\n" "\n" "\n" "\n" "\n" "\n" "\n" // console is 40 cols x 30 lines "\n" "\n" "\n" "\n" "\n" "\n" "\n" " A N D R O I D "; write(fd, msg, strlen(msg)); close(fd); } }相關代碼: /system/core/init/init.c /system/core/init/init.h /system/core/init/init.rc /system/core/init/logo.c *.rle檔的製作步驟: a. 使用GIMP或者Advanced Batch Converter軟體,將圖像轉換為RAW格式; b. 使用android自帶的rgb2565工具,將RAW格式檔轉換為RLE格式(如:rgb2565 -rle < initlogo.raw > initlogo.rle)。

 

3、開機動畫(閃動的ANDROID字樣的動畫圖片)
Android 1.5版本:Android的系統登錄動畫類似于Windows系統的捲軸,是由前景和背景兩張PNG圖片組成,這兩張圖片存在於手機或模擬器/system/framework/framework-res.apk檔當中,對應原檔位於/frameworks/base/core/res/assets/images/。前景圖片(android-logo-mask.png)上的Android文字部分鏤空,背景圖片(android-logo-shine.png)則是簡單的紋理。系統登錄時,前景圖片在最上層顯示,程式碼(BootAnimation.android())控制背景圖片連續滾動,透過前景圖片文字鏤空部分滾動顯示背景紋理,從而實現動畫效果。
相關代碼:
/frameworks/base/libs/surfaceflinger/BootAnimation.h
/frameworks/base/libs/surfaceflinger/BootAnimation.cpp
/frameworks/base/core/res/assets/images/android-logo-mask.png Android預設的前景圖片,文字部分鏤空,大小256×64
/frameworks/base/core/res/assets/images/android-logo-shine.png Android預設的背景圖片,有動感效果,大小512×64

 

Android 1.6及以上版本:
init.c解析init.rc(其中定義服務:“service bootanim /system/bin/bootanimation”),bootanim服務由SurfaceFlinger.readyToRun()(property_set("ctl.start", "bootanim");)執行開機動畫、bootFinished()(property_set("ctl.stop", "bootanim");)執行停止開機動畫。
BootAnimation.h和BootAnimation.cpp檔放到了/frameworks/base/cmds/bootanimation目錄下了,增加了一個入口檔bootanimation_main.cpp。Android.mk檔中可以看到,將開機動畫從原來的SurfaceFlinger裡提取出來了,生成可執行檔:bootanimation。Android.mk代碼如下:
//=============Android.mk======================
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES:= \
bootanimation_main.cpp \
BootAnimation.cpp
# need "-lrt" on Linux simulator to pick up clock_gettime
ifeq ($(TARGET_SIMULATOR),true)
ifeq ($(HOST_OS),linux)
LOCAL_LDLIBS += -lrt
endif
endif
LOCAL_SHARED_LIBRARIES := \
libcutils \
libutils \
libui \
libcorecg \
libsgl \
libEGL \
libGLESv1_CM \
libmedia
LOCAL_C_INCLUDES := \
$(call include-path-for, corecg graphics)
LOCAL_MODULE:= bootanimation
include $(BUILD_EXECUTABLE)
//==========================================
(1)adb shell後,可以直接運行“bootanimation”來重新看開機動畫,它會一直處於動畫狀態,而不會停止。
(2)adb shell後,命令“setprop ctl.start bootanim”執行開機動畫;命令“getprop ctl.start bootanim”停止開機動畫。這兩句命令分別對應SurfaceFlinger.cpp的兩句語句:property_set("ctl.start", "bootanim");和property_set("ctl.stop", "bootanim");
相關檔:
/frameworks/base/cmds/bootanimation/BootAnimation.h
/frameworks/base/cmds/bootanimation/BootAnimation.cpp
/frameworks/base/cmds/bootanimation/bootanimation_main.cpp
/system/core/init/init.c
/system/core/rootdir/init.rc
參考文檔:
圖說Android開機畫面和開機動畫
http://www.shudoo.com/09/1030/15/13418431.html
initlogo.rle: display an image on boot
http://forum.xda-developers.com/showthread.php?t=443431

 

分析Android 根檔案系統啟動過程(init守護進程分析)
http://crazier9527.javaeye.com/blog/454635
arrow
arrow
    全站熱搜

    戮克 發表在 痞客邦 留言(0) 人氣()