当前位置: 移动技术网 > 移动技术>移动开发>Android > Andorid 系统实现多种开机动画和logo切换功能

Andorid 系统实现多种开机动画和logo切换功能

2019年07月31日  | 移动技术网移动技术  | 我要评论

前言

基于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();
    }
   }
  }
 }

2.在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");
  }
 }
}

3.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) {

总结

以上所述是小编给大家介绍的andorid 系统实现多种开机动画和logo切换功能,希望对大家有所帮助

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网