Loading cmds/bootanimation/BootAnimation.cpp +55 −14 Original line number Original line Diff line number Diff line Loading @@ -110,13 +110,30 @@ BootAnimation::BootAnimation(sp<Callbacks> callbacks) } else { } else { mShuttingDown = true; mShuttingDown = true; } } ALOGD("%sAnimationStartTiming start time: %" PRId64 "ms", mShuttingDown ? "Shutdown" : "Boot", elapsedRealtime()); } BootAnimation::~BootAnimation() { if (mAnimation != nullptr) { releaseAnimation(mAnimation); mAnimation = nullptr; } ALOGD("%sAnimationStopTiming start time: %" PRId64 "ms", mShuttingDown ? "Shutdown" : "Boot", elapsedRealtime()); } } void BootAnimation::onFirstRef() { void BootAnimation::onFirstRef() { status_t err = mSession->linkToComposerDeath(this); status_t err = mSession->linkToComposerDeath(this); SLOGE_IF(err, "linkToComposerDeath failed (%s) ", strerror(-err)); SLOGE_IF(err, "linkToComposerDeath failed (%s) ", strerror(-err)); if (err == NO_ERROR) { if (err == NO_ERROR) { run("BootAnimation", PRIORITY_DISPLAY); // Load the animation content -- this can be slow (eg 200ms) // called before waitForSurfaceFlinger() in main() to avoid wait ALOGD("%sAnimationPreloadTiming start time: %" PRId64 "ms", mShuttingDown ? "Shutdown" : "Boot", elapsedRealtime()); preloadAnimation(); ALOGD("%sAnimationPreloadStopTiming start time: %" PRId64 "ms", mShuttingDown ? "Shutdown" : "Boot", elapsedRealtime()); } } } } Loading Loading @@ -306,6 +323,20 @@ status_t BootAnimation::readyToRun() { mFlingerSurface = s; mFlingerSurface = s; mTargetInset = -1; mTargetInset = -1; return NO_ERROR; } bool BootAnimation::preloadAnimation() { findBootAnimationFile(); if (!mZipFileName.isEmpty()) { mAnimation = loadAnimation(mZipFileName); return (mAnimation != nullptr); } return false; } void BootAnimation::findBootAnimationFile() { // If the device has encryption turned on or is in process // If the device has encryption turned on or is in process // of being encrypted we show the encrypted boot animation. // of being encrypted we show the encrypted boot animation. char decrypt[PROPERTY_VALUE_MAX]; char decrypt[PROPERTY_VALUE_MAX]; Loading @@ -320,7 +351,7 @@ status_t BootAnimation::readyToRun() { for (const char* f : encryptedBootFiles) { for (const char* f : encryptedBootFiles) { if (access(f, R_OK) == 0) { if (access(f, R_OK) == 0) { mZipFileName = f; mZipFileName = f; return NO_ERROR; return; } } } } } } Loading @@ -332,10 +363,9 @@ status_t BootAnimation::readyToRun() { for (const char* f : (!mShuttingDown ? bootFiles : shutdownFiles)) { for (const char* f : (!mShuttingDown ? bootFiles : shutdownFiles)) { if (access(f, R_OK) == 0) { if (access(f, R_OK) == 0) { mZipFileName = f; mZipFileName = f; return NO_ERROR; return; } } } } return NO_ERROR; } } bool BootAnimation::threadLoop() bool BootAnimation::threadLoop() Loading Loading @@ -790,8 +820,6 @@ bool BootAnimation::preloadZip(Animation& animation) } } } } mCallbacks->init(animation.parts); zip->endIteration(cookie); zip->endIteration(cookie); return true; return true; Loading @@ -799,13 +827,25 @@ bool BootAnimation::preloadZip(Animation& animation) bool BootAnimation::movie() bool BootAnimation::movie() { { Animation* animation = loadAnimation(mZipFileName); if (mAnimation == nullptr) { if (animation == NULL) mAnimation = loadAnimation(mZipFileName); } if (mAnimation == nullptr) return false; return false; // mCallbacks->init() may get called recursively, // this loop is needed to get the same results for (const Animation::Part& part : mAnimation->parts) { if (part.animation != nullptr) { mCallbacks->init(part.animation->parts); } } mCallbacks->init(mAnimation->parts); bool anyPartHasClock = false; bool anyPartHasClock = false; for (size_t i=0; i < animation->parts.size(); i++) { for (size_t i=0; i < mAnimation->parts.size(); i++) { if(validClock(animation->parts[i])) { if(validClock(mAnimation->parts[i])) { anyPartHasClock = true; anyPartHasClock = true; break; break; } } Loading Loading @@ -846,7 +886,7 @@ bool BootAnimation::movie() bool clockFontInitialized = false; bool clockFontInitialized = false; if (mClockEnabled) { if (mClockEnabled) { clockFontInitialized = clockFontInitialized = (initFont(&animation->clockFont, CLOCK_FONT_ASSET) == NO_ERROR); (initFont(&mAnimation->clockFont, CLOCK_FONT_ASSET) == NO_ERROR); mClockEnabled = clockFontInitialized; mClockEnabled = clockFontInitialized; } } Loading @@ -855,7 +895,7 @@ bool BootAnimation::movie() mTimeCheckThread->run("BootAnimation::TimeCheckThread", PRIORITY_NORMAL); mTimeCheckThread->run("BootAnimation::TimeCheckThread", PRIORITY_NORMAL); } } playAnimation(*animation); playAnimation(*mAnimation); if (mTimeCheckThread != nullptr) { if (mTimeCheckThread != nullptr) { mTimeCheckThread->requestExit(); mTimeCheckThread->requestExit(); Loading @@ -863,10 +903,11 @@ bool BootAnimation::movie() } } if (clockFontInitialized) { if (clockFontInitialized) { glDeleteTextures(1, &animation->clockFont.texture.name); glDeleteTextures(1, &mAnimation->clockFont.texture.name); } } releaseAnimation(animation); releaseAnimation(mAnimation); mAnimation = nullptr; return false; return false; } } Loading cmds/bootanimation/BootAnimation.h +4 −0 Original line number Original line Diff line number Diff line Loading @@ -115,6 +115,7 @@ public: }; }; explicit BootAnimation(sp<Callbacks> callbacks); explicit BootAnimation(sp<Callbacks> callbacks); virtual ~BootAnimation(); sp<SurfaceComposerClient> session() const; sp<SurfaceComposerClient> session() const; Loading Loading @@ -155,6 +156,8 @@ private: void releaseAnimation(Animation*) const; void releaseAnimation(Animation*) const; bool parseAnimationDesc(Animation&); bool parseAnimationDesc(Animation&); bool preloadZip(Animation &animation); bool preloadZip(Animation &animation); void findBootAnimationFile(); bool preloadAnimation(); void checkExit(); void checkExit(); Loading Loading @@ -182,6 +185,7 @@ private: SortedVector<String8> mLoadedFiles; SortedVector<String8> mLoadedFiles; sp<TimeCheckThread> mTimeCheckThread = nullptr; sp<TimeCheckThread> mTimeCheckThread = nullptr; sp<Callbacks> mCallbacks; sp<Callbacks> mCallbacks; Animation* mAnimation = nullptr; }; }; // --------------------------------------------------------------------------- // --------------------------------------------------------------------------- Loading cmds/bootanimation/bootanimation_main.cpp +5 −3 Original line number Original line Diff line number Diff line Loading @@ -44,14 +44,16 @@ int main() sp<ProcessState> proc(ProcessState::self()); sp<ProcessState> proc(ProcessState::self()); ProcessState::self()->startThreadPool(); ProcessState::self()->startThreadPool(); // create the boot animation object (may take up to 200ms for 2MB zip) sp<BootAnimation> boot = new BootAnimation(audioplay::createAnimationCallbacks()); waitForSurfaceFlinger(); waitForSurfaceFlinger(); // create the boot animation object boot->run("BootAnimation", PRIORITY_DISPLAY); sp<BootAnimation> boot = new BootAnimation(audioplay::createAnimationCallbacks()); ALOGV("Boot animation set up. Joining pool."); ALOGV("Boot animation set up. Joining pool."); IPCThreadState::self()->joinThreadPool(); IPCThreadState::self()->joinThreadPool(); } } ALOGV("Boot animation exit"); return 0; return 0; } } Loading
cmds/bootanimation/BootAnimation.cpp +55 −14 Original line number Original line Diff line number Diff line Loading @@ -110,13 +110,30 @@ BootAnimation::BootAnimation(sp<Callbacks> callbacks) } else { } else { mShuttingDown = true; mShuttingDown = true; } } ALOGD("%sAnimationStartTiming start time: %" PRId64 "ms", mShuttingDown ? "Shutdown" : "Boot", elapsedRealtime()); } BootAnimation::~BootAnimation() { if (mAnimation != nullptr) { releaseAnimation(mAnimation); mAnimation = nullptr; } ALOGD("%sAnimationStopTiming start time: %" PRId64 "ms", mShuttingDown ? "Shutdown" : "Boot", elapsedRealtime()); } } void BootAnimation::onFirstRef() { void BootAnimation::onFirstRef() { status_t err = mSession->linkToComposerDeath(this); status_t err = mSession->linkToComposerDeath(this); SLOGE_IF(err, "linkToComposerDeath failed (%s) ", strerror(-err)); SLOGE_IF(err, "linkToComposerDeath failed (%s) ", strerror(-err)); if (err == NO_ERROR) { if (err == NO_ERROR) { run("BootAnimation", PRIORITY_DISPLAY); // Load the animation content -- this can be slow (eg 200ms) // called before waitForSurfaceFlinger() in main() to avoid wait ALOGD("%sAnimationPreloadTiming start time: %" PRId64 "ms", mShuttingDown ? "Shutdown" : "Boot", elapsedRealtime()); preloadAnimation(); ALOGD("%sAnimationPreloadStopTiming start time: %" PRId64 "ms", mShuttingDown ? "Shutdown" : "Boot", elapsedRealtime()); } } } } Loading Loading @@ -306,6 +323,20 @@ status_t BootAnimation::readyToRun() { mFlingerSurface = s; mFlingerSurface = s; mTargetInset = -1; mTargetInset = -1; return NO_ERROR; } bool BootAnimation::preloadAnimation() { findBootAnimationFile(); if (!mZipFileName.isEmpty()) { mAnimation = loadAnimation(mZipFileName); return (mAnimation != nullptr); } return false; } void BootAnimation::findBootAnimationFile() { // If the device has encryption turned on or is in process // If the device has encryption turned on or is in process // of being encrypted we show the encrypted boot animation. // of being encrypted we show the encrypted boot animation. char decrypt[PROPERTY_VALUE_MAX]; char decrypt[PROPERTY_VALUE_MAX]; Loading @@ -320,7 +351,7 @@ status_t BootAnimation::readyToRun() { for (const char* f : encryptedBootFiles) { for (const char* f : encryptedBootFiles) { if (access(f, R_OK) == 0) { if (access(f, R_OK) == 0) { mZipFileName = f; mZipFileName = f; return NO_ERROR; return; } } } } } } Loading @@ -332,10 +363,9 @@ status_t BootAnimation::readyToRun() { for (const char* f : (!mShuttingDown ? bootFiles : shutdownFiles)) { for (const char* f : (!mShuttingDown ? bootFiles : shutdownFiles)) { if (access(f, R_OK) == 0) { if (access(f, R_OK) == 0) { mZipFileName = f; mZipFileName = f; return NO_ERROR; return; } } } } return NO_ERROR; } } bool BootAnimation::threadLoop() bool BootAnimation::threadLoop() Loading Loading @@ -790,8 +820,6 @@ bool BootAnimation::preloadZip(Animation& animation) } } } } mCallbacks->init(animation.parts); zip->endIteration(cookie); zip->endIteration(cookie); return true; return true; Loading @@ -799,13 +827,25 @@ bool BootAnimation::preloadZip(Animation& animation) bool BootAnimation::movie() bool BootAnimation::movie() { { Animation* animation = loadAnimation(mZipFileName); if (mAnimation == nullptr) { if (animation == NULL) mAnimation = loadAnimation(mZipFileName); } if (mAnimation == nullptr) return false; return false; // mCallbacks->init() may get called recursively, // this loop is needed to get the same results for (const Animation::Part& part : mAnimation->parts) { if (part.animation != nullptr) { mCallbacks->init(part.animation->parts); } } mCallbacks->init(mAnimation->parts); bool anyPartHasClock = false; bool anyPartHasClock = false; for (size_t i=0; i < animation->parts.size(); i++) { for (size_t i=0; i < mAnimation->parts.size(); i++) { if(validClock(animation->parts[i])) { if(validClock(mAnimation->parts[i])) { anyPartHasClock = true; anyPartHasClock = true; break; break; } } Loading Loading @@ -846,7 +886,7 @@ bool BootAnimation::movie() bool clockFontInitialized = false; bool clockFontInitialized = false; if (mClockEnabled) { if (mClockEnabled) { clockFontInitialized = clockFontInitialized = (initFont(&animation->clockFont, CLOCK_FONT_ASSET) == NO_ERROR); (initFont(&mAnimation->clockFont, CLOCK_FONT_ASSET) == NO_ERROR); mClockEnabled = clockFontInitialized; mClockEnabled = clockFontInitialized; } } Loading @@ -855,7 +895,7 @@ bool BootAnimation::movie() mTimeCheckThread->run("BootAnimation::TimeCheckThread", PRIORITY_NORMAL); mTimeCheckThread->run("BootAnimation::TimeCheckThread", PRIORITY_NORMAL); } } playAnimation(*animation); playAnimation(*mAnimation); if (mTimeCheckThread != nullptr) { if (mTimeCheckThread != nullptr) { mTimeCheckThread->requestExit(); mTimeCheckThread->requestExit(); Loading @@ -863,10 +903,11 @@ bool BootAnimation::movie() } } if (clockFontInitialized) { if (clockFontInitialized) { glDeleteTextures(1, &animation->clockFont.texture.name); glDeleteTextures(1, &mAnimation->clockFont.texture.name); } } releaseAnimation(animation); releaseAnimation(mAnimation); mAnimation = nullptr; return false; return false; } } Loading
cmds/bootanimation/BootAnimation.h +4 −0 Original line number Original line Diff line number Diff line Loading @@ -115,6 +115,7 @@ public: }; }; explicit BootAnimation(sp<Callbacks> callbacks); explicit BootAnimation(sp<Callbacks> callbacks); virtual ~BootAnimation(); sp<SurfaceComposerClient> session() const; sp<SurfaceComposerClient> session() const; Loading Loading @@ -155,6 +156,8 @@ private: void releaseAnimation(Animation*) const; void releaseAnimation(Animation*) const; bool parseAnimationDesc(Animation&); bool parseAnimationDesc(Animation&); bool preloadZip(Animation &animation); bool preloadZip(Animation &animation); void findBootAnimationFile(); bool preloadAnimation(); void checkExit(); void checkExit(); Loading Loading @@ -182,6 +185,7 @@ private: SortedVector<String8> mLoadedFiles; SortedVector<String8> mLoadedFiles; sp<TimeCheckThread> mTimeCheckThread = nullptr; sp<TimeCheckThread> mTimeCheckThread = nullptr; sp<Callbacks> mCallbacks; sp<Callbacks> mCallbacks; Animation* mAnimation = nullptr; }; }; // --------------------------------------------------------------------------- // --------------------------------------------------------------------------- Loading
cmds/bootanimation/bootanimation_main.cpp +5 −3 Original line number Original line Diff line number Diff line Loading @@ -44,14 +44,16 @@ int main() sp<ProcessState> proc(ProcessState::self()); sp<ProcessState> proc(ProcessState::self()); ProcessState::self()->startThreadPool(); ProcessState::self()->startThreadPool(); // create the boot animation object (may take up to 200ms for 2MB zip) sp<BootAnimation> boot = new BootAnimation(audioplay::createAnimationCallbacks()); waitForSurfaceFlinger(); waitForSurfaceFlinger(); // create the boot animation object boot->run("BootAnimation", PRIORITY_DISPLAY); sp<BootAnimation> boot = new BootAnimation(audioplay::createAnimationCallbacks()); ALOGV("Boot animation set up. Joining pool."); ALOGV("Boot animation set up. Joining pool."); IPCThreadState::self()->joinThreadPool(); IPCThreadState::self()->joinThreadPool(); } } ALOGV("Boot animation exit"); return 0; return 0; } }