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;
93 bool operator < (const Frame& rhs) const {
94 return name < rhs.name;
98 int count; // The number of times this part should repeat, 0 for infinite
99 int pause; // The number of frames to pause for at the end of this part
100 int clockPosX; // The x position of the clock, in pixels. Positive values offset from
101 // the left of the screen, negative values offset from the right.
102 int clockPosY; // The y position of the clock, in pixels. Positive values offset from
103 // the bottom of the screen, negative values offset from the top.
104 // If either of the above are INT_MIN the clock is disabled, if INT_MAX
105 // the clock is centred on that axis.
108 SortedVector<Frame> frames;
109 bool playUntilComplete;
110 float backgroundColor[3];
113 Animation* animation;
125 status_t initTexture(Texture* texture, AssetManager& asset, const char* name);
126 status_t initTexture(FileMap* map, int* width, int* height);
127 status_t initFont(Font* font, const char* fallback);
130 void drawText(const char* str, const Font& font, bool bold, int* x, int* y);
131 void drawClock(const Font& font, const int xPos, const int yPos);
132 bool validClock(const Animation::Part& part);
133 Animation* loadAnimation(const String8&);
134 bool playAnimation(const Animation&);
135 void releaseAnimation(Animation*) const;
136 bool parseAnimationDesc(Animation&);
137 bool preloadZip(Animation &animation);
138 bool playSoundsAllowed() const;
142 sp<SurfaceComposerClient> mSession;
143 AssetManager mAssets;
147 bool mUseNpotTextures = false;
151 sp<SurfaceControl> mFlingerSurfaceControl;
152 sp<Surface> mFlingerSurface;
154 bool mTimeIsAccurate;
155 bool mTimeFormat12Hour;
157 String8 mZipFileName;
158 SortedVector<String8> mLoadedFiles;
159 sp<TimeCheckThread> mTimeCheckThread;
162 // ---------------------------------------------------------------------------
164 }; // namespace android
166 #endif // ANDROID_BOOTANIMATION_H