Android startup Screen

Source: Internet
Author: User

Android has three boot screens

1. The logo in the kernel framebuffer driver. For details, see kernel/Drivers/Video/fbmem. C. This is the earliest static startup screen.

2. Start Screen of INIT process loading. For details, refer to load_565rle_image implementation in Android/system/CORE/init. C.

3. bootanimation animation. In general, init. RC contains the following section:

Service bootanim/system/bin/bootanimation
User graphics
Group graphics
Disabled
Oneshot

For the implementation of bootanimation, see the frameworks/base/cmds/bootanimation/directory. This process displays an animation.

The second boot screen is described here.

1 load_565rle_image source code

105 int load_565rle_image(char *fn)106 {107     struct FB fb;108     struct stat s;109     unsigned short *data, *bits, *ptr;110     unsigned count, max;111     int fd;112113     if (vt_set_mode(1))114         return -1;115116     fd = open(fn, O_RDONLY);117     if (fd < 0) {118         ERROR("cannot open '%s'\n", fn);119         goto fail_restore_text;120     }121122     if (fstat(fd, &s) < 0) {123         goto fail_close_file;124     }125126     data = mmap(0, s.st_size, PROT_READ, MAP_SHARED, fd, 0);127     if (data == MAP_FAILED)128         goto fail_close_file;129130     if (fb_open(&fb))131         goto fail_unmap_data;132133     max = fb_width(&fb) * fb_height(&fb);134     ptr = data;135     count = s.st_size;136     bits = fb.bits;137     while (count > 3) {138         unsigned n = ptr[0];139         if (n > max)140             break;141         android_memset16(bits, ptr[1], n << 1);142         bits += n;143         max -= n;144         ptr += 2;145         count -= 4;146     }147148     munmap(data, s.st_size);149     fb_update(&fb);150     fb_close(&fb);151     close(fd);152     unlink(fn);153     return 0;154155 fail_unmap_data:156     munmap(data, s.st_size);157 fail_close_file:158     close(fd);159 fail_restore_text:160     vt_set_mode(0);161     return -1;162 }163 

2 RLE image file format

The input parameter of the load_565rle_image function is an RLE file, which converts the file content to rgb565 and writes it to framebuffer.

The following Baidu encyclopedia to RLE introduction http://baike.baidu.com/view/18819.htm? Fromtaglist

--------------------

Run-length encoding (RLE), translated into travel code, and translated into travel Length Code, also known as run coding ), in the control theory, binary images are encoded using different code words for continuous black and white serial numbers. Travel encoding is a simple non-destructive data compression method. Its advantage is that it can be compressed and decompressed quickly. The method is to compress the continuous data length.

-------------------

The RLE file is in the format of [count (2 bytes), color (2 bytes)], and the maximum value of count is 65535. The color is rgb565, or yuv422, I think it is okay if it is less than 2 bytes, but since rgb565 is written into the framebuffer, the color value of the RLE file is rgb565 from the efficiency point of view.

3 Write to framebuffer

Row 141st of load_565rel_image source code: writes n pixels and the color value of the pixel is the original data in RLE. This is no problem for the framebuffer of rgb565, but if framebuffer is rgb32 (argb ), you cannot work. The solution is to convert 2bytes rgb565 to 4 bytes argb.

Code on

#define rgb32_r(rle) (((rle & 0xf800) >> 11) << 3)#define rgb32_g(rle) (((rle & 0x07e0) >> 5 << 2))#define rgb32_b(rle) (((rle & 0x001f) << 3))#define rgb32(rle) (rgb32_r(rle) << 16 | rgb32_g(rle) << 8 | rgb32_b(rle) << 0)         unsigned int *bits;        bits = (unsigned int *)fb.bits;        while (count > 3) {            unsigned n = ptr[0];            if (n > max)                break;            out = rgb32(ptr[1]);            android_memset32(bits, out, n << 2);            bits += n;            max -= n;            ptr += 2;            count -= 4;

4. Now let's go back and see how to get the RLE format file. Generally, we can convert the original image into rgb565 and then convert rgb565 into RLE (of course not necessary, if there is a tool that can convert PNG directly into RLE ).

A) Generate a 800x480 PNG file with gmip. The image size must be the same as the screen size. It doesn't matter if it is PNG. You only need tools to convert it to rgb565.

B) The convert command PNG is rgb565: Convert-depth 8 android_logo.png RGB: android_logo.raw

C) convert rgb565 to RLE file: rgb2565-RLE <android_logo.raw> initlogo. RLE

5. Replace initlogo. RLE in ramdisk and restart to view the new startup screen.

Note that the load_565rle_image line 152 unlink (FN) will delete the initlogo. RLE file. after entering the system, you will find/initlogo. the RLE file has been deleted, which saves a little memory space in the ramdisk file system,

There is no problem with rootfs for ramdisk because the ramdisk image is not modified.

However, if the root file system is another file system, unlink (FN) needs to be commented out to prevent initlog. RLE from being permanently deleted.

Android/system/CORE/init/logo. C is not very scalable. The Code assumes that framebuffer is rgb565. In fact, I have access to other formats of FB, such as yuyv and argb. If this happens, I need to modify the file code.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.