Make your own Android boot animation

Table of Contents

    1. What is boot animation
    1. How is the animation started
    1. How to customize boot animation
    1. Try it out

1. What is boot animation

2. How is the animation started

It’s started as an init service during boot up stage
The starter file is /system/etc/init/bootanim.rc

service bootanim /system/bin/bootanimation
class core animation
user graphics
group graphics audio
disabled
oneshot
writepid /dev/stune/top-app/tasks

‘bootanimation’ application will search for animation resources in specified order,

/product/media/bootanimation.zip
/oem/media/bootanimation.zip
/system/media/bootanimation.zip

the final choice is first match.

3. How to customize boot animation

Files in bootanimation.zip

Prerequisite
A series of animated ‘png’ files

3.1 descriptor file

Descriptor file - desc.txt

800 1280 24 --> header part
p 1 0 Part0 --> body part
p 2 0 Part1 --> body part

header part

800 1280  24
| | +---- FPS
| +--------- Height
+------------- Width

body part

p   1   0   Part0
p 2 0 Part1
| | | |
| | | +------ directory name for png files
| | +------------ number of FRAMES to delay after this part
| +---------------- iterations to play, 0 for infinite loop
+-------------------- TYPE

TYPE values:

  • ‘p’: this part will play unless interrupted by the end of the boot
  • ‘c’: this part will play to completion, no matter what

Notes about descriptor file

  • Only 1 line in boby part of desc.txt can be marked as infinite loop.
  • desc.txt should be in Linux text format, otherwise it may confuse the parser.

3.2 animation contents

Animation stages are ogranized as directories.
Each diredctory matches one line in desc.txt detail part.

Part 0 \
Part 1 \
Part 2 >-- directories full of PNG frames
... /
Part N /

Then PNG files are played alphabetically.

3.3 pack everything

Finally we should pack the descriptor and PNG files into bootanimation.zip
compression method is ‘STORE’, which means no compression.
Other compression methods include DEFLATE, BZIP2, LZMA etc, but they are NOT suitable for bootanimation.
Command:

zip ../bootanimation.zip * -0 -r

4. Try it out!

Push the generated file to the platform:

adb push bootanimation.zip /system/media/bootanimation.zip

Now let’s have a look at what we have achieved:

Enjoy!