2 * Copyright (C) 2007 The Android Open Source Project
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #ifndef ANDROID_BOOTANIMATION_H
18 #define ANDROID_BOOTANIMATION_H
21 #include <sys/types.h>
23 #include <androidfw/AssetManager.h>
24 #include <utils/Thread.h>
34 class SurfaceComposerClient;
37 // ---------------------------------------------------------------------------
39 class BootAnimation : public Thread, public IBinder::DeathRecipient
43 virtual ~BootAnimation();
45 sp<SurfaceComposerClient> session() const;
48 virtual bool threadLoop();
49 virtual status_t readyToRun();
50 virtual void onFirstRef();
51 virtual void binderDied(const wp<IBinder>& who);
53 bool updateIsTimeAccurate();
55 class TimeCheckThread : public Thread {
57 TimeCheckThread(BootAnimation* bootAnimation);
58 virtual ~TimeCheckThread();
60 virtual status_t readyToRun();
61 virtual bool threadLoop();
63 void addTimeDirWatch();
68 BootAnimation* mBootAnimation;
86 bool operator < (const Frame& rhs) const {
87 return name < rhs.name;
91 int count; // The number of times this part should repeat, 0 for infinite
92 int pause; // The number of frames to pause for at the end of this part
93 int clockPosY; // The y position of the clock, in pixels, from the bottom of the
94 // display (the clock is centred horizontally). -1 to disable the clock
97 SortedVector<Frame> frames;
98 bool playUntilComplete;
99 float backgroundColor[3];
102 Animation* animation;
113 status_t initTexture(Texture* texture, AssetManager& asset, const char* name);
114 status_t initTexture(const Animation::Frame& frame);
117 void drawTime(const Texture& clockTex, const int yPos);
118 Animation* loadAnimation(const String8&);
119 bool playAnimation(const Animation&);
120 void releaseAnimation(Animation*) const;
121 bool parseAnimationDesc(Animation&);
122 bool preloadZip(Animation &animation);
123 bool playSoundsAllowed() const;
127 sp<SurfaceComposerClient> mSession;
128 AssetManager mAssets;
133 bool mUseNpotTextures = false;
137 sp<SurfaceControl> mFlingerSurfaceControl;
138 sp<Surface> mFlingerSurface;
140 bool mTimeIsAccurate;
142 String8 mZipFileName;
143 SortedVector<String8> mLoadedFiles;
144 sp<TimeCheckThread> mTimeCheckThread;
147 // ---------------------------------------------------------------------------
149 }; // namespace android
151 #endif // ANDROID_BOOTANIMATION_H