andorid 系统实现多种开机动画和logo切换

前言

基于mtk6580,添加多logo和开关机动画切换

描述

目前android开机画面由三个部分(阶段)组成,第一部分在bootloader启动时显示(静态),第二部分在启动kernel时显示(静态),第三部分在系统启动时(bootanimation)显示(动画)。

添加资源

  1. 在device/tangxun/tx6580_weg_m/ProjectConfig.mk,找到BOOT_LOGO=这项,记住这项内容(如hd720,),在vendor/mediatek/proprietary/bootable/bootloader/lk/dev/logo/目录下找到BOOT_LOGO=对应的文件夹把你的图片放进去,图片我是这样命名的hd720_kernel_i7.bmp.(如果你只是替换的话更换hd720_kernel.bmp和hd720_uboot.bmp这两张图片即可,新图片的名字需与旧图片一致)
  2. 在vendor/mediatek/proprietary/bootable/bootloader/lk/dev/logo/rules.mk下修改RESOURCE_OBJ_LIST列表,如图:
    在这里插入图片描述
    最后两项就是我添加的
  3. 同目录下update文件中添加
    在这里插入图片描述

添加标识区分不同logo

思路:首先我们添加的标识,不能被轻易清除,包括恢复出厂设置情况下。所以我选择在protect_f分区下创建空文件的方式,在show logo的时候判断相应文件是否存在,来展示不同的logo和动画。

  1. 选择一种要展示的logo和动画,在protect_f分区下创建.dat后缀的文件,删除其他类型动画在protect_f分区下的相应文件
private void createOrDeleteFile(String str){
        String sDir = "/protect_f";
        File fDir = new File(sDir);
        if (fDir.exists()){
            try {
                Runtime.getRuntime().exec("chmod 777"+sDir);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        File mFile = new File(sDir,File_moto_logo);
        if (mFile.exists()){
            mFile.delete();
        }

        mFile = new File(sDir,File_samsun_logo);
        if (mFile.exists()){
            mFile.delete();
        }
	 mFile = new File(sDir,"sysBoot_logo_null.dat");
        if (mFile.exists()){
            mFile.delete();
        }

        if (str != null){
            mFile = new File(sDir,str);
            if (!mFile.exists()){
                try {
                    mFile.createNewFile();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
  1. 在vendor/mediatek/proprietary/external/libshowlogo/charging_animation.cpp文件中,添加logo切换
const char LOGO_ON5_ANI[] = "/protect_f/sysBoot_logo_moto.dat";
const char LOGO_I7_ANI[] = "/protect_f/sysBoot_logo_samsun.dat";
/*
 * Show kernel logo when phone boot up
 *
 */
void show_kernel_logo(){     //这是系统本来就有的
	 SLOGD("[libshowlogo: %s %d]show kernel logo, index = 38 \n",__FUNCTION__,__LINE__);
    if (error_flag == 0) {
        if(open(LOGO_ON5_ANI,O_RDONLY) >= 0){
            anim_show_logo(kernel_logo_position+1);
            property_set("ani_type","custom");
            property_set("animation_num","On5_Ani");
        }else if (open(LOGO_I7_ANI,O_RDONLY) >= 0) {
            anim_show_logo(kernel_logo_position+2);
            property_set("ani_type","custom");
            property_set("animation_num","I7_Ani");
        }else{
            anim_show_logo(kernel_logo_position);
            property_set("ani_type","android");
            property_set("animtion_num","android");
        }
    }
}
  1. framworks/base/cmds/bootanimation/BootAnimation.cpp文件中,在void BootAnimation::initBootanimationZip()方法中添加切换动画
    char anitype[PROPERTY_VALUE_MAX];
    char aninum[PROPERTY_VALUE_MAX];
    property_get("ani_type",anitype,"");
    property_get("animation_num",aninum,"");
    if (strcmp("custom",anitype) == 0) {
        if (strcmp("On5_Ani", aninum)==0) {
            if (access("/system/media/bootanimation_custom.zip", R_OK) == 0) {
                if ((zipFile = ZipFileRO::open("/system/media/bootanimation_custom.zip")) != NULL) {
                    mZip = zipFile;
                }
            }
        }else if (strcmp("I7_Ani", aninum)==0){
            if (access("/system/media/bootanimation_s6.zip", R_OK) == 0) {
                if ((zipFile = ZipFileRO::open("/system/media/bootanimation_s6.zip")) != NULL) {
                    mZip = zipFile;
                }
            }
        }
    }
    if (zipFile == NULL) {

到这里功能基本就可以实现了。

开关机动画和铃声修改可以参考我的另一篇文章 链接

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值