google 默认开机动画代码在framework/base/cmds/bootanimation
MTK 开机动画代码在vendor/mediatek/proprietary/operator/framework/bootanimation/MtkBootanimation
一、启用 MtkBootanimation,编译 libmtkbootanimation
关闭 bootanimation,打开 mtkbootanimation
deleted: frameworks/base/cmds/bootanimation/Android.bp add frameworks/base/cmds/bootanimation/Android.bp_disable deleted: vendor/mediatek/proprietary/operator/frameworks/bootanimation/Android_disable.mk add vendor/mediatek/proprietary/operator/frameworks/bootanimation/Android.mk deleted: vendor/mediatek/proprietary/operator/frameworks/bootanimation/MtkBootanimation/Android_disable.mk add vendor/mediatek/proprietary/operator/frameworks/bootanimation/MtkBootanimation/Android.mk
配置编译 libmtkbootanimation
device/mediatek/$(platform_name)/device.mk
+++ b/alps/device/mediatek/mt6765/device.mk @@ -62,6 +62,8 @@ endif endif endif +PRODUCT_PACKAGES += mtkbootanimation +PRODUCT_PACKAGES += libmtkbootanimation #GPU collection PRODUCT_PACKAGES += libI420colorconvert
二、修改 MtkBootanimation mk 文件
vendor/mediatek/proprietary/operator/frameworks/bootanimation/Android.mk
修改 cxp_support := yes,通过打印 MSSI_MTK_CARRIEREXPRESS_PACK 不存在,
默认 cxp_support 为 no,所以不编译 MtkBootanimation/Android.mk
vendor/mediatek/proprietary/operator/frameworks/bootanimation/MtkBootanimation/Android.mk
增加 include $(BUILD_EXECUTABLE) 结尾,增加 include $(BUILD_SHARED_LIBRARY) 结尾,lib 配置中
增加
LOCAL_CFLAGS += -DMTK_TER_SERVICE
LOCAL_CPPFLAGS += -DMTK_TER_SERVICE
LOCAL_SHARED_LIBRARIES += libterservice
LOCAL_C_INCLUDES += $(MTK_PATH_SOURCE)/hardware/terservice/include/
LOCAL_INIT_RC := mtkbootanim.rc ifdef TARGET_32_BIT_SURFACEFLINGER LOCAL_32_BIT_ONLY := true endif include $(BUILD_EXECUTABLE) # ifeq (OP01,$(word 1,$(subst _, ,$(OPTR_SPEC_SEG_DEF)))) # ifeq ($(strip $(MTK_BSP_PACKAGE)), yes) # include $(BUILD_EXECUTABLE) # endif # else ifeq (OP02,$(word 1,$(subst _, ,$(OPTR_SPEC_SEG_DEF)))) # ifeq ($(strip $(MTK_BSP_PACKAGE)), yes) # include $(BUILD_EXECUTABLE) # endif # else ifeq (OP09,$(word 1,$(subst _, ,$(OPTR_SPEC_SEG_DEF)))) # ifeq ($(strip $(MTK_BSP_PACKAGE)), yes) # include $(BUILD_EXECUTABLE) # endif # endif # libbootanimation # =========================================================== include $(CLEAR_VARS) LOCAL_MODULE := libmtkbootanimation LOCAL_CFLAGS += ${bootanimation_CommonCFlags} LOCAL_SRC_FILES:= \ BootAnimation.cpp LOCAL_CFLAGS += -DMTK_TER_SERVICE LOCAL_CPPFLAGS += -DMTK_TER_SERVICE ....... LOCAL_SHARED_LIBRARIES += libterservice LOCAL_C_INCLUDES += $(MTK_PATH_SOURCE)/hardware/terservice/include/ LOCAL_C_INCLUDES += $(TOP)/$(MTK_ROOT)/frameworks-ext/native/include LOCAL_C_INCLUDES += external/skia/include ifdef TARGET_32_BIT_SURFACEFLINGER LOCAL_32_BIT_ONLY := true endif include $(BUILD_SHARED_LIBRARY) # ifeq (OP01,$(word 1,$(subst _, ,$(OPTR_SPEC_SEG_DEF)))) # ifeq ($(strip $(MTK_BSP_PACKAGE)), yes) # include $(BUILD_SHARED_LIBRARY) # endif # else ifeq (OP02,$(word 1,$(subst _, ,$(OPTR_SPEC_SEG_DEF)))) # ifeq ($(strip $(MTK_BSP_PACKAGE)), yes) # include $(BUILD_SHARED_LIBRARY) # endif # else ifeq (OP09,$(word 1,$(subst _, ,$(OPTR_SPEC_SEG_DEF)))) # ifeq ($(strip $(MTK_BSP_PACKAGE)), yes) # include $(BUILD_SHARED_LIBRARY) # endif # endif
三、BootAnimation.cpp 排错
vendor/mediatek/proprietary/operator/frameworks/bootanimation/MtkBootanimation/BootAnimation.cpp
错误1、 use of undeclared identifier ITerService
解决 mk中导入 libterservice,cpp 中引入 #include “ITerService.h”
错误2、 use of undeclared identifier BootanimFileName
解决 BootAnimation.cpp 增加 char BootanimFileName[PROPERTY_VALUE_MAX]; 定义
错误3、 ISurfaceComposer 不存在的构造函数
解决 sp dtoken(SurfaceComposerClient::getInternalDisplayToken());
+++ b/alps/vendor/mediatek/proprietary/operator/frameworks/bootanimation/MtkBootanimation/BootAnimation.cpp @@ -76,6 +76,9 @@ #include <binder/Parcel.h> #define PATH_COUNT 3 +#include <binder/IServiceManager.h> +#include "ITerService.h" +#define REGIONAL_BOOTANIM_GET_MNC "persist.vendor.bootanim.mnc" #ifdef MSSI_MTK_CARRIEREXPRESS_PACK @@ -412,16 +415,32 @@ status_t BootAnimation::readyToRun() { mAssets.addDefaultAssets(); - sp<IBinder> dtoken(SurfaceComposerClient::getBuiltInDisplay( - ISurfaceComposer::eDisplayIdMain)); + sp<IBinder> dtoken(SurfaceComposerClient::getInternalDisplayToken()); + if (dtoken == nullptr) + return -1; + DisplayInfo dinfo; status_t status = SurfaceComposerClient::getDisplayInfo(dtoken, &dinfo); if (status) return -1; @@ -538,7 +557,12 @@ bool BootAnimation::threadLoop() // We have no bootanimation file, so we use the stock android logo // animation. sp<MediaPlayer> mediaplayer; + /** const char* resourcePath = NULL; + */ + /** MTK begin */ + const char* resourcePath = initAudioPath(); + /** MTK end */ status_t mediastatus = NO_ERROR; if (resourcePath != NULL) { bPlayMP3 = true; @@ -1510,6 +1534,8 @@ const char* BootAnimation::initAudioPath() { void BootAnimation::initBootanimationZip() { ZipFileRO* zipFile = NULL; String8 ZipFileName; + ALOGD(" MTK_TER_SERVICE: true"); + char BootanimFileName[PROPERTY_VALUE_MAX]; #ifdef MSSI_MTK_CARRIEREXPRESS_PACK char OPTR[PROPERTY_VALUE_MAX]; // ter-service
四、其它
第一次开机没有铃声
1.frameworks/av/media/libaudioclient/AudioTrack.cpp
#endif + if(!strcmp(mAttributes.tags,"BootAnimationAudioTrack")) { + ALOGD("mAttributes.tags = BootAnimationAudioTrack"); + strcpy(input.attr.tags, "BootAnimationAudioTrack"); + }else{ + strcpy(input.attr.tags, ""); + } + input.flags = mFlags; input.frameCount = mReqFrameCount; input.notificationFrameCount = mNotificationFramesReq;
2.frameworks/av/services/audioflinger/Threads.cpp
} #endif - // XXX: these things DON'T need to be done each time + + + if(!strcmp(track->mAttr.tags,"BootAnimationAudioTrack")) { + ALOGD("mAttributes.tags = BootAnimationAudioTrack"); + vlf = 0.50f; + vrf = 0.50f; + vaf = 0.50f; + } + + // XXX: these things DON'T need to be done each time mAudioMixer->setBufferProvider(name, track); mAudioMixer->enable(name);
关机有关机动画,重启无关机动画
Default设计,关机过程会有一个delayForPlayAnimation,但是重启(除了恢复出产设置)不会,
由于重启本身就牵涉到时间上的连续行,不会有任何delay。
修改方案:
vendor\mediatek\proprietary\frameworks\base\services\core\java\com\mediatek\server\MtkShutdownThread.java
贵司只需要在MtkShutdownThread.java的
public static void rebootOrShutdown(boolean reboot, String reason) {
里面将如下if判断去掉:
// added for Shutdown animation private void shutdownAnimationService() { if(isCustBootAnim()!= ANIMATION_MODE) { return; } /* M: fix shutdown animation timing issue */ Log.i(TAG, "set service.shutanim.running to 1"); SystemProperties.set("service.shutanim.running", "1"); /*M: play animation*/ /*if ((mReboot == true && mReason != null && mReason.equals("recovery")) || (mReboot == false)) {*/ delayForPlayAnimation(); //} } 只保留 delayForPlayAnimation(); 只要reboot都做delay
开关机流程
1、开关机动画的动作会生成一个native 可执行文件/system/bin/mtkbootanimation
开机情况下, adb shell 进入 /system/bin/ 直接执行 mtkbootanimation 可查看开机动画和开机音乐
2、通过init.rc配置成Service
service bootanim /system/bin/mtkbootanimation class core animation user graphics group graphics audio disabled oneshot writepid /dev/stune/top-app/tasks # MTK add service banim_shutmp3 /system/bin/mtkbootanimation shut mp3 class core animation user graphics group graphics audio disabled oneshot writepid /dev/stune/top-app/tasks service banim_shutnomp3 /system/bin/mtkbootanimation shut nomp3 class core animation user graphics group graphics audio disabled oneshot writepid /dev/stune/top-app/tasks
3、开机时执行
frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
frameworks/native/services/surfaceflinger/StartPropertySetThread.cpp
SurfaceFlinger::startBootAnim -->StartPropertySetThread::threadLoop // Clear BootAnimation exit flag property_set("service.bootanim.exit", "0"); // Start BootAnimation if not started property_set("ctl.start", "bootanim");
4、关机时执行
/vendor/mediatek/proprietary/frameworks/base/services/core/java/com/mediatek/server/MtkShutdownThread.java
private static void startBootAnimation() { Log.i(TAG, "Set 'service.bootanim.exit' = 0)."); SystemProperties.set("service.bootanim.exit", "0"); if (bPlayaudio) { SystemProperties.set("ctl.start", "banim_shutmp3"); Log.i(TAG, "bootanim:shut mp3"); } else { SystemProperties.set("ctl.start", "banim_shutnomp3"); Log.i(TAG, "bootanim:shut nomp3"); } }
5、开机动画逻辑入口
bootanimation_main.cpp
int main(int argc, char** argv) C++语言都是从main开始执行
sp boot = new BootAnimation(new AudioAnimationCallbacks(),setBoot,sePaly,setRotated);
参考文章