Android4.4系统启动时,播放自定义bootanimation.zip动画时,由于分辨率为1280x720,bootanimation.zip包也很大,播放太卡,所以将开机动画修改为播放视频。如下为修改记录
modified: frameworks/base/cmds/bootanimation/Android.mk
modified: frameworks/base/cmds/bootanimation/BootAnimation.cpp
modified: frameworks/base/cmds/bootanimation/BootAnimation.h
diff --git a/cmds/bootanimation/Android.mk b/cmds/bootanimation/Android.mk
index d5ff84e..0816bec 100755
--- a/cmds/bootanimation/Android.mk
+++ b/cmds/bootanimation/Android.mk
@@ -17,7 +17,8 @@ LOCAL_SHARED_LIBRARIES := \
libskia \
libEGL \
libGLESv1_CM \
- libgui
+ libgui \
+ libmedia
diff --git a/cmds/bootanimation/BootAnimation.h b/cmds/bootanimation/BootAnimation.h
index fa908eb..4266004 100755
--- a/cmds/bootanimation/BootAnimation.h
+++ b/cmds/bootanimation/BootAnimation.h
@@ -26,6 +26,8 @@
#include
#include
+#include
+
class SkBitmap;
namespace android {
@@ -82,6 +84,7 @@ private:
status_t initTexture(void* buffer, size_t len);
bool android();
bool movie();
+ bool video();
void checkExit();
@@ -97,6 +100,7 @@ private:
sp mFlingerSurface;
bool mAndroidAnimation;
ZipFileRO mZip;
+ bool mVideo;
};
diff --git a/cmds/bootanimation/BootAnimation.cpp b/cmds/bootanimation/BootAnimation.cpp
index 54813a6..f49c632 100755
--- a/cmds/bootanimation/BootAnimation.cpp
+++ b/cmds/bootanimation/BootAnimation.cpp
@@ -54,6 +54,7 @@
#define USER_BOOTANIMATION_FILE "/data/local/bootanimation.zip"
#define SYSTEM_BOOTANIMATION_FILE "/system/media/bootanimation.zip"
+#define SYSTEM_BOOT_VIDEO_FILE "/system/media/boot_start.mp4"
#define SYSTEM_ENCRYPTED_BOOTANIMATION_FILE "/system/media/bootanimation-encrypted.zip"
#define EXIT_PROP_NAME "service.bootanim.exit"
@@ -289,17 +290,31 @@ status_t BootAnimation::readyToRun() {
mAndroidAnimation = false;
}
+ if (access(SYSTEM_BOOT_VIDEO_FILE, R_OK) == 0) {
+ mVideo = true;
+ } else {
+ mVideo = false;
+ }
+
return NO_ERROR;
}
bool BootAnimation::threadLoop()
{
bool r;
+#if 0
if (mAndroidAnimation) {
r = android();
} else {
r = movie();
}
+#else
+ if (!mVideo) {
+ r = android();
+ }else {
+ r = video();
+ }
+#endif
// No need to force exit anymore
property_set(EXIT_PROP_NAME, "0");
@@ -575,6 +590,39 @@ bool BootAnimation::movie()
return false;
}
+bool BootAnimation::video() {
+
+ ALOGI("%s start", __FUNCTION__);
+
+ eglMakeCurrent(mDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
+ eglDestroySurface(mDisplay, mSurface);
+
+ sp mp = new MediaPlayer();
+ mp->reset();
+ mp->setDataSource(SYSTEM_BOOT_VIDEO_FILE, NULL);
+ mp->setLooping(false);
+ mp->setVideoSurfaceTexture(mFlingerSurface->getIGraphicBufferProducer());
+ mp->prepare();
+
+ //delay for play boot video
+ sleep(5);
+
+ mp->start();
+
+ while(true) {
+ if (exitPending())
+ break;
+
+ usleep(100);
+ checkExit();
+ }
+
+ mp->stop();
+ ALOGI("%s end", __FUNCTION__);
+
+ return false;
+}
+
// ---------------------------------------------------------------------------
}