blob: 79017378c9092634de1baadddf4e0b330540f493 [file] [log] [blame]
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001/*
2 * Copyright (C) 2007 The Android Open Source Project
3 *
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
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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.
15 */
16
Mike Lockwoodebf9a0d2014-10-02 16:08:47 -070017#define LOG_NDEBUG 0
Mathias Agopianbc726112009-09-23 15:44:05 -070018#define LOG_TAG "BootAnimation"
19
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080020#include <stdint.h>
Wei Wanga90c54c2017-02-02 11:35:21 -080021#include <inttypes.h>
Damien Bargiacchi97480862016-03-29 14:55:55 -070022#include <sys/inotify.h>
23#include <sys/poll.h>
24#include <sys/stat.h>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080025#include <sys/types.h>
26#include <math.h>
27#include <fcntl.h>
28#include <utils/misc.h>
Mathias Agopianb4d5a722009-09-23 17:05:19 -070029#include <signal.h>
Elliott Hughesbb94f312014-10-21 10:41:33 -070030#include <time.h>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080031
Jason parksbd9a08d2011-01-31 15:04:34 -060032#include <cutils/properties.h>
33
Mathias Agopianb13b9bd2012-02-17 18:27:36 -080034#include <androidfw/AssetManager.h>
Mathias Agopianac31a3b2009-05-21 19:59:24 -070035#include <binder/IPCThreadState.h>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080036#include <utils/Atomic.h>
37#include <utils/Errors.h>
38#include <utils/Log.h>
Wei Wanga90c54c2017-02-02 11:35:21 -080039#include <utils/SystemClock.h>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080040
41#include <ui/PixelFormat.h>
42#include <ui/Rect.h>
43#include <ui/Region.h>
44#include <ui/DisplayInfo.h>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080045
Jeff Brown0b722fe2012-08-24 22:40:14 -070046#include <gui/ISurfaceComposer.h>
Mathias Agopian8335f1c2012-02-25 18:48:35 -080047#include <gui/Surface.h>
48#include <gui/SurfaceComposerClient.h>
Mathias Agopian000479f2010-02-09 17:46:37 -080049
Andreas Gampecfedceb2014-09-30 21:48:18 -070050// TODO: Fix Skia.
51#pragma GCC diagnostic push
52#pragma GCC diagnostic ignored "-Wunused-parameter"
Derek Sollenbergereece0dd2014-02-27 14:31:29 -050053#include <SkBitmap.h>
Matt Sarett8898c162016-03-24 16:11:01 -040054#include <SkImage.h>
Derek Sollenbergereece0dd2014-02-27 14:31:29 -050055#include <SkStream.h>
Andreas Gampecfedceb2014-09-30 21:48:18 -070056#pragma GCC diagnostic pop
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080057
58#include <GLES/gl.h>
59#include <GLES/glext.h>
60#include <EGL/eglext.h>
61
62#include "BootAnimation.h"
Geoffrey Pitschd6d9a1d2016-06-08 00:38:58 -070063#include "audioplay.h"
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080064
65namespace android {
66
Damien Bargiacchi97480862016-03-29 14:55:55 -070067static const char OEM_BOOTANIMATION_FILE[] = "/oem/media/bootanimation.zip";
68static const char SYSTEM_BOOTANIMATION_FILE[] = "/system/media/bootanimation.zip";
69static const char SYSTEM_ENCRYPTED_BOOTANIMATION_FILE[] = "/system/media/bootanimation-encrypted.zip";
70static const char SYSTEM_DATA_DIR_PATH[] = "/data/system";
71static const char SYSTEM_TIME_DIR_NAME[] = "time";
72static const char SYSTEM_TIME_DIR_PATH[] = "/data/system/time";
Damien Bargiacchi0e3d2ab2016-08-29 04:11:19 -070073static const char CLOCK_FONT_ASSET[] = "images/clock_font.png";
74static const char CLOCK_FONT_ZIP_NAME[] = "clock_font.png";
Damien Bargiacchi97480862016-03-29 14:55:55 -070075static const char LAST_TIME_CHANGED_FILE_NAME[] = "last_time_change";
76static const char LAST_TIME_CHANGED_FILE_PATH[] = "/data/system/time/last_time_change";
77static const char ACCURATE_TIME_FLAG_FILE_NAME[] = "time_is_accurate";
78static const char ACCURATE_TIME_FLAG_FILE_PATH[] = "/data/system/time/time_is_accurate";
Damien Bargiacchi9071db12016-10-28 17:38:22 -070079static const char TIME_FORMAT_12_HOUR_FLAG_FILE_PATH[] = "/data/system/time/time_format_12_hour";
Damien Bargiacchi96762812016-07-12 15:53:40 -070080// Java timestamp format. Don't show the clock if the date is before 2000-01-01 00:00:00.
81static const long long ACCURATE_TIME_EPOCH = 946684800000;
Damien Bargiacchi0e3d2ab2016-08-29 04:11:19 -070082static constexpr char FONT_BEGIN_CHAR = ' ';
83static constexpr char FONT_END_CHAR = '~' + 1;
84static constexpr size_t FONT_NUM_CHARS = FONT_END_CHAR - FONT_BEGIN_CHAR + 1;
85static constexpr size_t FONT_NUM_COLS = 16;
86static constexpr size_t FONT_NUM_ROWS = FONT_NUM_CHARS / FONT_NUM_COLS;
87static const int TEXT_CENTER_VALUE = INT_MAX;
88static const int TEXT_MISSING_VALUE = INT_MIN;
Damien Bargiacchi97480862016-03-29 14:55:55 -070089static const char EXIT_PROP_NAME[] = "service.bootanim.exit";
Geoffrey Pitsch30508792016-07-22 17:04:21 -040090static const char PLAY_SOUND_PROP_NAME[] = "persist.sys.bootanim.play_sound";
Narayan Kamathafd31e02013-12-03 13:16:03 +000091static const int ANIM_ENTRY_NAME_MAX = 256;
Damien Bargiacchi0e3d2ab2016-08-29 04:11:19 -070092static constexpr size_t TEXT_POS_LEN_MAX = 16;
Geoffrey Pitsch290c4352016-08-09 14:35:10 -040093static const char BOOT_COMPLETED_PROP_NAME[] = "sys.boot_completed";
94static const char BOOTREASON_PROP_NAME[] = "ro.boot.bootreason";
95// bootreasons list in "system/core/bootstat/bootstat.cpp".
96static const std::vector<std::string> PLAY_SOUND_BOOTREASON_BLACKLIST {
97 "kernel_panic",
98 "Panic",
99 "Watchdog",
100};
Narayan Kamathafd31e02013-12-03 13:16:03 +0000101
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800102// ---------------------------------------------------------------------------
103
Damien Bargiacchi97480862016-03-29 14:55:55 -0700104BootAnimation::BootAnimation() : Thread(false), mClockEnabled(true), mTimeIsAccurate(false),
Damien Bargiacchi9071db12016-10-28 17:38:22 -0700105 mTimeFormat12Hour(false), mTimeCheckThread(NULL) {
Mathias Agopian627e7b52009-05-21 19:21:59 -0700106 mSession = new SurfaceComposerClient();
Geoffrey Pitsch290c4352016-08-09 14:35:10 -0400107
108 // If the system has already booted, the animation is not being used for a boot.
109 mSystemBoot = !property_get_bool(BOOT_COMPLETED_PROP_NAME, 0);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800110}
111
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800112void BootAnimation::onFirstRef() {
Mathias Agopianbc726112009-09-23 15:44:05 -0700113 status_t err = mSession->linkToComposerDeath(this);
Steve Block3762c312012-01-06 19:20:56 +0000114 ALOGE_IF(err, "linkToComposerDeath failed (%s) ", strerror(-err));
Mathias Agopian8434c532009-09-23 18:52:49 -0700115 if (err == NO_ERROR) {
Mathias Agopianbc726112009-09-23 15:44:05 -0700116 run("BootAnimation", PRIORITY_DISPLAY);
117 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800118}
119
Mathias Agopianbc726112009-09-23 15:44:05 -0700120sp<SurfaceComposerClient> BootAnimation::session() const {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800121 return mSession;
122}
123
Mathias Agopianbc726112009-09-23 15:44:05 -0700124
Narayan Kamathafd31e02013-12-03 13:16:03 +0000125void BootAnimation::binderDied(const wp<IBinder>&)
Mathias Agopianbc726112009-09-23 15:44:05 -0700126{
127 // woah, surfaceflinger died!
Steve Block5baa3a62011-12-20 16:23:08 +0000128 ALOGD("SurfaceFlinger died, exiting...");
Mathias Agopianbc726112009-09-23 15:44:05 -0700129
130 // calling requestExit() is not enough here because the Surface code
131 // might be blocked on a condition variable that will never be updated.
132 kill( getpid(), SIGKILL );
133 requestExit();
Geoffrey Pitschd6d9a1d2016-06-08 00:38:58 -0700134 audioplay::destroy();
Mathias Agopianbc726112009-09-23 15:44:05 -0700135}
136
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800137status_t BootAnimation::initTexture(Texture* texture, AssetManager& assets,
138 const char* name) {
139 Asset* asset = assets.open(name, Asset::ACCESS_BUFFER);
Andreas Gampecfedceb2014-09-30 21:48:18 -0700140 if (asset == NULL)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800141 return NO_INIT;
142 SkBitmap bitmap;
Matt Sarett8898c162016-03-24 16:11:01 -0400143 sk_sp<SkData> data = SkData::MakeWithoutCopy(asset->getBuffer(false),
144 asset->getLength());
145 sk_sp<SkImage> image = SkImage::MakeFromEncoded(data);
146 image->asLegacyBitmap(&bitmap, SkImage::kRO_LegacyBitmapMode);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800147 asset->close();
148 delete asset;
149
150 // ensure we can call getPixels(). No need to call unlock, since the
151 // bitmap will go out of scope when we return from this method.
152 bitmap.lockPixels();
153
154 const int w = bitmap.width();
155 const int h = bitmap.height();
156 const void* p = bitmap.getPixels();
157
158 GLint crop[4] = { 0, h, w, -h };
159 texture->w = w;
160 texture->h = h;
161
162 glGenTextures(1, &texture->name);
163 glBindTexture(GL_TEXTURE_2D, texture->name);
164
Mike Reed42a1d082014-07-07 18:06:18 -0400165 switch (bitmap.colorType()) {
166 case kAlpha_8_SkColorType:
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800167 glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, w, h, 0, GL_ALPHA,
168 GL_UNSIGNED_BYTE, p);
169 break;
Mike Reed42a1d082014-07-07 18:06:18 -0400170 case kARGB_4444_SkColorType:
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800171 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA,
172 GL_UNSIGNED_SHORT_4_4_4_4, p);
173 break;
Mike Reed42a1d082014-07-07 18:06:18 -0400174 case kN32_SkColorType:
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800175 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA,
176 GL_UNSIGNED_BYTE, p);
177 break;
Mike Reed42a1d082014-07-07 18:06:18 -0400178 case kRGB_565_SkColorType:
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800179 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, w, h, 0, GL_RGB,
180 GL_UNSIGNED_SHORT_5_6_5, p);
181 break;
182 default:
183 break;
184 }
185
186 glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES, crop);
187 glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
188 glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
189 glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
190 glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
Damien Bargiacchi0e3d2ab2016-08-29 04:11:19 -0700191
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800192 return NO_ERROR;
193}
194
Damien Bargiacchi0e3d2ab2016-08-29 04:11:19 -0700195status_t BootAnimation::initTexture(FileMap* map, int* width, int* height)
Mathias Agopiana8826d62009-10-01 03:10:14 -0700196{
Mathias Agopiana8826d62009-10-01 03:10:14 -0700197 SkBitmap bitmap;
Damien Bargiacchif67b3172016-09-07 20:17:14 -0700198 sk_sp<SkData> data = SkData::MakeWithoutCopy(map->getDataPtr(),
199 map->getDataLength());
Matt Sarett8898c162016-03-24 16:11:01 -0400200 sk_sp<SkImage> image = SkImage::MakeFromEncoded(data);
201 image->asLegacyBitmap(&bitmap, SkImage::kRO_LegacyBitmapMode);
Mathias Agopiana8826d62009-10-01 03:10:14 -0700202
Mykola Kondratenko0c1eeb32014-04-15 09:35:44 +0200203 // FileMap memory is never released until application exit.
204 // Release it now as the texture is already loaded and the memory used for
205 // the packed resource can be released.
Damien Bargiacchi0e3d2ab2016-08-29 04:11:19 -0700206 delete map;
Mykola Kondratenko0c1eeb32014-04-15 09:35:44 +0200207
Mathias Agopiana8826d62009-10-01 03:10:14 -0700208 // ensure we can call getPixels(). No need to call unlock, since the
209 // bitmap will go out of scope when we return from this method.
210 bitmap.lockPixels();
211
212 const int w = bitmap.width();
213 const int h = bitmap.height();
214 const void* p = bitmap.getPixels();
215
216 GLint crop[4] = { 0, h, w, -h };
217 int tw = 1 << (31 - __builtin_clz(w));
218 int th = 1 << (31 - __builtin_clz(h));
219 if (tw < w) tw <<= 1;
220 if (th < h) th <<= 1;
221
Mike Reed42a1d082014-07-07 18:06:18 -0400222 switch (bitmap.colorType()) {
223 case kN32_SkColorType:
Sai Kiran Korwar27167492015-07-07 20:00:06 +0530224 if (!mUseNpotTextures && (tw != w || th != h)) {
Mathias Agopiana8826d62009-10-01 03:10:14 -0700225 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, tw, th, 0, GL_RGBA,
226 GL_UNSIGNED_BYTE, 0);
227 glTexSubImage2D(GL_TEXTURE_2D, 0,
228 0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, p);
229 } else {
Sai Kiran Korwar27167492015-07-07 20:00:06 +0530230 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA,
Mathias Agopiana8826d62009-10-01 03:10:14 -0700231 GL_UNSIGNED_BYTE, p);
232 }
233 break;
234
Mike Reed42a1d082014-07-07 18:06:18 -0400235 case kRGB_565_SkColorType:
Sai Kiran Korwar27167492015-07-07 20:00:06 +0530236 if (!mUseNpotTextures && (tw != w || th != h)) {
Mathias Agopiana8826d62009-10-01 03:10:14 -0700237 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, tw, th, 0, GL_RGB,
238 GL_UNSIGNED_SHORT_5_6_5, 0);
239 glTexSubImage2D(GL_TEXTURE_2D, 0,
240 0, 0, w, h, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, p);
241 } else {
Sai Kiran Korwar27167492015-07-07 20:00:06 +0530242 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, w, h, 0, GL_RGB,
Mathias Agopiana8826d62009-10-01 03:10:14 -0700243 GL_UNSIGNED_SHORT_5_6_5, p);
244 }
245 break;
246 default:
247 break;
248 }
249
250 glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES, crop);
251
Damien Bargiacchi0e3d2ab2016-08-29 04:11:19 -0700252 *width = w;
253 *height = h;
254
Mathias Agopiana8826d62009-10-01 03:10:14 -0700255 return NO_ERROR;
256}
257
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800258status_t BootAnimation::readyToRun() {
259 mAssets.addDefaultAssets();
260
Jeff Brown0b722fe2012-08-24 22:40:14 -0700261 sp<IBinder> dtoken(SurfaceComposerClient::getBuiltInDisplay(
262 ISurfaceComposer::eDisplayIdMain));
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800263 DisplayInfo dinfo;
Jeff Brown0b722fe2012-08-24 22:40:14 -0700264 status_t status = SurfaceComposerClient::getDisplayInfo(dtoken, &dinfo);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800265 if (status)
266 return -1;
267
268 // create the native surface
Jeff Brown0b722fe2012-08-24 22:40:14 -0700269 sp<SurfaceControl> control = session()->createSurface(String8("BootAnimation"),
270 dinfo.w, dinfo.h, PIXEL_FORMAT_RGB_565);
Mathias Agopian439863f2011-06-28 19:09:31 -0700271
272 SurfaceComposerClient::openGlobalTransaction();
Mathias Agopian17f638b2009-04-16 20:04:08 -0700273 control->setLayer(0x40000000);
Mathias Agopian439863f2011-06-28 19:09:31 -0700274 SurfaceComposerClient::closeGlobalTransaction();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800275
Mathias Agopian17f638b2009-04-16 20:04:08 -0700276 sp<Surface> s = control->getSurface();
277
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800278 // initialize opengl and egl
Mathias Agopian738b9a42009-08-06 16:41:02 -0700279 const EGLint attribs[] = {
Mathias Agopian1b253b72011-08-15 15:20:22 -0700280 EGL_RED_SIZE, 8,
281 EGL_GREEN_SIZE, 8,
282 EGL_BLUE_SIZE, 8,
Mathias Agopiana8826d62009-10-01 03:10:14 -0700283 EGL_DEPTH_SIZE, 0,
284 EGL_NONE
Mathias Agopian738b9a42009-08-06 16:41:02 -0700285 };
Andreas Gampecfedceb2014-09-30 21:48:18 -0700286 EGLint w, h;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800287 EGLint numConfigs;
288 EGLConfig config;
289 EGLSurface surface;
290 EGLContext context;
Mathias Agopian627e7b52009-05-21 19:21:59 -0700291
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800292 EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
Mathias Agopian627e7b52009-05-21 19:21:59 -0700293
294 eglInitialize(display, 0, 0);
Mathias Agopian1b253b72011-08-15 15:20:22 -0700295 eglChooseConfig(display, attribs, &config, 1, &numConfigs);
Mathias Agopian1473f462009-04-10 14:24:30 -0700296 surface = eglCreateWindowSurface(display, config, s.get(), NULL);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800297 context = eglCreateContext(display, config, NULL, NULL);
298 eglQuerySurface(display, surface, EGL_WIDTH, &w);
299 eglQuerySurface(display, surface, EGL_HEIGHT, &h);
Mathias Agopiana8826d62009-10-01 03:10:14 -0700300
Mathias Agopianabac0102009-07-31 14:47:00 -0700301 if (eglMakeCurrent(display, surface, surface, context) == EGL_FALSE)
302 return NO_INIT;
Mathias Agopiana8826d62009-10-01 03:10:14 -0700303
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800304 mDisplay = display;
305 mContext = context;
306 mSurface = surface;
307 mWidth = w;
308 mHeight = h;
Mathias Agopian17f638b2009-04-16 20:04:08 -0700309 mFlingerSurfaceControl = control;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800310 mFlingerSurface = s;
311
Elliott Hughesc367d482013-10-29 13:12:55 -0700312 // If the device has encryption turned on or is in process
Jason parksbd9a08d2011-01-31 15:04:34 -0600313 // of being encrypted we show the encrypted boot animation.
314 char decrypt[PROPERTY_VALUE_MAX];
315 property_get("vold.decrypt", decrypt, "");
316
317 bool encryptedAnimation = atoi(decrypt) != 0 || !strcmp("trigger_restart_min_framework", decrypt);
318
Andriy Naborskyy39218ba2015-08-16 21:32:50 -0700319 if (encryptedAnimation && (access(SYSTEM_ENCRYPTED_BOOTANIMATION_FILE, R_OK) == 0)) {
320 mZipFileName = SYSTEM_ENCRYPTED_BOOTANIMATION_FILE;
Jason parksbd9a08d2011-01-31 15:04:34 -0600321 }
Andriy Naborskyy39218ba2015-08-16 21:32:50 -0700322 else if (access(OEM_BOOTANIMATION_FILE, R_OK) == 0) {
323 mZipFileName = OEM_BOOTANIMATION_FILE;
324 }
325 else if (access(SYSTEM_BOOTANIMATION_FILE, R_OK) == 0) {
326 mZipFileName = SYSTEM_BOOTANIMATION_FILE;
327 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800328 return NO_ERROR;
329}
330
Mathias Agopiana8826d62009-10-01 03:10:14 -0700331bool BootAnimation::threadLoop()
332{
333 bool r;
Narayan Kamathafd31e02013-12-03 13:16:03 +0000334 // We have no bootanimation file, so we use the stock android logo
335 // animation.
Andriy Naborskyy39218ba2015-08-16 21:32:50 -0700336 if (mZipFileName.isEmpty()) {
Mathias Agopiana8826d62009-10-01 03:10:14 -0700337 r = android();
338 } else {
339 r = movie();
340 }
341
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800342 eglMakeCurrent(mDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
343 eglDestroyContext(mDisplay, mContext);
344 eglDestroySurface(mDisplay, mSurface);
Mathias Agopian6cf0db22009-04-17 19:36:26 -0700345 mFlingerSurface.clear();
Mathias Agopian17f638b2009-04-16 20:04:08 -0700346 mFlingerSurfaceControl.clear();
Mathias Agopian627e7b52009-05-21 19:21:59 -0700347 eglTerminate(mDisplay);
Sai Kiran Korwar3eee9fb2015-06-16 17:13:35 +0530348 eglReleaseThread();
Mathias Agopian627e7b52009-05-21 19:21:59 -0700349 IPCThreadState::self()->stopProcess();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800350 return r;
351}
352
Mathias Agopiana8826d62009-10-01 03:10:14 -0700353bool BootAnimation::android()
354{
Wei Wanga90c54c2017-02-02 11:35:21 -0800355 ALOGD("BootAnimationShownTiming: BootAnimation start time: %" PRId64 "ms", elapsedRealtime());
Mathias Agopianb2cf9542009-03-24 18:34:16 -0700356 initTexture(&mAndroid[0], mAssets, "images/android-logo-mask.png");
357 initTexture(&mAndroid[1], mAssets, "images/android-logo-shine.png");
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800358
359 // clear screen
Mathias Agopiana8826d62009-10-01 03:10:14 -0700360 glShadeModel(GL_FLAT);
Mathias Agopianb2cf9542009-03-24 18:34:16 -0700361 glDisable(GL_DITHER);
362 glDisable(GL_SCISSOR_TEST);
Mathias Agopian59f19e42011-05-06 19:22:12 -0700363 glClearColor(0,0,0,1);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800364 glClear(GL_COLOR_BUFFER_BIT);
365 eglSwapBuffers(mDisplay, mSurface);
366
Mathias Agopiana8826d62009-10-01 03:10:14 -0700367 glEnable(GL_TEXTURE_2D);
368 glTexEnvx(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
369
Mathias Agopianb2cf9542009-03-24 18:34:16 -0700370 const GLint xc = (mWidth - mAndroid[0].w) / 2;
371 const GLint yc = (mHeight - mAndroid[0].h) / 2;
372 const Rect updateRect(xc, yc, xc + mAndroid[0].w, yc + mAndroid[0].h);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800373
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800374 glScissor(updateRect.left, mHeight - updateRect.bottom, updateRect.width(),
375 updateRect.height());
376
Mathias Agopianb2cf9542009-03-24 18:34:16 -0700377 // Blend state
378 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
379 glTexEnvx(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
380
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800381 const nsecs_t startTime = systemTime();
382 do {
Mathias Agopian13796652009-03-24 22:49:21 -0700383 nsecs_t now = systemTime();
384 double time = now - startTime;
Mathias Agopianb2cf9542009-03-24 18:34:16 -0700385 float t = 4.0f * float(time / us2ns(16667)) / mAndroid[1].w;
386 GLint offset = (1 - (t - floorf(t))) * mAndroid[1].w;
387 GLint x = xc - offset;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800388
Mathias Agopian81668642009-07-28 11:41:30 -0700389 glDisable(GL_SCISSOR_TEST);
390 glClear(GL_COLOR_BUFFER_BIT);
391
392 glEnable(GL_SCISSOR_TEST);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800393 glDisable(GL_BLEND);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800394 glBindTexture(GL_TEXTURE_2D, mAndroid[1].name);
Mathias Agopianb2cf9542009-03-24 18:34:16 -0700395 glDrawTexiOES(x, yc, 0, mAndroid[1].w, mAndroid[1].h);
396 glDrawTexiOES(x + mAndroid[1].w, yc, 0, mAndroid[1].w, mAndroid[1].h);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800397
Mathias Agopianb2cf9542009-03-24 18:34:16 -0700398 glEnable(GL_BLEND);
399 glBindTexture(GL_TEXTURE_2D, mAndroid[0].name);
400 glDrawTexiOES(xc, yc, 0, mAndroid[0].w, mAndroid[0].h);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800401
Mathias Agopian627e7b52009-05-21 19:21:59 -0700402 EGLBoolean res = eglSwapBuffers(mDisplay, mSurface);
403 if (res == EGL_FALSE)
404 break;
405
Mathias Agopian13796652009-03-24 22:49:21 -0700406 // 12fps: don't animate too fast to preserve CPU
407 const nsecs_t sleepTime = 83333 - ns2us(systemTime() - now);
408 if (sleepTime > 0)
Mathias Agopiana8826d62009-10-01 03:10:14 -0700409 usleep(sleepTime);
Kevin Hesterd3782b22012-04-26 10:38:55 -0700410
411 checkExit();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800412 } while (!exitPending());
413
414 glDeleteTextures(1, &mAndroid[0].name);
415 glDeleteTextures(1, &mAndroid[1].name);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800416 return false;
417}
418
Kevin Hesterd3782b22012-04-26 10:38:55 -0700419void BootAnimation::checkExit() {
420 // Allow surface flinger to gracefully request shutdown
421 char value[PROPERTY_VALUE_MAX];
422 property_get(EXIT_PROP_NAME, value, "0");
423 int exitnow = atoi(value);
424 if (exitnow) {
425 requestExit();
426 }
427}
428
Damien Bargiacchi0e3d2ab2016-08-29 04:11:19 -0700429bool BootAnimation::validClock(const Animation::Part& part) {
430 return part.clockPosX != TEXT_MISSING_VALUE && part.clockPosY != TEXT_MISSING_VALUE;
431}
432
433bool parseTextCoord(const char* str, int* dest) {
434 if (strcmp("c", str) == 0) {
435 *dest = TEXT_CENTER_VALUE;
436 return true;
437 }
438
439 char* end;
440 int val = (int) strtol(str, &end, 0);
441 if (end == str || *end != '\0' || val == INT_MAX || val == INT_MIN) {
442 return false;
443 }
444 *dest = val;
445 return true;
446}
447
448// Parse two position coordinates. If only string is non-empty, treat it as the y value.
449void parsePosition(const char* str1, const char* str2, int* x, int* y) {
450 bool success = false;
451 if (strlen(str1) == 0) { // No values were specified
452 // success = false
453 } else if (strlen(str2) == 0) { // we have only one value
454 if (parseTextCoord(str1, y)) {
455 *x = TEXT_CENTER_VALUE;
456 success = true;
457 }
458 } else {
459 if (parseTextCoord(str1, x) && parseTextCoord(str2, y)) {
460 success = true;
461 }
462 }
463
464 if (!success) {
465 *x = TEXT_MISSING_VALUE;
466 *y = TEXT_MISSING_VALUE;
467 }
468}
469
Jesse Hall083b84c2014-09-22 10:51:09 -0700470// Parse a color represented as an HTML-style 'RRGGBB' string: each pair of
471// characters in str is a hex number in [0, 255], which are converted to
472// floating point values in the range [0.0, 1.0] and placed in the
473// corresponding elements of color.
474//
475// If the input string isn't valid, parseColor returns false and color is
476// left unchanged.
477static bool parseColor(const char str[7], float color[3]) {
478 float tmpColor[3];
479 for (int i = 0; i < 3; i++) {
480 int val = 0;
481 for (int j = 0; j < 2; j++) {
482 val *= 16;
483 char c = str[2*i + j];
484 if (c >= '0' && c <= '9') val += c - '0';
485 else if (c >= 'A' && c <= 'F') val += (c - 'A') + 10;
486 else if (c >= 'a' && c <= 'f') val += (c - 'a') + 10;
487 else return false;
488 }
489 tmpColor[i] = static_cast<float>(val) / 255.0f;
490 }
491 memcpy(color, tmpColor, sizeof(tmpColor));
492 return true;
493}
494
Andriy Naborskyy39218ba2015-08-16 21:32:50 -0700495
496static bool readFile(ZipFileRO* zip, const char* name, String8& outString)
Mike Lockwoodebf9a0d2014-10-02 16:08:47 -0700497{
Andriy Naborskyy39218ba2015-08-16 21:32:50 -0700498 ZipEntryRO entry = zip->findEntryByName(name);
Mike Lockwoodebf9a0d2014-10-02 16:08:47 -0700499 ALOGE_IF(!entry, "couldn't find %s", name);
500 if (!entry) {
501 return false;
502 }
503
Andriy Naborskyy39218ba2015-08-16 21:32:50 -0700504 FileMap* entryMap = zip->createEntryFileMap(entry);
505 zip->releaseEntry(entry);
Mike Lockwoodebf9a0d2014-10-02 16:08:47 -0700506 ALOGE_IF(!entryMap, "entryMap is null");
507 if (!entryMap) {
508 return false;
509 }
510
511 outString.setTo((char const*)entryMap->getDataPtr(), entryMap->getDataLength());
Narayan Kamath688ff4c2015-02-23 15:47:54 +0000512 delete entryMap;
Mike Lockwoodebf9a0d2014-10-02 16:08:47 -0700513 return true;
514}
515
Damien Bargiacchi0e3d2ab2016-08-29 04:11:19 -0700516// The font image should be a 96x2 array of character images. The
517// columns are the printable ASCII characters 0x20 - 0x7f. The
518// top row is regular text; the bottom row is bold.
519status_t BootAnimation::initFont(Font* font, const char* fallback) {
520 status_t status = NO_ERROR;
Damien Bargiacchia704b7d2016-02-16 16:55:49 -0800521
Damien Bargiacchi0e3d2ab2016-08-29 04:11:19 -0700522 if (font->map != nullptr) {
523 glGenTextures(1, &font->texture.name);
524 glBindTexture(GL_TEXTURE_2D, font->texture.name);
Damien Bargiacchia704b7d2016-02-16 16:55:49 -0800525
Damien Bargiacchi0e3d2ab2016-08-29 04:11:19 -0700526 status = initTexture(font->map, &font->texture.w, &font->texture.h);
527
528 glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
529 glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
530 glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
531 glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
532 } else if (fallback != nullptr) {
533 status = initTexture(&font->texture, mAssets, fallback);
534 } else {
535 return NO_INIT;
Damien Bargiacchia704b7d2016-02-16 16:55:49 -0800536 }
537
Damien Bargiacchi0e3d2ab2016-08-29 04:11:19 -0700538 if (status == NO_ERROR) {
539 font->char_width = font->texture.w / FONT_NUM_COLS;
540 font->char_height = font->texture.h / FONT_NUM_ROWS / 2; // There are bold and regular rows
541 }
542
543 return status;
544}
545
546void BootAnimation::drawText(const char* str, const Font& font, bool bold, int* x, int* y) {
547 glEnable(GL_BLEND); // Allow us to draw on top of the animation
548 glBindTexture(GL_TEXTURE_2D, font.texture.name);
549
550 const int len = strlen(str);
551 const int strWidth = font.char_width * len;
552
553 if (*x == TEXT_CENTER_VALUE) {
554 *x = (mWidth - strWidth) / 2;
555 } else if (*x < 0) {
556 *x = mWidth + *x - strWidth;
557 }
558 if (*y == TEXT_CENTER_VALUE) {
559 *y = (mHeight - font.char_height) / 2;
560 } else if (*y < 0) {
561 *y = mHeight + *y - font.char_height;
562 }
563
564 int cropRect[4] = { 0, 0, font.char_width, -font.char_height };
565
566 for (int i = 0; i < len; i++) {
567 char c = str[i];
568
569 if (c < FONT_BEGIN_CHAR || c > FONT_END_CHAR) {
570 c = '?';
571 }
572
573 // Crop the texture to only the pixels in the current glyph
574 const int charPos = (c - FONT_BEGIN_CHAR); // Position in the list of valid characters
575 const int row = charPos / FONT_NUM_COLS;
576 const int col = charPos % FONT_NUM_COLS;
577 cropRect[0] = col * font.char_width; // Left of column
578 cropRect[1] = row * font.char_height * 2; // Top of row
579 // Move down to bottom of regular (one char_heigh) or bold (two char_heigh) line
580 cropRect[1] += bold ? 2 * font.char_height : font.char_height;
581 glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES, cropRect);
582
583 glDrawTexiOES(*x, *y, 0, font.char_width, font.char_height);
584
585 *x += font.char_width;
586 }
587
588 glDisable(GL_BLEND); // Return to the animation's default behaviour
589 glBindTexture(GL_TEXTURE_2D, 0);
590}
591
Damien Bargiacchi9071db12016-10-28 17:38:22 -0700592// We render 12 or 24 hour time.
Damien Bargiacchi0e3d2ab2016-08-29 04:11:19 -0700593void BootAnimation::drawClock(const Font& font, const int xPos, const int yPos) {
Damien Bargiacchi9071db12016-10-28 17:38:22 -0700594 static constexpr char TIME_FORMAT_12[] = "%l:%M";
595 static constexpr char TIME_FORMAT_24[] = "%H:%M";
Damien Bargiacchi0e3d2ab2016-08-29 04:11:19 -0700596 static constexpr int TIME_LENGTH = 6;
597
Damien Bargiacchia704b7d2016-02-16 16:55:49 -0800598 time_t rawtime;
599 time(&rawtime);
600 struct tm* timeInfo = localtime(&rawtime);
601
602 char timeBuff[TIME_LENGTH];
Damien Bargiacchi9071db12016-10-28 17:38:22 -0700603 const char* timeFormat = mTimeFormat12Hour ? TIME_FORMAT_12 : TIME_FORMAT_24;
604 size_t length = strftime(timeBuff, TIME_LENGTH, timeFormat, timeInfo);
Damien Bargiacchia704b7d2016-02-16 16:55:49 -0800605
606 if (length != TIME_LENGTH - 1) {
607 ALOGE("Couldn't format time; abandoning boot animation clock");
608 mClockEnabled = false;
609 return;
610 }
611
Damien Bargiacchi45a76442016-12-05 18:02:18 -0800612 char* out = timeBuff[0] == ' ' ? &timeBuff[1] : &timeBuff[0];
Damien Bargiacchi0e3d2ab2016-08-29 04:11:19 -0700613 int x = xPos;
614 int y = yPos;
Damien Bargiacchi45a76442016-12-05 18:02:18 -0800615 drawText(out, font, false, &x, &y);
Damien Bargiacchia704b7d2016-02-16 16:55:49 -0800616}
617
Andriy Naborskyy39218ba2015-08-16 21:32:50 -0700618bool BootAnimation::parseAnimationDesc(Animation& animation)
Mathias Agopiana8826d62009-10-01 03:10:14 -0700619{
Mike Lockwoodebf9a0d2014-10-02 16:08:47 -0700620 String8 desString;
621
Andriy Naborskyy39218ba2015-08-16 21:32:50 -0700622 if (!readFile(animation.zip, "desc.txt", desString)) {
Narayan Kamathafd31e02013-12-03 13:16:03 +0000623 return false;
624 }
Mathias Agopiana8826d62009-10-01 03:10:14 -0700625 char const* s = desString.string();
626
Mathias Agopiana8826d62009-10-01 03:10:14 -0700627 // Parse the description file
628 for (;;) {
629 const char* endl = strstr(s, "\n");
Andreas Gampecfedceb2014-09-30 21:48:18 -0700630 if (endl == NULL) break;
Mathias Agopiana8826d62009-10-01 03:10:14 -0700631 String8 line(s, endl - s);
632 const char* l = line.string();
Damien Bargiacchia704b7d2016-02-16 16:55:49 -0800633 int fps = 0;
634 int width = 0;
635 int height = 0;
636 int count = 0;
637 int pause = 0;
Narayan Kamathafd31e02013-12-03 13:16:03 +0000638 char path[ANIM_ENTRY_NAME_MAX];
Jesse Hall083b84c2014-09-22 10:51:09 -0700639 char color[7] = "000000"; // default to black if unspecified
Damien Bargiacchi0e3d2ab2016-08-29 04:11:19 -0700640 char clockPos1[TEXT_POS_LEN_MAX + 1] = "";
641 char clockPos2[TEXT_POS_LEN_MAX + 1] = "";
Jesse Hall083b84c2014-09-22 10:51:09 -0700642
Kevin Hesterd3782b22012-04-26 10:38:55 -0700643 char pathType;
Mathias Agopiana8826d62009-10-01 03:10:14 -0700644 if (sscanf(l, "%d %d %d", &width, &height, &fps) == 3) {
Jesse Hall083b84c2014-09-22 10:51:09 -0700645 // ALOGD("> w=%d, h=%d, fps=%d", width, height, fps);
Mathias Agopiana8826d62009-10-01 03:10:14 -0700646 animation.width = width;
647 animation.height = height;
648 animation.fps = fps;
Damien Bargiacchi0e3d2ab2016-08-29 04:11:19 -0700649 } else if (sscanf(l, " %c %d %d %s #%6s %16s %16s",
650 &pathType, &count, &pause, path, color, clockPos1, clockPos2) >= 4) {
651 //ALOGD("> type=%c, count=%d, pause=%d, path=%s, color=%s, clockPos1=%s, clockPos2=%s",
652 // pathType, count, pause, path, color, clockPos1, clockPos2);
Mathias Agopiana8826d62009-10-01 03:10:14 -0700653 Animation::Part part;
Kevin Hesterd3782b22012-04-26 10:38:55 -0700654 part.playUntilComplete = pathType == 'c';
Mathias Agopiana8826d62009-10-01 03:10:14 -0700655 part.count = count;
656 part.pause = pause;
657 part.path = path;
Geoffrey Pitschd6d9a1d2016-06-08 00:38:58 -0700658 part.audioData = NULL;
Andriy Naborskyy39218ba2015-08-16 21:32:50 -0700659 part.animation = NULL;
Jesse Hall083b84c2014-09-22 10:51:09 -0700660 if (!parseColor(color, part.backgroundColor)) {
661 ALOGE("> invalid color '#%s'", color);
662 part.backgroundColor[0] = 0.0f;
663 part.backgroundColor[1] = 0.0f;
664 part.backgroundColor[2] = 0.0f;
665 }
Damien Bargiacchi0e3d2ab2016-08-29 04:11:19 -0700666 parsePosition(clockPos1, clockPos2, &part.clockPosX, &part.clockPosY);
Mathias Agopiana8826d62009-10-01 03:10:14 -0700667 animation.parts.add(part);
668 }
Andriy Naborskyy39218ba2015-08-16 21:32:50 -0700669 else if (strcmp(l, "$SYSTEM") == 0) {
670 // ALOGD("> SYSTEM");
671 Animation::Part part;
672 part.playUntilComplete = false;
673 part.count = 1;
674 part.pause = 0;
Geoffrey Pitschd6d9a1d2016-06-08 00:38:58 -0700675 part.audioData = NULL;
Andriy Naborskyy39218ba2015-08-16 21:32:50 -0700676 part.animation = loadAnimation(String8(SYSTEM_BOOTANIMATION_FILE));
677 if (part.animation != NULL)
678 animation.parts.add(part);
679 }
Mathias Agopiana8826d62009-10-01 03:10:14 -0700680 s = ++endl;
681 }
682
Andriy Naborskyy39218ba2015-08-16 21:32:50 -0700683 return true;
684}
685
686bool BootAnimation::preloadZip(Animation& animation)
687{
Mathias Agopiana8826d62009-10-01 03:10:14 -0700688 // read all the data structures
689 const size_t pcount = animation.parts.size();
Narayan Kamathafd31e02013-12-03 13:16:03 +0000690 void *cookie = NULL;
Geoffrey Pitschdd214a72016-06-27 17:14:30 -0400691 ZipFileRO* zip = animation.zip;
692 if (!zip->startIteration(&cookie)) {
Narayan Kamathafd31e02013-12-03 13:16:03 +0000693 return false;
694 }
695
Geoffrey Pitscha91a2d72016-07-12 14:46:19 -0400696 Animation::Part* partWithAudio = NULL;
Narayan Kamathafd31e02013-12-03 13:16:03 +0000697 ZipEntryRO entry;
698 char name[ANIM_ENTRY_NAME_MAX];
Geoffrey Pitschdd214a72016-06-27 17:14:30 -0400699 while ((entry = zip->nextEntry(cookie)) != NULL) {
700 const int foundEntryName = zip->getEntryFileName(entry, name, ANIM_ENTRY_NAME_MAX);
Narayan Kamathafd31e02013-12-03 13:16:03 +0000701 if (foundEntryName > ANIM_ENTRY_NAME_MAX || foundEntryName == -1) {
702 ALOGE("Error fetching entry file name");
703 continue;
704 }
705
706 const String8 entryName(name);
707 const String8 path(entryName.getPathDir());
708 const String8 leaf(entryName.getPathLeaf());
709 if (leaf.size() > 0) {
Damien Bargiacchi0e3d2ab2016-08-29 04:11:19 -0700710 if (entryName == CLOCK_FONT_ZIP_NAME) {
711 FileMap* map = zip->createEntryFileMap(entry);
712 if (map) {
713 animation.clockFont.map = map;
714 }
715 continue;
716 }
717
Geoffrey Pitschdd214a72016-06-27 17:14:30 -0400718 for (size_t j = 0; j < pcount; j++) {
Narayan Kamathafd31e02013-12-03 13:16:03 +0000719 if (path == animation.parts[j].path) {
Narayan Kamath4600dd02015-06-16 12:02:57 +0100720 uint16_t method;
Narayan Kamathafd31e02013-12-03 13:16:03 +0000721 // supports only stored png files
Geoffrey Pitschdd214a72016-06-27 17:14:30 -0400722 if (zip->getEntryInfo(entry, &method, NULL, NULL, NULL, NULL, NULL)) {
Narayan Kamathafd31e02013-12-03 13:16:03 +0000723 if (method == ZipFileRO::kCompressStored) {
Geoffrey Pitschdd214a72016-06-27 17:14:30 -0400724 FileMap* map = zip->createEntryFileMap(entry);
Narayan Kamathafd31e02013-12-03 13:16:03 +0000725 if (map) {
Narayan Kamathafd31e02013-12-03 13:16:03 +0000726 Animation::Part& part(animation.parts.editItemAt(j));
Mike Lockwoodebf9a0d2014-10-02 16:08:47 -0700727 if (leaf == "audio.wav") {
728 // a part may have at most one audio file
Geoffrey Pitschd6d9a1d2016-06-08 00:38:58 -0700729 part.audioData = (uint8_t *)map->getDataPtr();
730 part.audioLength = map->getDataLength();
Geoffrey Pitscha91a2d72016-07-12 14:46:19 -0400731 partWithAudio = &part;
Geoffrey Pitschdd214a72016-06-27 17:14:30 -0400732 } else if (leaf == "trim.txt") {
733 part.trimData.setTo((char const*)map->getDataPtr(),
734 map->getDataLength());
Mike Lockwoodebf9a0d2014-10-02 16:08:47 -0700735 } else {
736 Animation::Frame frame;
737 frame.name = leaf;
738 frame.map = map;
Geoffrey Pitschdd214a72016-06-27 17:14:30 -0400739 frame.trimWidth = animation.width;
740 frame.trimHeight = animation.height;
741 frame.trimX = 0;
742 frame.trimY = 0;
Mike Lockwoodebf9a0d2014-10-02 16:08:47 -0700743 part.frames.add(frame);
744 }
Mathias Agopiana8826d62009-10-01 03:10:14 -0700745 }
Geoffrey Pitschd6d9a1d2016-06-08 00:38:58 -0700746 } else {
747 ALOGE("bootanimation.zip is compressed; must be only stored");
Mathias Agopiana8826d62009-10-01 03:10:14 -0700748 }
749 }
750 }
751 }
752 }
753 }
754
Geoffrey Pitschdd214a72016-06-27 17:14:30 -0400755 // If there is trimData present, override the positioning defaults.
756 for (Animation::Part& part : animation.parts) {
757 const char* trimDataStr = part.trimData.string();
758 for (size_t frameIdx = 0; frameIdx < part.frames.size(); frameIdx++) {
759 const char* endl = strstr(trimDataStr, "\n");
760 // No more trimData for this part.
761 if (endl == NULL) {
762 break;
763 }
764 String8 line(trimDataStr, endl - trimDataStr);
765 const char* lineStr = line.string();
766 trimDataStr = ++endl;
767 int width = 0, height = 0, x = 0, y = 0;
768 if (sscanf(lineStr, "%dx%d+%d+%d", &width, &height, &x, &y) == 4) {
769 Animation::Frame& frame(part.frames.editItemAt(frameIdx));
770 frame.trimWidth = width;
771 frame.trimHeight = height;
772 frame.trimX = x;
773 frame.trimY = y;
774 } else {
775 ALOGE("Error parsing trim.txt, line: %s", lineStr);
776 break;
777 }
778 }
779 }
780
Geoffrey Pitschd6d9a1d2016-06-08 00:38:58 -0700781 // Create and initialize audioplay if there is a wav file in any of the animations.
Geoffrey Pitscha9173532016-07-19 14:56:39 -0400782 // Do it on a separate thread so we don't hold up the animation intro.
Geoffrey Pitscha91a2d72016-07-12 14:46:19 -0400783 if (partWithAudio != NULL) {
Geoffrey Pitschd6d9a1d2016-06-08 00:38:58 -0700784 ALOGD("found audio.wav, creating playback engine");
Geoffrey Pitscha9173532016-07-19 14:56:39 -0400785 mInitAudioThread = new InitAudioThread(partWithAudio->audioData,
786 partWithAudio->audioLength);
787 mInitAudioThread->run("BootAnimation::InitAudioThread", PRIORITY_NORMAL);
Geoffrey Pitschd6d9a1d2016-06-08 00:38:58 -0700788 }
789
Geoffrey Pitschdd214a72016-06-27 17:14:30 -0400790 zip->endIteration(cookie);
Narayan Kamathafd31e02013-12-03 13:16:03 +0000791
Andriy Naborskyy39218ba2015-08-16 21:32:50 -0700792 return true;
793}
794
795bool BootAnimation::movie()
796{
Andriy Naborskyy39218ba2015-08-16 21:32:50 -0700797 Animation* animation = loadAnimation(mZipFileName);
798 if (animation == NULL)
799 return false;
800
Damien Bargiacchi97480862016-03-29 14:55:55 -0700801 bool anyPartHasClock = false;
802 for (size_t i=0; i < animation->parts.size(); i++) {
Damien Bargiacchi0e3d2ab2016-08-29 04:11:19 -0700803 if(validClock(animation->parts[i])) {
Damien Bargiacchi97480862016-03-29 14:55:55 -0700804 anyPartHasClock = true;
805 break;
806 }
807 }
808 if (!anyPartHasClock) {
809 mClockEnabled = false;
810 }
811
Sai Kiran Korwar27167492015-07-07 20:00:06 +0530812 // Check if npot textures are supported
813 mUseNpotTextures = false;
814 String8 gl_extensions;
815 const char* exts = reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS));
816 if (!exts) {
817 glGetError();
818 } else {
819 gl_extensions.setTo(exts);
820 if ((gl_extensions.find("GL_ARB_texture_non_power_of_two") != -1) ||
821 (gl_extensions.find("GL_OES_texture_npot") != -1)) {
822 mUseNpotTextures = true;
823 }
824 }
825
Damien Bargiacchia704b7d2016-02-16 16:55:49 -0800826 // Blend required to draw time on top of animation frames.
827 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
Mathias Agopiana8826d62009-10-01 03:10:14 -0700828 glShadeModel(GL_FLAT);
829 glDisable(GL_DITHER);
830 glDisable(GL_SCISSOR_TEST);
831 glDisable(GL_BLEND);
Mathias Agopiana8826d62009-10-01 03:10:14 -0700832
833 glBindTexture(GL_TEXTURE_2D, 0);
834 glEnable(GL_TEXTURE_2D);
835 glTexEnvx(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
836 glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
837 glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
838 glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
839 glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
840
Damien Bargiacchi0e3d2ab2016-08-29 04:11:19 -0700841 bool clockFontInitialized = false;
Damien Bargiacchia704b7d2016-02-16 16:55:49 -0800842 if (mClockEnabled) {
Damien Bargiacchi0e3d2ab2016-08-29 04:11:19 -0700843 clockFontInitialized =
844 (initFont(&animation->clockFont, CLOCK_FONT_ASSET) == NO_ERROR);
845 mClockEnabled = clockFontInitialized;
Damien Bargiacchia704b7d2016-02-16 16:55:49 -0800846 }
847
Damien Bargiacchi97480862016-03-29 14:55:55 -0700848 if (mClockEnabled && !updateIsTimeAccurate()) {
849 mTimeCheckThread = new TimeCheckThread(this);
850 mTimeCheckThread->run("BootAnimation::TimeCheckThread", PRIORITY_NORMAL);
851 }
852
Andriy Naborskyy39218ba2015-08-16 21:32:50 -0700853 playAnimation(*animation);
Damien Bargiacchi97480862016-03-29 14:55:55 -0700854
Geoffrey Pitscha9173532016-07-19 14:56:39 -0400855 if (mTimeCheckThread != nullptr) {
Damien Bargiacchi97480862016-03-29 14:55:55 -0700856 mTimeCheckThread->requestExit();
Geoffrey Pitscha9173532016-07-19 14:56:39 -0400857 mTimeCheckThread = nullptr;
858 }
859
Wei Wanga90c54c2017-02-02 11:35:21 -0800860 // We should have joined mInitAudioThread thread in playAnimation
Geoffrey Pitscha9173532016-07-19 14:56:39 -0400861 if (mInitAudioThread != nullptr) {
Geoffrey Pitscha9173532016-07-19 14:56:39 -0400862 mInitAudioThread = nullptr;
Damien Bargiacchi97480862016-03-29 14:55:55 -0700863 }
864
Andriy Naborskyy39218ba2015-08-16 21:32:50 -0700865 releaseAnimation(animation);
866
Damien Bargiacchi0e3d2ab2016-08-29 04:11:19 -0700867 if (clockFontInitialized) {
868 glDeleteTextures(1, &animation->clockFont.texture.name);
Andriy Naborskyy815e51d2016-03-24 16:43:34 -0700869 }
870
Andriy Naborskyy39218ba2015-08-16 21:32:50 -0700871 return false;
872}
873
874bool BootAnimation::playAnimation(const Animation& animation)
875{
876 const size_t pcount = animation.parts.size();
Mathias Agopiana8826d62009-10-01 03:10:14 -0700877 nsecs_t frameDuration = s2ns(1) / animation.fps;
Geoffrey Pitschdd214a72016-06-27 17:14:30 -0400878 const int animationX = (mWidth - animation.width) / 2;
879 const int animationY = (mHeight - animation.height) / 2;
Mathias Agopian9f3020d2009-11-06 16:30:18 -0800880
Wei Wanga90c54c2017-02-02 11:35:21 -0800881 ALOGD("BootAnimationShownTiming: BootAnimation start time: %" PRId64 "ms", elapsedRealtime());
Narayan Kamathafd31e02013-12-03 13:16:03 +0000882 for (size_t i=0 ; i<pcount ; i++) {
Mathias Agopiana8826d62009-10-01 03:10:14 -0700883 const Animation::Part& part(animation.parts[i]);
884 const size_t fcount = part.frames.size();
885 glBindTexture(GL_TEXTURE_2D, 0);
886
Andriy Naborskyy39218ba2015-08-16 21:32:50 -0700887 // Handle animation package
888 if (part.animation != NULL) {
889 playAnimation(*part.animation);
890 if (exitPending())
891 break;
892 continue; //to next part
893 }
894
Mathias Agopiana8826d62009-10-01 03:10:14 -0700895 for (int r=0 ; !part.count || r<part.count ; r++) {
Kevin Hesterd3782b22012-04-26 10:38:55 -0700896 // Exit any non playuntil complete parts immediately
897 if(exitPending() && !part.playUntilComplete)
898 break;
899
Mike Lockwoodebf9a0d2014-10-02 16:08:47 -0700900 // only play audio file the first time we animate the part
Geoffrey Pitsch290c4352016-08-09 14:35:10 -0400901 if (r == 0 && part.audioData && playSoundsAllowed()) {
902 ALOGD("playing clip for part%d, size=%d", (int) i, part.audioLength);
Geoffrey Pitscha9173532016-07-19 14:56:39 -0400903 // Block until the audio engine is finished initializing.
904 if (mInitAudioThread != nullptr) {
905 mInitAudioThread->join();
906 }
Geoffrey Pitsch290c4352016-08-09 14:35:10 -0400907 audioplay::playClip(part.audioData, part.audioLength);
Mike Lockwoodebf9a0d2014-10-02 16:08:47 -0700908 }
909
Jesse Hall083b84c2014-09-22 10:51:09 -0700910 glClearColor(
911 part.backgroundColor[0],
912 part.backgroundColor[1],
913 part.backgroundColor[2],
914 1.0f);
915
Narayan Kamathafd31e02013-12-03 13:16:03 +0000916 for (size_t j=0 ; j<fcount && (!exitPending() || part.playUntilComplete) ; j++) {
Mathias Agopiana8826d62009-10-01 03:10:14 -0700917 const Animation::Frame& frame(part.frames[j]);
Mathias Agopiandb7dd2a2012-05-12 15:08:21 -0700918 nsecs_t lastFrame = systemTime();
Mathias Agopiana8826d62009-10-01 03:10:14 -0700919
920 if (r > 0) {
921 glBindTexture(GL_TEXTURE_2D, frame.tid);
922 } else {
923 if (part.count != 1) {
924 glGenTextures(1, &frame.tid);
925 glBindTexture(GL_TEXTURE_2D, frame.tid);
926 glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
927 glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
928 }
Damien Bargiacchi0e3d2ab2016-08-29 04:11:19 -0700929 int w, h;
930 initTexture(frame.map, &w, &h);
Mathias Agopiana8826d62009-10-01 03:10:14 -0700931 }
932
Geoffrey Pitschdd214a72016-06-27 17:14:30 -0400933 const int xc = animationX + frame.trimX;
934 const int yc = animationY + frame.trimY;
935 Region clearReg(Rect(mWidth, mHeight));
936 clearReg.subtractSelf(Rect(xc, yc, xc+frame.trimWidth, yc+frame.trimHeight));
Mathias Agopian9f3020d2009-11-06 16:30:18 -0800937 if (!clearReg.isEmpty()) {
938 Region::const_iterator head(clearReg.begin());
939 Region::const_iterator tail(clearReg.end());
940 glEnable(GL_SCISSOR_TEST);
941 while (head != tail) {
Andreas Gampecfedceb2014-09-30 21:48:18 -0700942 const Rect& r2(*head++);
Geoffrey Pitschdd214a72016-06-27 17:14:30 -0400943 glScissor(r2.left, mHeight - r2.bottom, r2.width(), r2.height());
Mathias Agopian9f3020d2009-11-06 16:30:18 -0800944 glClear(GL_COLOR_BUFFER_BIT);
945 }
946 glDisable(GL_SCISSOR_TEST);
947 }
Geoffrey Pitschdd214a72016-06-27 17:14:30 -0400948 // specify the y center as ceiling((mHeight - frame.trimHeight) / 2)
949 // which is equivalent to mHeight - (yc + frame.trimHeight)
950 glDrawTexiOES(xc, mHeight - (yc + frame.trimHeight),
951 0, frame.trimWidth, frame.trimHeight);
Damien Bargiacchi0e3d2ab2016-08-29 04:11:19 -0700952 if (mClockEnabled && mTimeIsAccurate && validClock(part)) {
953 drawClock(animation.clockFont, part.clockPosX, part.clockPosY);
Damien Bargiacchia704b7d2016-02-16 16:55:49 -0800954 }
955
Mathias Agopiana8826d62009-10-01 03:10:14 -0700956 eglSwapBuffers(mDisplay, mSurface);
957
958 nsecs_t now = systemTime();
959 nsecs_t delay = frameDuration - (now - lastFrame);
Mathias Agopiandb7dd2a2012-05-12 15:08:21 -0700960 //ALOGD("%lld, %lld", ns2ms(now - lastFrame), ns2ms(delay));
Mathias Agopiana8826d62009-10-01 03:10:14 -0700961 lastFrame = now;
Mathias Agopiandb7dd2a2012-05-12 15:08:21 -0700962
963 if (delay > 0) {
964 struct timespec spec;
965 spec.tv_sec = (now + delay) / 1000000000;
966 spec.tv_nsec = (now + delay) % 1000000000;
967 int err;
968 do {
969 err = clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &spec, NULL);
970 } while (err<0 && errno == EINTR);
971 }
Kevin Hesterd3782b22012-04-26 10:38:55 -0700972
973 checkExit();
Mathias Agopiana8826d62009-10-01 03:10:14 -0700974 }
Kevin Hesterd3782b22012-04-26 10:38:55 -0700975
Mathias Agopiana8826d62009-10-01 03:10:14 -0700976 usleep(part.pause * ns2us(frameDuration));
Kevin Hesterd3782b22012-04-26 10:38:55 -0700977
978 // For infinite parts, we've now played them at least once, so perhaps exit
979 if(exitPending() && !part.count)
980 break;
Mathias Agopiana8826d62009-10-01 03:10:14 -0700981 }
982
Geoffrey Pitsch2fb30fb2016-07-06 16:16:20 -0400983 }
984
985 // Free textures created for looping parts now that the animation is done.
986 for (const Animation::Part& part : animation.parts) {
Mathias Agopiana8826d62009-10-01 03:10:14 -0700987 if (part.count != 1) {
Geoffrey Pitsch2fb30fb2016-07-06 16:16:20 -0400988 const size_t fcount = part.frames.size();
989 for (size_t j = 0; j < fcount; j++) {
Mathias Agopiana8826d62009-10-01 03:10:14 -0700990 const Animation::Frame& frame(part.frames[j]);
991 glDeleteTextures(1, &frame.tid);
992 }
993 }
994 }
Geoffrey Pitschd6d9a1d2016-06-08 00:38:58 -0700995
996 // we've finally played everything we're going to play
997 audioplay::setPlaying(false);
998 audioplay::destroy();
999
Andriy Naborskyy39218ba2015-08-16 21:32:50 -07001000 return true;
Mathias Agopiana8826d62009-10-01 03:10:14 -07001001}
1002
Andriy Naborskyy39218ba2015-08-16 21:32:50 -07001003void BootAnimation::releaseAnimation(Animation* animation) const
1004{
1005 for (Vector<Animation::Part>::iterator it = animation->parts.begin(),
1006 e = animation->parts.end(); it != e; ++it) {
1007 if (it->animation)
1008 releaseAnimation(it->animation);
1009 }
1010 if (animation->zip)
1011 delete animation->zip;
1012 delete animation;
1013}
1014
1015BootAnimation::Animation* BootAnimation::loadAnimation(const String8& fn)
1016{
1017 if (mLoadedFiles.indexOf(fn) >= 0) {
1018 ALOGE("File \"%s\" is already loaded. Cyclic ref is not allowed",
1019 fn.string());
1020 return NULL;
1021 }
1022 ZipFileRO *zip = ZipFileRO::open(fn);
1023 if (zip == NULL) {
1024 ALOGE("Failed to open animation zip \"%s\": %s",
1025 fn.string(), strerror(errno));
1026 return NULL;
1027 }
1028
1029 Animation *animation = new Animation;
1030 animation->fileName = fn;
1031 animation->zip = zip;
Damien Bargiacchi0e3d2ab2016-08-29 04:11:19 -07001032 animation->clockFont.map = nullptr;
Andriy Naborskyy39218ba2015-08-16 21:32:50 -07001033 mLoadedFiles.add(animation->fileName);
1034
1035 parseAnimationDesc(*animation);
Geoffrey Pitscha91a2d72016-07-12 14:46:19 -04001036 if (!preloadZip(*animation)) {
1037 return NULL;
1038 }
1039
Andriy Naborskyy39218ba2015-08-16 21:32:50 -07001040
1041 mLoadedFiles.remove(fn);
1042 return animation;
1043}
Damien Bargiacchi97480862016-03-29 14:55:55 -07001044
Geoffrey Pitsch290c4352016-08-09 14:35:10 -04001045bool BootAnimation::playSoundsAllowed() const {
1046 // Only play sounds for system boots, not runtime restarts.
1047 if (!mSystemBoot) {
1048 return false;
1049 }
1050
1051 // Read the system property to see if we should play the sound.
1052 // If it's not present, default to allowed.
1053 if (!property_get_bool(PLAY_SOUND_PROP_NAME, 1)) {
1054 return false;
1055 }
1056
1057 // Don't play sounds if this is a reboot due to an error.
1058 char bootreason[PROPERTY_VALUE_MAX];
1059 if (property_get(BOOTREASON_PROP_NAME, bootreason, nullptr) > 0) {
1060 for (const auto& str : PLAY_SOUND_BOOTREASON_BLACKLIST) {
1061 if (strcasecmp(str.c_str(), bootreason) == 0) {
1062 return false;
1063 }
1064 }
1065 }
1066 return true;
1067}
1068
Damien Bargiacchi97480862016-03-29 14:55:55 -07001069bool BootAnimation::updateIsTimeAccurate() {
1070 static constexpr long long MAX_TIME_IN_PAST = 60000LL * 60LL * 24LL * 30LL; // 30 days
1071 static constexpr long long MAX_TIME_IN_FUTURE = 60000LL * 90LL; // 90 minutes
1072
1073 if (mTimeIsAccurate) {
1074 return true;
1075 }
1076
1077 struct stat statResult;
Damien Bargiacchi9071db12016-10-28 17:38:22 -07001078
1079 if(stat(TIME_FORMAT_12_HOUR_FLAG_FILE_PATH, &statResult) == 0) {
1080 mTimeFormat12Hour = true;
1081 }
1082
Damien Bargiacchi97480862016-03-29 14:55:55 -07001083 if(stat(ACCURATE_TIME_FLAG_FILE_PATH, &statResult) == 0) {
1084 mTimeIsAccurate = true;
1085 return true;
1086 }
1087
1088 FILE* file = fopen(LAST_TIME_CHANGED_FILE_PATH, "r");
1089 if (file != NULL) {
1090 long long lastChangedTime = 0;
1091 fscanf(file, "%lld", &lastChangedTime);
1092 fclose(file);
1093 if (lastChangedTime > 0) {
1094 struct timespec now;
1095 clock_gettime(CLOCK_REALTIME, &now);
1096 // Match the Java timestamp format
1097 long long rtcNow = (now.tv_sec * 1000LL) + (now.tv_nsec / 1000000LL);
Damien Bargiacchi96762812016-07-12 15:53:40 -07001098 if (ACCURATE_TIME_EPOCH < rtcNow
1099 && lastChangedTime > (rtcNow - MAX_TIME_IN_PAST)
1100 && lastChangedTime < (rtcNow + MAX_TIME_IN_FUTURE)) {
Damien Bargiacchi97480862016-03-29 14:55:55 -07001101 mTimeIsAccurate = true;
1102 }
1103 }
1104 }
1105
1106 return mTimeIsAccurate;
1107}
1108
1109BootAnimation::TimeCheckThread::TimeCheckThread(BootAnimation* bootAnimation) : Thread(false),
1110 mInotifyFd(-1), mSystemWd(-1), mTimeWd(-1), mBootAnimation(bootAnimation) {}
1111
1112BootAnimation::TimeCheckThread::~TimeCheckThread() {
1113 // mInotifyFd may be -1 but that's ok since we're not at risk of attempting to close a valid FD.
1114 close(mInotifyFd);
1115}
1116
1117bool BootAnimation::TimeCheckThread::threadLoop() {
1118 bool shouldLoop = doThreadLoop() && !mBootAnimation->mTimeIsAccurate
1119 && mBootAnimation->mClockEnabled;
1120 if (!shouldLoop) {
1121 close(mInotifyFd);
1122 mInotifyFd = -1;
1123 }
1124 return shouldLoop;
1125}
1126
1127bool BootAnimation::TimeCheckThread::doThreadLoop() {
1128 static constexpr int BUFF_LEN (10 * (sizeof(struct inotify_event) + NAME_MAX + 1));
1129
1130 // Poll instead of doing a blocking read so the Thread can exit if requested.
1131 struct pollfd pfd = { mInotifyFd, POLLIN, 0 };
1132 ssize_t pollResult = poll(&pfd, 1, 1000);
1133
1134 if (pollResult == 0) {
1135 return true;
1136 } else if (pollResult < 0) {
1137 ALOGE("Could not poll inotify events");
1138 return false;
1139 }
1140
1141 char buff[BUFF_LEN] __attribute__ ((aligned(__alignof__(struct inotify_event))));;
1142 ssize_t length = read(mInotifyFd, buff, BUFF_LEN);
1143 if (length == 0) {
1144 return true;
1145 } else if (length < 0) {
1146 ALOGE("Could not read inotify events");
1147 return false;
1148 }
1149
1150 const struct inotify_event *event;
1151 for (char* ptr = buff; ptr < buff + length; ptr += sizeof(struct inotify_event) + event->len) {
1152 event = (const struct inotify_event *) ptr;
1153 if (event->wd == mSystemWd && strcmp(SYSTEM_TIME_DIR_NAME, event->name) == 0) {
1154 addTimeDirWatch();
1155 } else if (event->wd == mTimeWd && (strcmp(LAST_TIME_CHANGED_FILE_NAME, event->name) == 0
1156 || strcmp(ACCURATE_TIME_FLAG_FILE_NAME, event->name) == 0)) {
1157 return !mBootAnimation->updateIsTimeAccurate();
1158 }
1159 }
1160
1161 return true;
1162}
1163
1164void BootAnimation::TimeCheckThread::addTimeDirWatch() {
1165 mTimeWd = inotify_add_watch(mInotifyFd, SYSTEM_TIME_DIR_PATH,
1166 IN_CLOSE_WRITE | IN_MOVED_TO | IN_ATTRIB);
1167 if (mTimeWd > 0) {
1168 // No need to watch for the time directory to be created if it already exists
1169 inotify_rm_watch(mInotifyFd, mSystemWd);
1170 mSystemWd = -1;
1171 }
1172}
1173
1174status_t BootAnimation::TimeCheckThread::readyToRun() {
1175 mInotifyFd = inotify_init();
1176 if (mInotifyFd < 0) {
1177 ALOGE("Could not initialize inotify fd");
1178 return NO_INIT;
1179 }
1180
1181 mSystemWd = inotify_add_watch(mInotifyFd, SYSTEM_DATA_DIR_PATH, IN_CREATE | IN_ATTRIB);
1182 if (mSystemWd < 0) {
1183 close(mInotifyFd);
1184 mInotifyFd = -1;
1185 ALOGE("Could not add watch for %s", SYSTEM_DATA_DIR_PATH);
1186 return NO_INIT;
1187 }
1188
1189 addTimeDirWatch();
1190
1191 if (mBootAnimation->updateIsTimeAccurate()) {
1192 close(mInotifyFd);
1193 mInotifyFd = -1;
1194 return ALREADY_EXISTS;
1195 }
1196
1197 return NO_ERROR;
1198}
1199
Geoffrey Pitscha9173532016-07-19 14:56:39 -04001200BootAnimation::InitAudioThread::InitAudioThread(uint8_t* exampleAudioData, int exampleAudioLength)
1201 : Thread(false),
1202 mExampleAudioData(exampleAudioData),
1203 mExampleAudioLength(exampleAudioLength) {}
1204
1205bool BootAnimation::InitAudioThread::threadLoop() {
1206 audioplay::create(mExampleAudioData, mExampleAudioLength);
1207 // Exit immediately
1208 return false;
1209}
1210
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001211// ---------------------------------------------------------------------------
1212
1213}
1214; // namespace android