Android13制作开机动画

默认设置下,Android13会加载

/frameworks/base/data/sounds/AllAudio.mk

下指定的开机动画bootanimation.zip

开机动画的加载代码在

/home/pcserver/gitos/android13-ruixin/frameworks/base/cmds/bootanimation/BootAnimation.cpp

参考代码加载路径

static const char OEM_BOOTANIMATION_FILE[] = "/oem/media/bootanimation.zip";
static const char PRODUCT_BOOTANIMATION_DARK_FILE[] = "/product/media/bootanimation-dark.zip";
static const char PRODUCT_BOOTANIMATION_FILE[] = "/product/media/bootanimation.zip";
static const char SYSTEM_BOOTANIMATION_FILE[] = "/system/media/bootanimation.zip";
..................................
static const std::vector bootFiles = {
   APEX_BOOTANIMATION_FILE, playDarkAnim ? PRODUCT_BOOTANIMATION_DARK_FILE : PRODUCT_BOOTANIMATION_FILE, OEM_BOOTANIMATION_FILE, SYSTEM_BOOTANIMATION_FILE
};

系统会查找相关目录下的zip文件进行加载,参考AllAudio.mk,直接把bootanimation.zip放到/frameworks/base/data/sounds/目录即可。

制作过程有些麻烦,参考

/frameworks/base/cmds/bootanimation/FORMAT.md

bootanimation.zip由两部分组成

desc.txt - a text file
    part0  \
    part1   \  directories full of PNG frames
    ...     /
    partN  /

desc.txt定义开机动画参数,比如:

1080 2160 10

p 1 0 part1

p 0 0 part2
描述的是开机动画宽1080,高2160,每帧动画10秒

p后面带的参数包含播放方式,对应目录,参考FORMAT.md


    TYPE COUNT PAUSE PATH [FADE [#RGBHEX [CLOCK1 [CLOCK2]]]]

  * **TYPE:** a single char indicating what type of animation segment this is:
      + `p` -- this part will play unless interrupted by the end of the boot
      + `c` -- this part will play to completion, no matter what
      + `f` -- same as `p` but in addition the specified number of frames is being faded out while
        continue playing. Only the first interrupted `f` part is faded out, other subsequent `f`
        parts are skipped

制作过程要注意的是,要按FORMAT.md来

1、图片要经过zopflipng压缩,参考

### PNG compression

Use `zopflipng` if you have it, otherwise `pngcrush` will do. e.g.:

    for fn in *.png ; do
        zopflipng -m ${fn}s ${fn}s.new && mv -f ${fn}s.new ${fn}
        # or: pngcrush -q ....
    done

2、图片要转为256色,参考

Some animations benefit from being reduced to 256 colors:

    pngquant --force --ext .png *.png
    # alternatively: mogrify -colors 256 anim-tmp/*/*.png

3、最后一步压缩为zip文件

### creating the ZIP archive

    cd 
    zip -0qry -i \*.txt \*.png \*.wav @ ../bootanimation.zip *.txt part*

开始制作开机动画的时候,没有做步骤1,2,结果动画无法显示,失败,还是要好好看下文档。

你可能感兴趣的:(Android,Framework)