Android 系統(tǒng)實(shí)現(xiàn)多種開機(jī)動(dòng)畫和logo切換功能
前言
基于mtk6580,添加多l(xiāng)ogo和開關(guān)機(jī)動(dòng)畫切換
描述
目前android開機(jī)畫面由三個(gè)部分(階段)組成,第一部分在bootloader啟動(dòng)時(shí)顯示(靜態(tài)),第二部分在啟動(dòng)kernel時(shí)顯示(靜態(tài)),第三部分在系統(tǒng)啟動(dòng)時(shí)(bootanimation)顯示(動(dòng)畫)。
添加資源
1.在device/tangxun/tx6580_weg_m/ProjectConfig.mk,找到BOOT_LOGO=這項(xiàng),記住這項(xiàng)內(nèi)容(如hd720,),在vendor/mediatek/proprietary/bootable/bootloader/lk/dev/logo/目錄下找到BOOT_LOGO=對(duì)應(yīng)的文件夾把你的圖片放進(jìn)去,圖片我是這樣命名的hd720_kernel_i7.bmp.(如果你只是替換的話更換hd720_kernel.bmp和hd720_uboot.bmp這兩張圖片即可,新圖片的名字需與舊圖片一致)
2.在vendor/mediatek/proprietary/bootable/bootloader/lk/dev/logo/rules.mk下修改RESOURCE_OBJ_LIST列表,如圖:

最后兩項(xiàng)就是我添加的
3.同目錄下update文件中添加

添加標(biāo)識(shí)區(qū)分不同logo
思路:首先我們添加的標(biāo)識(shí),不能被輕易清除,包括恢復(fù)出廠設(shè)置情況下。所以我選擇在protect_f分區(qū)下創(chuàng)建空文件的方式,在show logo的時(shí)候判斷相應(yīng)文件是否存在,來展示不同的logo和動(dòng)畫。
1.選擇一種要展示的logo和動(dòng)畫,在protect_f分區(qū)下創(chuàng)建.dat后綴的文件,刪除其他類型動(dòng)畫在protect_f分區(qū)下的相應(yīng)文件
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(){ //這是系統(tǒng)本來就有的
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()方法中添加切換動(dòng)畫
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) {總結(jié)
以上所述是小編給大家介紹的Andorid 系統(tǒng)實(shí)現(xiàn)多種開機(jī)動(dòng)畫和logo切換功能,希望對(duì)大家有所幫助,如果大家有任何疑問請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!
相關(guān)文章
Android實(shí)現(xiàn)Neumorphism?UI控件
大家好,本篇文章主要講的是Android實(shí)現(xiàn)Neumorphism?UI控件,感興趣的同學(xué)趕快來看一看吧,對(duì)你有幫助的話記得收藏一下2022-02-02
Android手動(dòng)檢查并申請(qǐng)權(quán)限方法
今天小編就為大家分享一篇Android手動(dòng)檢查并申請(qǐng)權(quán)限方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2018-07-07
Android基礎(chǔ)之使用Fragment控制切換多個(gè)頁面
Android官方已經(jīng)提供了Fragment的各種使用的Demo例子,在我們SDK下面的API Demo里面就包含了Fragment的各種使用例子,需要看Demo的朋友,直接看API Demo那個(gè)程序就可以了,不用到處去找。里面分開不同功能,實(shí)現(xiàn)了不同的類2013-07-07
Android開發(fā)中Intent傳遞對(duì)象的方法分析
這篇文章主要介紹了Android開發(fā)中Intent傳遞對(duì)象的方法,結(jié)合實(shí)例分析了Intent傳遞對(duì)象所涉及的具體方法、實(shí)現(xiàn)步驟與相關(guān)注意事項(xiàng),需要的朋友可以參考下2016-02-02
Android ExpandableListView實(shí)現(xiàn)下拉刷新和加載更多效果
這篇文章主要為大家詳細(xì)介紹了Android ExpandableListView實(shí)現(xiàn)下拉刷新和加載更多效果,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-06-06
Android開發(fā)實(shí)現(xiàn)跟隨手指的小球效果示例
這篇文章主要介紹了Android開發(fā)實(shí)現(xiàn)跟隨手指的小球效果,涉及Android圖形繪制、事件響應(yīng)、界面布局等相關(guān)操作技巧,需要的朋友可以參考下2019-04-04

