前言
基于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切換功能,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對VEVB武林網網站的支持!
新聞熱點
疑難解答