Android系統開機畫面修改

來源:互聯網
上載者:User

Android系統開機畫面分為下面三個階段:

      1、開機圖片:Android核心是基於標準核心的,對linux比較熟悉,特別是在開發板上移植過Linux系統的人就知道在核心引導過程中會顯示出一個小企鵝的圖片,這就是第一階段的開機圖片,相信大家知道怎麼去修改它。Android1.5及其以上版本都取消了這個圖片的顯示,具體的看核心相關代碼就知道了;

      2、開機文字:Android系統開機會出現“A N D R O I D”這行字,相信大家都不陌生,那麼這個怎麼修改呢?相關檔案在Android系統源碼(不是Android核心源碼)system/core/init/init.c,如下程式碼片段:


[cpp] if( load_565rle_image(INIT_IMAGE_FILE) ) { 
     fd = open("/dev/tty0", O_WRONLY); 
     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); 
     } 
 } 
   if( load_565rle_image(INIT_IMAGE_FILE) ) {
        fd = open("/dev/tty0", O_WRONLY);
        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);
        }
    }         到這裡大家就知道怎麼修改了吧。但是這裡要提到的一點就是,上面的程式碼片段有一個if語句,就是先檢測在檔案系統根目錄下是否存在要實現的開機動畫,如果不存在的話,那麼就顯示這個文本資訊代替,所以,這個階段是可以實現圖片的顯示的,而且圖片的格式是.rle格式的。如果不存在就顯示文本,所以你可以選擇系那是自己的文字,也就是修改“A N D R O I D”字樣啊。也可以選擇顯示圖片,但是要自己在檔案系統的根目錄下提供提片,具體的圖片的名字在init.h檔案中定義:


[cpp] <span style="font-size:16px;">#define INIT_IMAGE_FILE "/initlogo.rle" 
 
int load_565rle_image( char *file_name );</span> 
<span style="font-size:16px;">#define INIT_IMAGE_FILE "/initlogo.rle"

int load_565rle_image( char *file_name );</span>           看到上面的宏定義大家就懂了吧,至於怎麼製作rle格式的,這個使用一些軟體就好。www.2cto.com

         3、開機動畫:這個階段就是大家能看到的系統啟動過程中,顯示完"A N D R O I D"字樣後顯示的圖片,類似進度條一樣,圖片內容也是“A N D R O I D”字樣。這裡怎麼修改呢?

            其實這個部分的動畫是使用兩個圖片顯示出來的,具體的圖片檔案所在路徑為:frameworks/base/core/res/assets/images,大家看一下就知道了,也就知道怎麼修改了。但是還沒完。

            和這部分相關的源碼檔案主要是如下幾個:frameworks/base/cmds/bootanimation下面的幾個檔案就是的了,可以看看BootAnimation.cpp檔案的內容,有如下程式碼片段:


[java] <span style="font-size:16px;">bool BootAnimation::android() 

    initTexture(&mAndroid[0], mAssets, "images/android-logo-mask.png"); 
    initTexture(&mAndroid[1], mAssets, "images/android-logo-shine.png");</span> 
<span style="font-size:16px;">bool BootAnimation::android()
{
    initTexture(&mAndroid[0], mAssets, "images/android-logo-mask.png");
    initTexture(&mAndroid[1], mAssets, "images/android-logo-shine.png");</span>           這就是設定顯示的前景圖片和背景圖片。

           接著看還有如下代碼:


[cpp] <span style="font-size:16px;">#define USER_BOOTANIMATION_FILE "/data/local/bootanimation.zip" 
#define SYSTEM_BOOTANIMATION_FILE "/system/media/bootanimation.zip"  
#define SYSTEM_ENCRYPTED_BOOTANIMATION_FILE "/system/media/bootanimation-encrypted.zip"</span> 
<span style="font-size:16px;">#define USER_BOOTANIMATION_FILE "/data/local/bootanimation.zip"
#define SYSTEM_BOOTANIMATION_FILE "/system/media/bootanimation.zip"
#define SYSTEM_ENCRYPTED_BOOTANIMATION_FILE "/system/media/bootanimation-encrypted.zip"</span>          看宏名相信大家就知道了,這就是設定動畫檔案的名稱了。為什麼會又顯示圖片又設定動畫顯示呢,這個Android版本有關。顯示兩個圖片:前景和背景圖片是在1.5版本用,後來就改為了設定動畫檔案,就是:bootanimation.zip,是zip格式的,這個檔案包含三個內容:兩個目錄:part0和part1,一個檔案desc.txt。

兩個目錄用來包含要顯示的圖片,分為第一階段和第二階段。剩下的檔案就是設定關於如何顯示的資訊:

樣本如下:

480 800 15
    p 1 0 part0
    p 0 0 part1


具體的含義如下:

 480--width of the image, 800--height of the image, 15--frames of second
  p 1, display one time
  p 0, display recycling till handset power on finished,相信大家懂了!呵呵。


         你可以製作自己的bootanimation.zip檔案放置在合適的目錄下,這樣可以代替預設的開機介面:這裡說的合適的目錄就是上面的宏定義,大家都懂^_^!

        怎麼製作bootanimation.zip檔案呢?和上面一樣建立兩個目錄和一個檔案,然後使用軟體或者是命令列大包即可

         zip -r -0 bootanimation.zip part0 part1 desc.txt


       至此,自訂開機畫面就完成了!

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.