[DESCRIPTION]
现象:L版本开机时,kernel logo与开机动画之间闪一帧黑屏。
[SOLUTION]
这个现象是因为,在BootAnimation开始绘图之前,会先做一次clear screen的动作,避免出现前面的图干扰到BootAnimation的显示。这是Google default design,虽然不可避免,但是可以优化。
优化方法:
1.通过check main_log先确认播放开机动画是哪个function,在对应function删除clear screen的动作的对应代码。
/frameworks/base/cmds/bootanimation/BootAnimation.cpp
bool BootAnimation::android()
{
initTexture(&mAndroid[0], mAssets, "images/android-logo-mask.png");
initTexture(&mAndroid[1], mAssets, "images/android-logo-shine.png");
/*----------------------------删除clear screen对应code-------------------------*/
// clear screen
/*glShadeModel(GL_FLAT);
glDisable(GL_DITHER);
glDisable(GL_SCISSOR_TEST);
glClearColor(0,0,0,1);
glClear(GL_COLOR_BUFFER_BIT);
eglSwapBuffers(mDisplay, mSurface);*/
/*----------------------------删除clear screen对应code-------------------------*/
glEnable(GL_TEXTURE_2D);
glTexEnvx(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
bool BootAnimation::movie()
/*----------------------------删除clear screen对应code-------------------------*/
// clear screen
/*glShadeModel(GL_FLAT);
glDisable(GL_DITHER);
glDisable(GL_SCISSOR_TEST);
glDisable(GL_BLEND);
glClearColor(0,0,0,1);
glClear(GL_COLOR_BUFFER_BIT);
eglSwapBuffers(mDisplay, mSurface);*/
/*----------------------------删除clear screen对应code-------------------------*/
如果有MTKmovie则也要去掉clear screen 对应的code
bool BootAnimation::MTKmovie()
/*----------------------------删除clear screen对应code-------------------------*/
// clear screen
/*glDisable(GL_DITHER);
glDisable(GL_SCISSOR_TEST);
glDisable(GL_BLEND);
glClear(GL_COLOR_BUFFER_BIT);
eglSwapBuffers(mDisplay, mSurface);*/
/*----------------------------删除clear screen对应code-------------------------*/
2.在initAudioPath() function中,两个while循环可能耗时导致黑屏(没有while就不用了)
char* BootAnimation::initAudioPath() {
while (strcmp(type, "-1") == 0 &&
strcmp(crypto_state, "unencrypted") != 0 &&
deal_with_encryption == true){
usleep(100000);
property_get("ro.crypto.state", crypto_state, "-1");
property_get("vold.encryption.type", type, "-1");
}
while (strcmp(type, "default") == 0 && deal_with_encryption == true){
property_get("vold.decrypt", status, "-1");
if (strcmp(status, "trigger_restart_framework") != 0){
usleep(100000);
XLOGD("[BootAnimation %s %d]Decrypt status=%s",__FUNCTION__,__LINE__,status);
continue;
}
property_get("persist.sys.mute.state", volume, "-1");
int nVolume = -1;
nVolume = atoi(volume);
XLOGD("[BootAnimation %s %d]nVolume=%d",__FUNCTION__,__LINE__,nVolume);
if(nVolume == 0 || nVolume == 1){
XLOGD("initAudioPath: DON'T PLAY AUDIO!");
return NULL;
}
break;
}
本文来自:[FAQ14488]