diff options
author | Mathias Agopian <mathias@google.com> | 2012-06-20 13:37:13 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2012-06-20 13:37:13 -0700 |
commit | 8b3895392662640b84d3e2bbadb0bc53c456cea5 (patch) | |
tree | 9722e370b7c76334ca484e3c911c9664c108225c /cmds | |
parent | 3a9ff158fe45b3ee986dfa5f3c56fa48f781a5a9 (diff) | |
parent | 06c93386374de3812629908f21c057a8d60c4b12 (diff) | |
download | frameworks_base-8b3895392662640b84d3e2bbadb0bc53c456cea5.zip frameworks_base-8b3895392662640b84d3e2bbadb0bc53c456cea5.tar.gz frameworks_base-8b3895392662640b84d3e2bbadb0bc53c456cea5.tar.bz2 |
am 06c93386: Merge "Exit boot animation cleanly." into jb-dev
* commit '06c93386374de3812629908f21c057a8d60c4b12':
Exit boot animation cleanly.
Diffstat (limited to 'cmds')
-rw-r--r-- | cmds/bootanimation/BootAnimation.cpp | 40 | ||||
-rw-r--r-- | cmds/bootanimation/BootAnimation.h | 3 |
2 files changed, 38 insertions, 5 deletions
diff --git a/cmds/bootanimation/BootAnimation.cpp b/cmds/bootanimation/BootAnimation.cpp index 225be9c..6b50486 100644 --- 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_ENCRYPTED_BOOTANIMATION_FILE "/system/media/bootanimation-encrypted.zip" +#define EXIT_PROP_NAME "service.bootanim.exit" extern "C" int clock_nanosleep(clockid_t clock_id, int flags, const struct timespec *request, @@ -297,6 +298,9 @@ bool BootAnimation::threadLoop() r = movie(); } + // No need to force exit anymore + property_set(EXIT_PROP_NAME, "0"); + eglMakeCurrent(mDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); eglDestroyContext(mDisplay, mContext); eglDestroySurface(mDisplay, mSurface); @@ -363,6 +367,8 @@ bool BootAnimation::android() const nsecs_t sleepTime = 83333 - ns2us(systemTime() - now); if (sleepTime > 0) usleep(sleepTime); + + checkExit(); } while (!exitPending()); glDeleteTextures(1, &mAndroid[0].name); @@ -371,6 +377,16 @@ bool BootAnimation::android() } +void BootAnimation::checkExit() { + // Allow surface flinger to gracefully request shutdown + char value[PROPERTY_VALUE_MAX]; + property_get(EXIT_PROP_NAME, value, "0"); + int exitnow = atoi(value); + if (exitnow) { + requestExit(); + } +} + bool BootAnimation::movie() { ZipFileRO& zip(mZip); @@ -397,20 +413,23 @@ bool BootAnimation::movie() const char* l = line.string(); int fps, width, height, count, pause; char path[256]; + char pathType; if (sscanf(l, "%d %d %d", &width, &height, &fps) == 3) { - //ALOGD("> w=%d, h=%d, fps=%d", fps, width, height); + //LOGD("> w=%d, h=%d, fps=%d", width, height, fps); animation.width = width; animation.height = height; animation.fps = fps; } - if (sscanf(l, "p %d %d %s", &count, &pause, path) == 3) { - //ALOGD("> count=%d, pause=%d, path=%s", count, pause, path); + else if (sscanf(l, " %c %d %d %s", &pathType, &count, &pause, path) == 4) { + //LOGD("> type=%c, count=%d, pause=%d, path=%s", pathType, count, pause, path); Animation::Part part; + part.playUntilComplete = pathType == 'c'; part.count = count; part.pause = pause; part.path = path; animation.parts.add(part); } + s = ++endl; } @@ -472,13 +491,17 @@ bool BootAnimation::movie() Region clearReg(Rect(mWidth, mHeight)); clearReg.subtractSelf(Rect(xc, yc, xc+animation.width, yc+animation.height)); - for (int i=0 ; i<pcount && !exitPending() ; i++) { + for (int i=0 ; i<pcount ; i++) { const Animation::Part& part(animation.parts[i]); const size_t fcount = part.frames.size(); glBindTexture(GL_TEXTURE_2D, 0); for (int r=0 ; !part.count || r<part.count ; r++) { - for (int j=0 ; j<fcount && !exitPending(); j++) { + // Exit any non playuntil complete parts immediately + if(exitPending() && !part.playUntilComplete) + break; + + for (int j=0 ; j<fcount && (!exitPending() || part.playUntilComplete) ; j++) { const Animation::Frame& frame(part.frames[j]); nsecs_t lastFrame = systemTime(); @@ -525,8 +548,15 @@ bool BootAnimation::movie() err = clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &spec, NULL); } while (err<0 && errno == EINTR); } + + checkExit(); } + usleep(part.pause * ns2us(frameDuration)); + + // For infinite parts, we've now played them at least once, so perhaps exit + if(exitPending() && !part.count) + break; } // free the textures for this part diff --git a/cmds/bootanimation/BootAnimation.h b/cmds/bootanimation/BootAnimation.h index 62da82f..fa908eb 100644 --- a/cmds/bootanimation/BootAnimation.h +++ b/cmds/bootanimation/BootAnimation.h @@ -70,6 +70,7 @@ private: int pause; String8 path; SortedVector<Frame> frames; + bool playUntilComplete; }; int fps; int width; @@ -82,6 +83,8 @@ private: bool android(); bool movie(); + void checkExit(); + sp<SurfaceComposerClient> mSession; AssetManager mAssets; Texture mAndroid[2]; |