简介
- 平台:MTK6761
- 系统:Android 13
- 模块:开机动画
- 源码位置:vendor/mediatek/proprietary/operator/frameworks/bootanimation/MtkBootanimation/
开机动画初始化流程—地址修改
- vendor/mediatek/proprietary/operator/frameworks/bootanimation/MtkBootanimation/bootanimation_main.cpp
int main(int argc, char** argv)
{
sp<BootAnimation> boot = new BootAnimation(new AudioAnimationCallbacks(),setBoot,sePaly,setRotated);
IPCThreadState::self()->joinThreadPool();
}
}
// Thread执行前的初始化
status_t BootAnimation::readyToRun() {
SurfaceComposerClient::Transaction t;
if (bBootOrShutDown) {
initBootanimationZip(); //初始化开机动画
} else {
initShutanimationZip(); //初始化关机动画
}
}
开机动画播放流程
// 每个线程类都要实现的,开始播放
bool BootAnimation::threadLoop()
{
if ((mZip == NULL)&&(mZipFileName.isEmpty())) {
r = android(); //系统默认开机动画
} else if(mZip != NULL){
if (!bETC1Movie) {
ALOGD("threadLoop() movie()");
r = movie(); //自定义开机动画
} else {
ALOGD("threadLoop() ETC1movie()");
r = ETC1movie();
}
}
else
{
r = android();
}
}
bool BootAnimation::movie()
{
Animation* animation = loadAnimation(mZipFileName); //加载开机动画
playAnimation(*animation); //播放开机动画
return false;
}
bool BootAnimation::playAnimation(const Animation& animation)
{
//循环播放
for (size_t i=0 ; i<pcount ; i++) {
for (int r=0 ; !part.count || r<part.count ; r++) {
for (size_t j=0 ; j<fcount && (!exitPending() || part.playUntilComplete) ; j++) {
if(!bPlayMP3){
checkExit(); //检测退出
}else{
if(mBootVideoPlayState == MEDIA_PLAYBACK_COMPLETE || mBootVideoPlayState == MEDIA_ERROR) {
checkExit();
}
}
}
}
}
}
static const char EXIT_PROP_NAME[] = "service.bootanim.exit";
void BootAnimation::checkExit() {
// Allow surface flinger to gracefully request shutdown
char value[PROPERTY_VALUE_MAX];
property_get(EXIT_PROP_NAME, value, "0"); //检测系统属性"service.bootanim.exit";
int exitnow = atoi(value);
if (exitnow) {
requestExit();
mCallbacks->shutdown();
}
}
参考
Android 开机动画的启动