The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 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 Lockwood | ebf9a0d | 2014-10-02 16:08:47 -0700 | [diff] [blame] | 17 | #define LOG_NDEBUG 0 |
Mathias Agopian | bc72611 | 2009-09-23 15:44:05 -0700 | [diff] [blame] | 18 | #define LOG_TAG "BootAnimation" |
| 19 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 20 | #include <stdint.h> |
Damien Bargiacchi | 9748086 | 2016-03-29 14:55:55 -0700 | [diff] [blame] | 21 | #include <sys/inotify.h> |
| 22 | #include <sys/poll.h> |
| 23 | #include <sys/stat.h> |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 24 | #include <sys/types.h> |
| 25 | #include <math.h> |
| 26 | #include <fcntl.h> |
| 27 | #include <utils/misc.h> |
Mathias Agopian | b4d5a72 | 2009-09-23 17:05:19 -0700 | [diff] [blame] | 28 | #include <signal.h> |
Elliott Hughes | bb94f31 | 2014-10-21 10:41:33 -0700 | [diff] [blame] | 29 | #include <time.h> |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 30 | |
Jason parks | bd9a08d | 2011-01-31 15:04:34 -0600 | [diff] [blame] | 31 | #include <cutils/properties.h> |
| 32 | |
Mathias Agopian | b13b9bd | 2012-02-17 18:27:36 -0800 | [diff] [blame] | 33 | #include <androidfw/AssetManager.h> |
Mathias Agopian | ac31a3b | 2009-05-21 19:59:24 -0700 | [diff] [blame] | 34 | #include <binder/IPCThreadState.h> |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 35 | #include <utils/Atomic.h> |
| 36 | #include <utils/Errors.h> |
| 37 | #include <utils/Log.h> |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 38 | |
| 39 | #include <ui/PixelFormat.h> |
| 40 | #include <ui/Rect.h> |
| 41 | #include <ui/Region.h> |
| 42 | #include <ui/DisplayInfo.h> |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 43 | |
Jeff Brown | 0b722fe | 2012-08-24 22:40:14 -0700 | [diff] [blame] | 44 | #include <gui/ISurfaceComposer.h> |
Mathias Agopian | 8335f1c | 2012-02-25 18:48:35 -0800 | [diff] [blame] | 45 | #include <gui/Surface.h> |
| 46 | #include <gui/SurfaceComposerClient.h> |
Mathias Agopian | 000479f | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 47 | |
Andreas Gampe | cfedceb | 2014-09-30 21:48:18 -0700 | [diff] [blame] | 48 | // TODO: Fix Skia. |
| 49 | #pragma GCC diagnostic push |
| 50 | #pragma GCC diagnostic ignored "-Wunused-parameter" |
Derek Sollenberger | eece0dd | 2014-02-27 14:31:29 -0500 | [diff] [blame] | 51 | #include <SkBitmap.h> |
Matt Sarett | 8898c16 | 2016-03-24 16:11:01 -0400 | [diff] [blame] | 52 | #include <SkImage.h> |
Derek Sollenberger | eece0dd | 2014-02-27 14:31:29 -0500 | [diff] [blame] | 53 | #include <SkStream.h> |
Andreas Gampe | cfedceb | 2014-09-30 21:48:18 -0700 | [diff] [blame] | 54 | #pragma GCC diagnostic pop |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 55 | |
| 56 | #include <GLES/gl.h> |
| 57 | #include <GLES/glext.h> |
| 58 | #include <EGL/eglext.h> |
| 59 | |
| 60 | #include "BootAnimation.h" |
Geoffrey Pitsch | d6d9a1d | 2016-06-08 00:38:58 -0700 | [diff] [blame] | 61 | #include "audioplay.h" |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 62 | |
| 63 | namespace android { |
| 64 | |
Damien Bargiacchi | 9748086 | 2016-03-29 14:55:55 -0700 | [diff] [blame] | 65 | static const char OEM_BOOTANIMATION_FILE[] = "/oem/media/bootanimation.zip"; |
| 66 | static const char SYSTEM_BOOTANIMATION_FILE[] = "/system/media/bootanimation.zip"; |
| 67 | static const char SYSTEM_ENCRYPTED_BOOTANIMATION_FILE[] = "/system/media/bootanimation-encrypted.zip"; |
| 68 | static const char SYSTEM_DATA_DIR_PATH[] = "/data/system"; |
| 69 | static const char SYSTEM_TIME_DIR_NAME[] = "time"; |
| 70 | static const char SYSTEM_TIME_DIR_PATH[] = "/data/system/time"; |
Damien Bargiacchi | 0e3d2ab | 2016-08-29 04:11:19 -0700 | [diff] [blame] | 71 | static const char CLOCK_FONT_ASSET[] = "images/clock_font.png"; |
| 72 | static const char CLOCK_FONT_ZIP_NAME[] = "clock_font.png"; |
Damien Bargiacchi | 9748086 | 2016-03-29 14:55:55 -0700 | [diff] [blame] | 73 | static const char LAST_TIME_CHANGED_FILE_NAME[] = "last_time_change"; |
| 74 | static const char LAST_TIME_CHANGED_FILE_PATH[] = "/data/system/time/last_time_change"; |
| 75 | static const char ACCURATE_TIME_FLAG_FILE_NAME[] = "time_is_accurate"; |
| 76 | static const char ACCURATE_TIME_FLAG_FILE_PATH[] = "/data/system/time/time_is_accurate"; |
Damien Bargiacchi | 9071db1 | 2016-10-28 17:38:22 -0700 | [diff] [blame] | 77 | static const char TIME_FORMAT_12_HOUR_FLAG_FILE_PATH[] = "/data/system/time/time_format_12_hour"; |
Damien Bargiacchi | 9676281 | 2016-07-12 15:53:40 -0700 | [diff] [blame] | 78 | // Java timestamp format. Don't show the clock if the date is before 2000-01-01 00:00:00. |
| 79 | static const long long ACCURATE_TIME_EPOCH = 946684800000; |
Damien Bargiacchi | 0e3d2ab | 2016-08-29 04:11:19 -0700 | [diff] [blame] | 80 | static constexpr char FONT_BEGIN_CHAR = ' '; |
| 81 | static constexpr char FONT_END_CHAR = '~' + 1; |
| 82 | static constexpr size_t FONT_NUM_CHARS = FONT_END_CHAR - FONT_BEGIN_CHAR + 1; |
| 83 | static constexpr size_t FONT_NUM_COLS = 16; |
| 84 | static constexpr size_t FONT_NUM_ROWS = FONT_NUM_CHARS / FONT_NUM_COLS; |
| 85 | static const int TEXT_CENTER_VALUE = INT_MAX; |
| 86 | static const int TEXT_MISSING_VALUE = INT_MIN; |
Damien Bargiacchi | 9748086 | 2016-03-29 14:55:55 -0700 | [diff] [blame] | 87 | static const char EXIT_PROP_NAME[] = "service.bootanim.exit"; |
Geoffrey Pitsch | 3050879 | 2016-07-22 17:04:21 -0400 | [diff] [blame] | 88 | static const char PLAY_SOUND_PROP_NAME[] = "persist.sys.bootanim.play_sound"; |
Narayan Kamath | afd31e0 | 2013-12-03 13:16:03 +0000 | [diff] [blame] | 89 | static const int ANIM_ENTRY_NAME_MAX = 256; |
Damien Bargiacchi | 0e3d2ab | 2016-08-29 04:11:19 -0700 | [diff] [blame] | 90 | static constexpr size_t TEXT_POS_LEN_MAX = 16; |
Geoffrey Pitsch | 290c435 | 2016-08-09 14:35:10 -0400 | [diff] [blame] | 91 | static const char BOOT_COMPLETED_PROP_NAME[] = "sys.boot_completed"; |
| 92 | static const char BOOTREASON_PROP_NAME[] = "ro.boot.bootreason"; |
| 93 | // bootreasons list in "system/core/bootstat/bootstat.cpp". |
| 94 | static const std::vector<std::string> PLAY_SOUND_BOOTREASON_BLACKLIST { |
| 95 | "kernel_panic", |
| 96 | "Panic", |
| 97 | "Watchdog", |
| 98 | }; |
Narayan Kamath | afd31e0 | 2013-12-03 13:16:03 +0000 | [diff] [blame] | 99 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 100 | // --------------------------------------------------------------------------- |
| 101 | |
Damien Bargiacchi | 9748086 | 2016-03-29 14:55:55 -0700 | [diff] [blame] | 102 | BootAnimation::BootAnimation() : Thread(false), mClockEnabled(true), mTimeIsAccurate(false), |
Damien Bargiacchi | 9071db1 | 2016-10-28 17:38:22 -0700 | [diff] [blame] | 103 | mTimeFormat12Hour(false), mTimeCheckThread(NULL) { |
Mathias Agopian | 627e7b5 | 2009-05-21 19:21:59 -0700 | [diff] [blame] | 104 | mSession = new SurfaceComposerClient(); |
Geoffrey Pitsch | 290c435 | 2016-08-09 14:35:10 -0400 | [diff] [blame] | 105 | |
| 106 | // If the system has already booted, the animation is not being used for a boot. |
| 107 | mSystemBoot = !property_get_bool(BOOT_COMPLETED_PROP_NAME, 0); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 108 | } |
| 109 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 110 | void BootAnimation::onFirstRef() { |
Mathias Agopian | bc72611 | 2009-09-23 15:44:05 -0700 | [diff] [blame] | 111 | status_t err = mSession->linkToComposerDeath(this); |
Steve Block | 3762c31 | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 112 | ALOGE_IF(err, "linkToComposerDeath failed (%s) ", strerror(-err)); |
Mathias Agopian | 8434c53 | 2009-09-23 18:52:49 -0700 | [diff] [blame] | 113 | if (err == NO_ERROR) { |
Mathias Agopian | bc72611 | 2009-09-23 15:44:05 -0700 | [diff] [blame] | 114 | run("BootAnimation", PRIORITY_DISPLAY); |
| 115 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 116 | } |
| 117 | |
Mathias Agopian | bc72611 | 2009-09-23 15:44:05 -0700 | [diff] [blame] | 118 | sp<SurfaceComposerClient> BootAnimation::session() const { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 119 | return mSession; |
| 120 | } |
| 121 | |
Mathias Agopian | bc72611 | 2009-09-23 15:44:05 -0700 | [diff] [blame] | 122 | |
Narayan Kamath | afd31e0 | 2013-12-03 13:16:03 +0000 | [diff] [blame] | 123 | void BootAnimation::binderDied(const wp<IBinder>&) |
Mathias Agopian | bc72611 | 2009-09-23 15:44:05 -0700 | [diff] [blame] | 124 | { |
| 125 | // woah, surfaceflinger died! |
Steve Block | 5baa3a6 | 2011-12-20 16:23:08 +0000 | [diff] [blame] | 126 | ALOGD("SurfaceFlinger died, exiting..."); |
Mathias Agopian | bc72611 | 2009-09-23 15:44:05 -0700 | [diff] [blame] | 127 | |
| 128 | // calling requestExit() is not enough here because the Surface code |
| 129 | // might be blocked on a condition variable that will never be updated. |
| 130 | kill( getpid(), SIGKILL ); |
| 131 | requestExit(); |
Geoffrey Pitsch | d6d9a1d | 2016-06-08 00:38:58 -0700 | [diff] [blame] | 132 | audioplay::destroy(); |
Mathias Agopian | bc72611 | 2009-09-23 15:44:05 -0700 | [diff] [blame] | 133 | } |
| 134 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 135 | status_t BootAnimation::initTexture(Texture* texture, AssetManager& assets, |
| 136 | const char* name) { |
| 137 | Asset* asset = assets.open(name, Asset::ACCESS_BUFFER); |
Andreas Gampe | cfedceb | 2014-09-30 21:48:18 -0700 | [diff] [blame] | 138 | if (asset == NULL) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 139 | return NO_INIT; |
| 140 | SkBitmap bitmap; |
Matt Sarett | 8898c16 | 2016-03-24 16:11:01 -0400 | [diff] [blame] | 141 | sk_sp<SkData> data = SkData::MakeWithoutCopy(asset->getBuffer(false), |
| 142 | asset->getLength()); |
| 143 | sk_sp<SkImage> image = SkImage::MakeFromEncoded(data); |
| 144 | image->asLegacyBitmap(&bitmap, SkImage::kRO_LegacyBitmapMode); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 145 | asset->close(); |
| 146 | delete asset; |
| 147 | |
| 148 | // ensure we can call getPixels(). No need to call unlock, since the |
| 149 | // bitmap will go out of scope when we return from this method. |
| 150 | bitmap.lockPixels(); |
| 151 | |
| 152 | const int w = bitmap.width(); |
| 153 | const int h = bitmap.height(); |
| 154 | const void* p = bitmap.getPixels(); |
| 155 | |
| 156 | GLint crop[4] = { 0, h, w, -h }; |
| 157 | texture->w = w; |
| 158 | texture->h = h; |
| 159 | |
| 160 | glGenTextures(1, &texture->name); |
| 161 | glBindTexture(GL_TEXTURE_2D, texture->name); |
| 162 | |
Mike Reed | 42a1d08 | 2014-07-07 18:06:18 -0400 | [diff] [blame] | 163 | switch (bitmap.colorType()) { |
| 164 | case kAlpha_8_SkColorType: |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 165 | glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, w, h, 0, GL_ALPHA, |
| 166 | GL_UNSIGNED_BYTE, p); |
| 167 | break; |
Mike Reed | 42a1d08 | 2014-07-07 18:06:18 -0400 | [diff] [blame] | 168 | case kARGB_4444_SkColorType: |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 169 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, |
| 170 | GL_UNSIGNED_SHORT_4_4_4_4, p); |
| 171 | break; |
Mike Reed | 42a1d08 | 2014-07-07 18:06:18 -0400 | [diff] [blame] | 172 | case kN32_SkColorType: |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 173 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, |
| 174 | GL_UNSIGNED_BYTE, p); |
| 175 | break; |
Mike Reed | 42a1d08 | 2014-07-07 18:06:18 -0400 | [diff] [blame] | 176 | case kRGB_565_SkColorType: |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 177 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, w, h, 0, GL_RGB, |
| 178 | GL_UNSIGNED_SHORT_5_6_5, p); |
| 179 | break; |
| 180 | default: |
| 181 | break; |
| 182 | } |
| 183 | |
| 184 | glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES, crop); |
| 185 | glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
| 186 | glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| 187 | glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); |
| 188 | glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); |
Damien Bargiacchi | 0e3d2ab | 2016-08-29 04:11:19 -0700 | [diff] [blame] | 189 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 190 | return NO_ERROR; |
| 191 | } |
| 192 | |
Damien Bargiacchi | 0e3d2ab | 2016-08-29 04:11:19 -0700 | [diff] [blame] | 193 | status_t BootAnimation::initTexture(FileMap* map, int* width, int* height) |
Mathias Agopian | a8826d6 | 2009-10-01 03:10:14 -0700 | [diff] [blame] | 194 | { |
Mathias Agopian | a8826d6 | 2009-10-01 03:10:14 -0700 | [diff] [blame] | 195 | SkBitmap bitmap; |
Damien Bargiacchi | f67b317 | 2016-09-07 20:17:14 -0700 | [diff] [blame] | 196 | sk_sp<SkData> data = SkData::MakeWithoutCopy(map->getDataPtr(), |
| 197 | map->getDataLength()); |
Matt Sarett | 8898c16 | 2016-03-24 16:11:01 -0400 | [diff] [blame] | 198 | sk_sp<SkImage> image = SkImage::MakeFromEncoded(data); |
| 199 | image->asLegacyBitmap(&bitmap, SkImage::kRO_LegacyBitmapMode); |
Mathias Agopian | a8826d6 | 2009-10-01 03:10:14 -0700 | [diff] [blame] | 200 | |
Mykola Kondratenko | 0c1eeb3 | 2014-04-15 09:35:44 +0200 | [diff] [blame] | 201 | // FileMap memory is never released until application exit. |
| 202 | // Release it now as the texture is already loaded and the memory used for |
| 203 | // the packed resource can be released. |
Damien Bargiacchi | 0e3d2ab | 2016-08-29 04:11:19 -0700 | [diff] [blame] | 204 | delete map; |
Mykola Kondratenko | 0c1eeb3 | 2014-04-15 09:35:44 +0200 | [diff] [blame] | 205 | |
Mathias Agopian | a8826d6 | 2009-10-01 03:10:14 -0700 | [diff] [blame] | 206 | // ensure we can call getPixels(). No need to call unlock, since the |
| 207 | // bitmap will go out of scope when we return from this method. |
| 208 | bitmap.lockPixels(); |
| 209 | |
| 210 | const int w = bitmap.width(); |
| 211 | const int h = bitmap.height(); |
| 212 | const void* p = bitmap.getPixels(); |
| 213 | |
| 214 | GLint crop[4] = { 0, h, w, -h }; |
| 215 | int tw = 1 << (31 - __builtin_clz(w)); |
| 216 | int th = 1 << (31 - __builtin_clz(h)); |
| 217 | if (tw < w) tw <<= 1; |
| 218 | if (th < h) th <<= 1; |
| 219 | |
Mike Reed | 42a1d08 | 2014-07-07 18:06:18 -0400 | [diff] [blame] | 220 | switch (bitmap.colorType()) { |
| 221 | case kN32_SkColorType: |
Sai Kiran Korwar | 2716749 | 2015-07-07 20:00:06 +0530 | [diff] [blame] | 222 | if (!mUseNpotTextures && (tw != w || th != h)) { |
Mathias Agopian | a8826d6 | 2009-10-01 03:10:14 -0700 | [diff] [blame] | 223 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, tw, th, 0, GL_RGBA, |
| 224 | GL_UNSIGNED_BYTE, 0); |
| 225 | glTexSubImage2D(GL_TEXTURE_2D, 0, |
| 226 | 0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, p); |
| 227 | } else { |
Sai Kiran Korwar | 2716749 | 2015-07-07 20:00:06 +0530 | [diff] [blame] | 228 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, |
Mathias Agopian | a8826d6 | 2009-10-01 03:10:14 -0700 | [diff] [blame] | 229 | GL_UNSIGNED_BYTE, p); |
| 230 | } |
| 231 | break; |
| 232 | |
Mike Reed | 42a1d08 | 2014-07-07 18:06:18 -0400 | [diff] [blame] | 233 | case kRGB_565_SkColorType: |
Sai Kiran Korwar | 2716749 | 2015-07-07 20:00:06 +0530 | [diff] [blame] | 234 | if (!mUseNpotTextures && (tw != w || th != h)) { |
Mathias Agopian | a8826d6 | 2009-10-01 03:10:14 -0700 | [diff] [blame] | 235 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, tw, th, 0, GL_RGB, |
| 236 | GL_UNSIGNED_SHORT_5_6_5, 0); |
| 237 | glTexSubImage2D(GL_TEXTURE_2D, 0, |
| 238 | 0, 0, w, h, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, p); |
| 239 | } else { |
Sai Kiran Korwar | 2716749 | 2015-07-07 20:00:06 +0530 | [diff] [blame] | 240 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, w, h, 0, GL_RGB, |
Mathias Agopian | a8826d6 | 2009-10-01 03:10:14 -0700 | [diff] [blame] | 241 | GL_UNSIGNED_SHORT_5_6_5, p); |
| 242 | } |
| 243 | break; |
| 244 | default: |
| 245 | break; |
| 246 | } |
| 247 | |
| 248 | glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES, crop); |
| 249 | |
Damien Bargiacchi | 0e3d2ab | 2016-08-29 04:11:19 -0700 | [diff] [blame] | 250 | *width = w; |
| 251 | *height = h; |
| 252 | |
Mathias Agopian | a8826d6 | 2009-10-01 03:10:14 -0700 | [diff] [blame] | 253 | return NO_ERROR; |
| 254 | } |
| 255 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 256 | status_t BootAnimation::readyToRun() { |
| 257 | mAssets.addDefaultAssets(); |
| 258 | |
Jeff Brown | 0b722fe | 2012-08-24 22:40:14 -0700 | [diff] [blame] | 259 | sp<IBinder> dtoken(SurfaceComposerClient::getBuiltInDisplay( |
| 260 | ISurfaceComposer::eDisplayIdMain)); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 261 | DisplayInfo dinfo; |
Jeff Brown | 0b722fe | 2012-08-24 22:40:14 -0700 | [diff] [blame] | 262 | status_t status = SurfaceComposerClient::getDisplayInfo(dtoken, &dinfo); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 263 | if (status) |
| 264 | return -1; |
| 265 | |
| 266 | // create the native surface |
Jeff Brown | 0b722fe | 2012-08-24 22:40:14 -0700 | [diff] [blame] | 267 | sp<SurfaceControl> control = session()->createSurface(String8("BootAnimation"), |
| 268 | dinfo.w, dinfo.h, PIXEL_FORMAT_RGB_565); |
Mathias Agopian | 439863f | 2011-06-28 19:09:31 -0700 | [diff] [blame] | 269 | |
| 270 | SurfaceComposerClient::openGlobalTransaction(); |
Mathias Agopian | 17f638b | 2009-04-16 20:04:08 -0700 | [diff] [blame] | 271 | control->setLayer(0x40000000); |
Mathias Agopian | 439863f | 2011-06-28 19:09:31 -0700 | [diff] [blame] | 272 | SurfaceComposerClient::closeGlobalTransaction(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 273 | |
Mathias Agopian | 17f638b | 2009-04-16 20:04:08 -0700 | [diff] [blame] | 274 | sp<Surface> s = control->getSurface(); |
| 275 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 276 | // initialize opengl and egl |
Mathias Agopian | 738b9a4 | 2009-08-06 16:41:02 -0700 | [diff] [blame] | 277 | const EGLint attribs[] = { |
Mathias Agopian | 1b253b7 | 2011-08-15 15:20:22 -0700 | [diff] [blame] | 278 | EGL_RED_SIZE, 8, |
| 279 | EGL_GREEN_SIZE, 8, |
| 280 | EGL_BLUE_SIZE, 8, |
Mathias Agopian | a8826d6 | 2009-10-01 03:10:14 -0700 | [diff] [blame] | 281 | EGL_DEPTH_SIZE, 0, |
| 282 | EGL_NONE |
Mathias Agopian | 738b9a4 | 2009-08-06 16:41:02 -0700 | [diff] [blame] | 283 | }; |
Andreas Gampe | cfedceb | 2014-09-30 21:48:18 -0700 | [diff] [blame] | 284 | EGLint w, h; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 285 | EGLint numConfigs; |
| 286 | EGLConfig config; |
| 287 | EGLSurface surface; |
| 288 | EGLContext context; |
Mathias Agopian | 627e7b5 | 2009-05-21 19:21:59 -0700 | [diff] [blame] | 289 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 290 | EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY); |
Mathias Agopian | 627e7b5 | 2009-05-21 19:21:59 -0700 | [diff] [blame] | 291 | |
| 292 | eglInitialize(display, 0, 0); |
Mathias Agopian | 1b253b7 | 2011-08-15 15:20:22 -0700 | [diff] [blame] | 293 | eglChooseConfig(display, attribs, &config, 1, &numConfigs); |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 294 | surface = eglCreateWindowSurface(display, config, s.get(), NULL); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 295 | context = eglCreateContext(display, config, NULL, NULL); |
| 296 | eglQuerySurface(display, surface, EGL_WIDTH, &w); |
| 297 | eglQuerySurface(display, surface, EGL_HEIGHT, &h); |
Mathias Agopian | a8826d6 | 2009-10-01 03:10:14 -0700 | [diff] [blame] | 298 | |
Mathias Agopian | abac010 | 2009-07-31 14:47:00 -0700 | [diff] [blame] | 299 | if (eglMakeCurrent(display, surface, surface, context) == EGL_FALSE) |
| 300 | return NO_INIT; |
Mathias Agopian | a8826d6 | 2009-10-01 03:10:14 -0700 | [diff] [blame] | 301 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 302 | mDisplay = display; |
| 303 | mContext = context; |
| 304 | mSurface = surface; |
| 305 | mWidth = w; |
| 306 | mHeight = h; |
Mathias Agopian | 17f638b | 2009-04-16 20:04:08 -0700 | [diff] [blame] | 307 | mFlingerSurfaceControl = control; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 308 | mFlingerSurface = s; |
| 309 | |
Elliott Hughes | c367d48 | 2013-10-29 13:12:55 -0700 | [diff] [blame] | 310 | // If the device has encryption turned on or is in process |
Jason parks | bd9a08d | 2011-01-31 15:04:34 -0600 | [diff] [blame] | 311 | // of being encrypted we show the encrypted boot animation. |
| 312 | char decrypt[PROPERTY_VALUE_MAX]; |
| 313 | property_get("vold.decrypt", decrypt, ""); |
| 314 | |
| 315 | bool encryptedAnimation = atoi(decrypt) != 0 || !strcmp("trigger_restart_min_framework", decrypt); |
| 316 | |
Andriy Naborskyy | 39218ba | 2015-08-16 21:32:50 -0700 | [diff] [blame] | 317 | if (encryptedAnimation && (access(SYSTEM_ENCRYPTED_BOOTANIMATION_FILE, R_OK) == 0)) { |
| 318 | mZipFileName = SYSTEM_ENCRYPTED_BOOTANIMATION_FILE; |
Jason parks | bd9a08d | 2011-01-31 15:04:34 -0600 | [diff] [blame] | 319 | } |
Andriy Naborskyy | 39218ba | 2015-08-16 21:32:50 -0700 | [diff] [blame] | 320 | else if (access(OEM_BOOTANIMATION_FILE, R_OK) == 0) { |
| 321 | mZipFileName = OEM_BOOTANIMATION_FILE; |
| 322 | } |
| 323 | else if (access(SYSTEM_BOOTANIMATION_FILE, R_OK) == 0) { |
| 324 | mZipFileName = SYSTEM_BOOTANIMATION_FILE; |
| 325 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 326 | return NO_ERROR; |
| 327 | } |
| 328 | |
Mathias Agopian | a8826d6 | 2009-10-01 03:10:14 -0700 | [diff] [blame] | 329 | bool BootAnimation::threadLoop() |
| 330 | { |
| 331 | bool r; |
Narayan Kamath | afd31e0 | 2013-12-03 13:16:03 +0000 | [diff] [blame] | 332 | // We have no bootanimation file, so we use the stock android logo |
| 333 | // animation. |
Andriy Naborskyy | 39218ba | 2015-08-16 21:32:50 -0700 | [diff] [blame] | 334 | if (mZipFileName.isEmpty()) { |
Mathias Agopian | a8826d6 | 2009-10-01 03:10:14 -0700 | [diff] [blame] | 335 | r = android(); |
| 336 | } else { |
| 337 | r = movie(); |
| 338 | } |
| 339 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 340 | eglMakeCurrent(mDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); |
| 341 | eglDestroyContext(mDisplay, mContext); |
| 342 | eglDestroySurface(mDisplay, mSurface); |
Mathias Agopian | 6cf0db2 | 2009-04-17 19:36:26 -0700 | [diff] [blame] | 343 | mFlingerSurface.clear(); |
Mathias Agopian | 17f638b | 2009-04-16 20:04:08 -0700 | [diff] [blame] | 344 | mFlingerSurfaceControl.clear(); |
Mathias Agopian | 627e7b5 | 2009-05-21 19:21:59 -0700 | [diff] [blame] | 345 | eglTerminate(mDisplay); |
Sai Kiran Korwar | 3eee9fb | 2015-06-16 17:13:35 +0530 | [diff] [blame] | 346 | eglReleaseThread(); |
Mathias Agopian | 627e7b5 | 2009-05-21 19:21:59 -0700 | [diff] [blame] | 347 | IPCThreadState::self()->stopProcess(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 348 | return r; |
| 349 | } |
| 350 | |
Mathias Agopian | a8826d6 | 2009-10-01 03:10:14 -0700 | [diff] [blame] | 351 | bool BootAnimation::android() |
| 352 | { |
Mathias Agopian | b2cf954 | 2009-03-24 18:34:16 -0700 | [diff] [blame] | 353 | initTexture(&mAndroid[0], mAssets, "images/android-logo-mask.png"); |
| 354 | initTexture(&mAndroid[1], mAssets, "images/android-logo-shine.png"); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 355 | |
| 356 | // clear screen |
Mathias Agopian | a8826d6 | 2009-10-01 03:10:14 -0700 | [diff] [blame] | 357 | glShadeModel(GL_FLAT); |
Mathias Agopian | b2cf954 | 2009-03-24 18:34:16 -0700 | [diff] [blame] | 358 | glDisable(GL_DITHER); |
| 359 | glDisable(GL_SCISSOR_TEST); |
Mathias Agopian | 59f19e4 | 2011-05-06 19:22:12 -0700 | [diff] [blame] | 360 | glClearColor(0,0,0,1); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 361 | glClear(GL_COLOR_BUFFER_BIT); |
| 362 | eglSwapBuffers(mDisplay, mSurface); |
| 363 | |
Mathias Agopian | a8826d6 | 2009-10-01 03:10:14 -0700 | [diff] [blame] | 364 | glEnable(GL_TEXTURE_2D); |
| 365 | glTexEnvx(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); |
| 366 | |
Mathias Agopian | b2cf954 | 2009-03-24 18:34:16 -0700 | [diff] [blame] | 367 | const GLint xc = (mWidth - mAndroid[0].w) / 2; |
| 368 | const GLint yc = (mHeight - mAndroid[0].h) / 2; |
| 369 | const Rect updateRect(xc, yc, xc + mAndroid[0].w, yc + mAndroid[0].h); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 370 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 371 | glScissor(updateRect.left, mHeight - updateRect.bottom, updateRect.width(), |
| 372 | updateRect.height()); |
| 373 | |
Mathias Agopian | b2cf954 | 2009-03-24 18:34:16 -0700 | [diff] [blame] | 374 | // Blend state |
| 375 | glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
| 376 | glTexEnvx(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); |
| 377 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 378 | const nsecs_t startTime = systemTime(); |
| 379 | do { |
Mathias Agopian | 1379665 | 2009-03-24 22:49:21 -0700 | [diff] [blame] | 380 | nsecs_t now = systemTime(); |
| 381 | double time = now - startTime; |
Mathias Agopian | b2cf954 | 2009-03-24 18:34:16 -0700 | [diff] [blame] | 382 | float t = 4.0f * float(time / us2ns(16667)) / mAndroid[1].w; |
| 383 | GLint offset = (1 - (t - floorf(t))) * mAndroid[1].w; |
| 384 | GLint x = xc - offset; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 385 | |
Mathias Agopian | 8166864 | 2009-07-28 11:41:30 -0700 | [diff] [blame] | 386 | glDisable(GL_SCISSOR_TEST); |
| 387 | glClear(GL_COLOR_BUFFER_BIT); |
| 388 | |
| 389 | glEnable(GL_SCISSOR_TEST); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 390 | glDisable(GL_BLEND); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 391 | glBindTexture(GL_TEXTURE_2D, mAndroid[1].name); |
Mathias Agopian | b2cf954 | 2009-03-24 18:34:16 -0700 | [diff] [blame] | 392 | glDrawTexiOES(x, yc, 0, mAndroid[1].w, mAndroid[1].h); |
| 393 | glDrawTexiOES(x + mAndroid[1].w, yc, 0, mAndroid[1].w, mAndroid[1].h); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 394 | |
Mathias Agopian | b2cf954 | 2009-03-24 18:34:16 -0700 | [diff] [blame] | 395 | glEnable(GL_BLEND); |
| 396 | glBindTexture(GL_TEXTURE_2D, mAndroid[0].name); |
| 397 | glDrawTexiOES(xc, yc, 0, mAndroid[0].w, mAndroid[0].h); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 398 | |
Mathias Agopian | 627e7b5 | 2009-05-21 19:21:59 -0700 | [diff] [blame] | 399 | EGLBoolean res = eglSwapBuffers(mDisplay, mSurface); |
| 400 | if (res == EGL_FALSE) |
| 401 | break; |
| 402 | |
Mathias Agopian | 1379665 | 2009-03-24 22:49:21 -0700 | [diff] [blame] | 403 | // 12fps: don't animate too fast to preserve CPU |
| 404 | const nsecs_t sleepTime = 83333 - ns2us(systemTime() - now); |
| 405 | if (sleepTime > 0) |
Mathias Agopian | a8826d6 | 2009-10-01 03:10:14 -0700 | [diff] [blame] | 406 | usleep(sleepTime); |
Kevin Hester | d3782b2 | 2012-04-26 10:38:55 -0700 | [diff] [blame] | 407 | |
| 408 | checkExit(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 409 | } while (!exitPending()); |
| 410 | |
| 411 | glDeleteTextures(1, &mAndroid[0].name); |
| 412 | glDeleteTextures(1, &mAndroid[1].name); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 413 | return false; |
| 414 | } |
| 415 | |
Kevin Hester | d3782b2 | 2012-04-26 10:38:55 -0700 | [diff] [blame] | 416 | void BootAnimation::checkExit() { |
| 417 | // Allow surface flinger to gracefully request shutdown |
| 418 | char value[PROPERTY_VALUE_MAX]; |
| 419 | property_get(EXIT_PROP_NAME, value, "0"); |
| 420 | int exitnow = atoi(value); |
| 421 | if (exitnow) { |
| 422 | requestExit(); |
| 423 | } |
| 424 | } |
| 425 | |
Damien Bargiacchi | 0e3d2ab | 2016-08-29 04:11:19 -0700 | [diff] [blame] | 426 | bool BootAnimation::validClock(const Animation::Part& part) { |
| 427 | return part.clockPosX != TEXT_MISSING_VALUE && part.clockPosY != TEXT_MISSING_VALUE; |
| 428 | } |
| 429 | |
| 430 | bool parseTextCoord(const char* str, int* dest) { |
| 431 | if (strcmp("c", str) == 0) { |
| 432 | *dest = TEXT_CENTER_VALUE; |
| 433 | return true; |
| 434 | } |
| 435 | |
| 436 | char* end; |
| 437 | int val = (int) strtol(str, &end, 0); |
| 438 | if (end == str || *end != '\0' || val == INT_MAX || val == INT_MIN) { |
| 439 | return false; |
| 440 | } |
| 441 | *dest = val; |
| 442 | return true; |
| 443 | } |
| 444 | |
| 445 | // Parse two position coordinates. If only string is non-empty, treat it as the y value. |
| 446 | void parsePosition(const char* str1, const char* str2, int* x, int* y) { |
| 447 | bool success = false; |
| 448 | if (strlen(str1) == 0) { // No values were specified |
| 449 | // success = false |
| 450 | } else if (strlen(str2) == 0) { // we have only one value |
| 451 | if (parseTextCoord(str1, y)) { |
| 452 | *x = TEXT_CENTER_VALUE; |
| 453 | success = true; |
| 454 | } |
| 455 | } else { |
| 456 | if (parseTextCoord(str1, x) && parseTextCoord(str2, y)) { |
| 457 | success = true; |
| 458 | } |
| 459 | } |
| 460 | |
| 461 | if (!success) { |
| 462 | *x = TEXT_MISSING_VALUE; |
| 463 | *y = TEXT_MISSING_VALUE; |
| 464 | } |
| 465 | } |
| 466 | |
Jesse Hall | 083b84c | 2014-09-22 10:51:09 -0700 | [diff] [blame] | 467 | // Parse a color represented as an HTML-style 'RRGGBB' string: each pair of |
| 468 | // characters in str is a hex number in [0, 255], which are converted to |
| 469 | // floating point values in the range [0.0, 1.0] and placed in the |
| 470 | // corresponding elements of color. |
| 471 | // |
| 472 | // If the input string isn't valid, parseColor returns false and color is |
| 473 | // left unchanged. |
| 474 | static bool parseColor(const char str[7], float color[3]) { |
| 475 | float tmpColor[3]; |
| 476 | for (int i = 0; i < 3; i++) { |
| 477 | int val = 0; |
| 478 | for (int j = 0; j < 2; j++) { |
| 479 | val *= 16; |
| 480 | char c = str[2*i + j]; |
| 481 | if (c >= '0' && c <= '9') val += c - '0'; |
| 482 | else if (c >= 'A' && c <= 'F') val += (c - 'A') + 10; |
| 483 | else if (c >= 'a' && c <= 'f') val += (c - 'a') + 10; |
| 484 | else return false; |
| 485 | } |
| 486 | tmpColor[i] = static_cast<float>(val) / 255.0f; |
| 487 | } |
| 488 | memcpy(color, tmpColor, sizeof(tmpColor)); |
| 489 | return true; |
| 490 | } |
| 491 | |
Andriy Naborskyy | 39218ba | 2015-08-16 21:32:50 -0700 | [diff] [blame] | 492 | |
| 493 | static bool readFile(ZipFileRO* zip, const char* name, String8& outString) |
Mike Lockwood | ebf9a0d | 2014-10-02 16:08:47 -0700 | [diff] [blame] | 494 | { |
Andriy Naborskyy | 39218ba | 2015-08-16 21:32:50 -0700 | [diff] [blame] | 495 | ZipEntryRO entry = zip->findEntryByName(name); |
Mike Lockwood | ebf9a0d | 2014-10-02 16:08:47 -0700 | [diff] [blame] | 496 | ALOGE_IF(!entry, "couldn't find %s", name); |
| 497 | if (!entry) { |
| 498 | return false; |
| 499 | } |
| 500 | |
Andriy Naborskyy | 39218ba | 2015-08-16 21:32:50 -0700 | [diff] [blame] | 501 | FileMap* entryMap = zip->createEntryFileMap(entry); |
| 502 | zip->releaseEntry(entry); |
Mike Lockwood | ebf9a0d | 2014-10-02 16:08:47 -0700 | [diff] [blame] | 503 | ALOGE_IF(!entryMap, "entryMap is null"); |
| 504 | if (!entryMap) { |
| 505 | return false; |
| 506 | } |
| 507 | |
| 508 | outString.setTo((char const*)entryMap->getDataPtr(), entryMap->getDataLength()); |
Narayan Kamath | 688ff4c | 2015-02-23 15:47:54 +0000 | [diff] [blame] | 509 | delete entryMap; |
Mike Lockwood | ebf9a0d | 2014-10-02 16:08:47 -0700 | [diff] [blame] | 510 | return true; |
| 511 | } |
| 512 | |
Damien Bargiacchi | 0e3d2ab | 2016-08-29 04:11:19 -0700 | [diff] [blame] | 513 | // The font image should be a 96x2 array of character images. The |
| 514 | // columns are the printable ASCII characters 0x20 - 0x7f. The |
| 515 | // top row is regular text; the bottom row is bold. |
| 516 | status_t BootAnimation::initFont(Font* font, const char* fallback) { |
| 517 | status_t status = NO_ERROR; |
Damien Bargiacchi | a704b7d | 2016-02-16 16:55:49 -0800 | [diff] [blame] | 518 | |
Damien Bargiacchi | 0e3d2ab | 2016-08-29 04:11:19 -0700 | [diff] [blame] | 519 | if (font->map != nullptr) { |
| 520 | glGenTextures(1, &font->texture.name); |
| 521 | glBindTexture(GL_TEXTURE_2D, font->texture.name); |
Damien Bargiacchi | a704b7d | 2016-02-16 16:55:49 -0800 | [diff] [blame] | 522 | |
Damien Bargiacchi | 0e3d2ab | 2016-08-29 04:11:19 -0700 | [diff] [blame] | 523 | status = initTexture(font->map, &font->texture.w, &font->texture.h); |
| 524 | |
| 525 | glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
| 526 | glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| 527 | glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); |
| 528 | glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); |
| 529 | } else if (fallback != nullptr) { |
| 530 | status = initTexture(&font->texture, mAssets, fallback); |
| 531 | } else { |
| 532 | return NO_INIT; |
Damien Bargiacchi | a704b7d | 2016-02-16 16:55:49 -0800 | [diff] [blame] | 533 | } |
| 534 | |
Damien Bargiacchi | 0e3d2ab | 2016-08-29 04:11:19 -0700 | [diff] [blame] | 535 | if (status == NO_ERROR) { |
| 536 | font->char_width = font->texture.w / FONT_NUM_COLS; |
| 537 | font->char_height = font->texture.h / FONT_NUM_ROWS / 2; // There are bold and regular rows |
| 538 | } |
| 539 | |
| 540 | return status; |
| 541 | } |
| 542 | |
| 543 | void BootAnimation::drawText(const char* str, const Font& font, bool bold, int* x, int* y) { |
| 544 | glEnable(GL_BLEND); // Allow us to draw on top of the animation |
| 545 | glBindTexture(GL_TEXTURE_2D, font.texture.name); |
| 546 | |
| 547 | const int len = strlen(str); |
| 548 | const int strWidth = font.char_width * len; |
| 549 | |
| 550 | if (*x == TEXT_CENTER_VALUE) { |
| 551 | *x = (mWidth - strWidth) / 2; |
| 552 | } else if (*x < 0) { |
| 553 | *x = mWidth + *x - strWidth; |
| 554 | } |
| 555 | if (*y == TEXT_CENTER_VALUE) { |
| 556 | *y = (mHeight - font.char_height) / 2; |
| 557 | } else if (*y < 0) { |
| 558 | *y = mHeight + *y - font.char_height; |
| 559 | } |
| 560 | |
| 561 | int cropRect[4] = { 0, 0, font.char_width, -font.char_height }; |
| 562 | |
| 563 | for (int i = 0; i < len; i++) { |
| 564 | char c = str[i]; |
| 565 | |
| 566 | if (c < FONT_BEGIN_CHAR || c > FONT_END_CHAR) { |
| 567 | c = '?'; |
| 568 | } |
| 569 | |
| 570 | // Crop the texture to only the pixels in the current glyph |
| 571 | const int charPos = (c - FONT_BEGIN_CHAR); // Position in the list of valid characters |
| 572 | const int row = charPos / FONT_NUM_COLS; |
| 573 | const int col = charPos % FONT_NUM_COLS; |
| 574 | cropRect[0] = col * font.char_width; // Left of column |
| 575 | cropRect[1] = row * font.char_height * 2; // Top of row |
| 576 | // Move down to bottom of regular (one char_heigh) or bold (two char_heigh) line |
| 577 | cropRect[1] += bold ? 2 * font.char_height : font.char_height; |
| 578 | glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES, cropRect); |
| 579 | |
| 580 | glDrawTexiOES(*x, *y, 0, font.char_width, font.char_height); |
| 581 | |
| 582 | *x += font.char_width; |
| 583 | } |
| 584 | |
| 585 | glDisable(GL_BLEND); // Return to the animation's default behaviour |
| 586 | glBindTexture(GL_TEXTURE_2D, 0); |
| 587 | } |
| 588 | |
Damien Bargiacchi | 9071db1 | 2016-10-28 17:38:22 -0700 | [diff] [blame] | 589 | // We render 12 or 24 hour time. |
Damien Bargiacchi | 0e3d2ab | 2016-08-29 04:11:19 -0700 | [diff] [blame] | 590 | void BootAnimation::drawClock(const Font& font, const int xPos, const int yPos) { |
Damien Bargiacchi | 9071db1 | 2016-10-28 17:38:22 -0700 | [diff] [blame] | 591 | static constexpr char TIME_FORMAT_12[] = "%l:%M"; |
| 592 | static constexpr char TIME_FORMAT_24[] = "%H:%M"; |
Damien Bargiacchi | 0e3d2ab | 2016-08-29 04:11:19 -0700 | [diff] [blame] | 593 | static constexpr int TIME_LENGTH = 6; |
| 594 | |
Damien Bargiacchi | a704b7d | 2016-02-16 16:55:49 -0800 | [diff] [blame] | 595 | time_t rawtime; |
| 596 | time(&rawtime); |
| 597 | struct tm* timeInfo = localtime(&rawtime); |
| 598 | |
| 599 | char timeBuff[TIME_LENGTH]; |
Damien Bargiacchi | 9071db1 | 2016-10-28 17:38:22 -0700 | [diff] [blame] | 600 | const char* timeFormat = mTimeFormat12Hour ? TIME_FORMAT_12 : TIME_FORMAT_24; |
| 601 | size_t length = strftime(timeBuff, TIME_LENGTH, timeFormat, timeInfo); |
Damien Bargiacchi | a704b7d | 2016-02-16 16:55:49 -0800 | [diff] [blame] | 602 | |
| 603 | if (length != TIME_LENGTH - 1) { |
| 604 | ALOGE("Couldn't format time; abandoning boot animation clock"); |
| 605 | mClockEnabled = false; |
| 606 | return; |
| 607 | } |
| 608 | |
Damien Bargiacchi | 45a7644 | 2016-12-05 18:02:18 -0800 | [diff] [blame] | 609 | char* out = timeBuff[0] == ' ' ? &timeBuff[1] : &timeBuff[0]; |
Damien Bargiacchi | 0e3d2ab | 2016-08-29 04:11:19 -0700 | [diff] [blame] | 610 | int x = xPos; |
| 611 | int y = yPos; |
Damien Bargiacchi | 45a7644 | 2016-12-05 18:02:18 -0800 | [diff] [blame] | 612 | drawText(out, font, false, &x, &y); |
Damien Bargiacchi | a704b7d | 2016-02-16 16:55:49 -0800 | [diff] [blame] | 613 | } |
| 614 | |
Andriy Naborskyy | 39218ba | 2015-08-16 21:32:50 -0700 | [diff] [blame] | 615 | bool BootAnimation::parseAnimationDesc(Animation& animation) |
Mathias Agopian | a8826d6 | 2009-10-01 03:10:14 -0700 | [diff] [blame] | 616 | { |
Mike Lockwood | ebf9a0d | 2014-10-02 16:08:47 -0700 | [diff] [blame] | 617 | String8 desString; |
| 618 | |
Andriy Naborskyy | 39218ba | 2015-08-16 21:32:50 -0700 | [diff] [blame] | 619 | if (!readFile(animation.zip, "desc.txt", desString)) { |
Narayan Kamath | afd31e0 | 2013-12-03 13:16:03 +0000 | [diff] [blame] | 620 | return false; |
| 621 | } |
Mathias Agopian | a8826d6 | 2009-10-01 03:10:14 -0700 | [diff] [blame] | 622 | char const* s = desString.string(); |
| 623 | |
Mathias Agopian | a8826d6 | 2009-10-01 03:10:14 -0700 | [diff] [blame] | 624 | // Parse the description file |
| 625 | for (;;) { |
| 626 | const char* endl = strstr(s, "\n"); |
Andreas Gampe | cfedceb | 2014-09-30 21:48:18 -0700 | [diff] [blame] | 627 | if (endl == NULL) break; |
Mathias Agopian | a8826d6 | 2009-10-01 03:10:14 -0700 | [diff] [blame] | 628 | String8 line(s, endl - s); |
| 629 | const char* l = line.string(); |
Damien Bargiacchi | a704b7d | 2016-02-16 16:55:49 -0800 | [diff] [blame] | 630 | int fps = 0; |
| 631 | int width = 0; |
| 632 | int height = 0; |
| 633 | int count = 0; |
| 634 | int pause = 0; |
Narayan Kamath | afd31e0 | 2013-12-03 13:16:03 +0000 | [diff] [blame] | 635 | char path[ANIM_ENTRY_NAME_MAX]; |
Jesse Hall | 083b84c | 2014-09-22 10:51:09 -0700 | [diff] [blame] | 636 | char color[7] = "000000"; // default to black if unspecified |
Damien Bargiacchi | 0e3d2ab | 2016-08-29 04:11:19 -0700 | [diff] [blame] | 637 | char clockPos1[TEXT_POS_LEN_MAX + 1] = ""; |
| 638 | char clockPos2[TEXT_POS_LEN_MAX + 1] = ""; |
Jesse Hall | 083b84c | 2014-09-22 10:51:09 -0700 | [diff] [blame] | 639 | |
Kevin Hester | d3782b2 | 2012-04-26 10:38:55 -0700 | [diff] [blame] | 640 | char pathType; |
Mathias Agopian | a8826d6 | 2009-10-01 03:10:14 -0700 | [diff] [blame] | 641 | if (sscanf(l, "%d %d %d", &width, &height, &fps) == 3) { |
Jesse Hall | 083b84c | 2014-09-22 10:51:09 -0700 | [diff] [blame] | 642 | // ALOGD("> w=%d, h=%d, fps=%d", width, height, fps); |
Mathias Agopian | a8826d6 | 2009-10-01 03:10:14 -0700 | [diff] [blame] | 643 | animation.width = width; |
| 644 | animation.height = height; |
| 645 | animation.fps = fps; |
Damien Bargiacchi | 0e3d2ab | 2016-08-29 04:11:19 -0700 | [diff] [blame] | 646 | } else if (sscanf(l, " %c %d %d %s #%6s %16s %16s", |
| 647 | &pathType, &count, &pause, path, color, clockPos1, clockPos2) >= 4) { |
| 648 | //ALOGD("> type=%c, count=%d, pause=%d, path=%s, color=%s, clockPos1=%s, clockPos2=%s", |
| 649 | // pathType, count, pause, path, color, clockPos1, clockPos2); |
Mathias Agopian | a8826d6 | 2009-10-01 03:10:14 -0700 | [diff] [blame] | 650 | Animation::Part part; |
Kevin Hester | d3782b2 | 2012-04-26 10:38:55 -0700 | [diff] [blame] | 651 | part.playUntilComplete = pathType == 'c'; |
Mathias Agopian | a8826d6 | 2009-10-01 03:10:14 -0700 | [diff] [blame] | 652 | part.count = count; |
| 653 | part.pause = pause; |
| 654 | part.path = path; |
Geoffrey Pitsch | d6d9a1d | 2016-06-08 00:38:58 -0700 | [diff] [blame] | 655 | part.audioData = NULL; |
Andriy Naborskyy | 39218ba | 2015-08-16 21:32:50 -0700 | [diff] [blame] | 656 | part.animation = NULL; |
Jesse Hall | 083b84c | 2014-09-22 10:51:09 -0700 | [diff] [blame] | 657 | if (!parseColor(color, part.backgroundColor)) { |
| 658 | ALOGE("> invalid color '#%s'", color); |
| 659 | part.backgroundColor[0] = 0.0f; |
| 660 | part.backgroundColor[1] = 0.0f; |
| 661 | part.backgroundColor[2] = 0.0f; |
| 662 | } |
Damien Bargiacchi | 0e3d2ab | 2016-08-29 04:11:19 -0700 | [diff] [blame] | 663 | parsePosition(clockPos1, clockPos2, &part.clockPosX, &part.clockPosY); |
Mathias Agopian | a8826d6 | 2009-10-01 03:10:14 -0700 | [diff] [blame] | 664 | animation.parts.add(part); |
| 665 | } |
Andriy Naborskyy | 39218ba | 2015-08-16 21:32:50 -0700 | [diff] [blame] | 666 | else if (strcmp(l, "$SYSTEM") == 0) { |
| 667 | // ALOGD("> SYSTEM"); |
| 668 | Animation::Part part; |
| 669 | part.playUntilComplete = false; |
| 670 | part.count = 1; |
| 671 | part.pause = 0; |
Geoffrey Pitsch | d6d9a1d | 2016-06-08 00:38:58 -0700 | [diff] [blame] | 672 | part.audioData = NULL; |
Andriy Naborskyy | 39218ba | 2015-08-16 21:32:50 -0700 | [diff] [blame] | 673 | part.animation = loadAnimation(String8(SYSTEM_BOOTANIMATION_FILE)); |
| 674 | if (part.animation != NULL) |
| 675 | animation.parts.add(part); |
| 676 | } |
Mathias Agopian | a8826d6 | 2009-10-01 03:10:14 -0700 | [diff] [blame] | 677 | s = ++endl; |
| 678 | } |
| 679 | |
Andriy Naborskyy | 39218ba | 2015-08-16 21:32:50 -0700 | [diff] [blame] | 680 | return true; |
| 681 | } |
| 682 | |
| 683 | bool BootAnimation::preloadZip(Animation& animation) |
| 684 | { |
Mathias Agopian | a8826d6 | 2009-10-01 03:10:14 -0700 | [diff] [blame] | 685 | // read all the data structures |
| 686 | const size_t pcount = animation.parts.size(); |
Narayan Kamath | afd31e0 | 2013-12-03 13:16:03 +0000 | [diff] [blame] | 687 | void *cookie = NULL; |
Geoffrey Pitsch | dd214a7 | 2016-06-27 17:14:30 -0400 | [diff] [blame] | 688 | ZipFileRO* zip = animation.zip; |
| 689 | if (!zip->startIteration(&cookie)) { |
Narayan Kamath | afd31e0 | 2013-12-03 13:16:03 +0000 | [diff] [blame] | 690 | return false; |
| 691 | } |
| 692 | |
Geoffrey Pitsch | a91a2d7 | 2016-07-12 14:46:19 -0400 | [diff] [blame] | 693 | Animation::Part* partWithAudio = NULL; |
Narayan Kamath | afd31e0 | 2013-12-03 13:16:03 +0000 | [diff] [blame] | 694 | ZipEntryRO entry; |
| 695 | char name[ANIM_ENTRY_NAME_MAX]; |
Geoffrey Pitsch | dd214a7 | 2016-06-27 17:14:30 -0400 | [diff] [blame] | 696 | while ((entry = zip->nextEntry(cookie)) != NULL) { |
| 697 | const int foundEntryName = zip->getEntryFileName(entry, name, ANIM_ENTRY_NAME_MAX); |
Narayan Kamath | afd31e0 | 2013-12-03 13:16:03 +0000 | [diff] [blame] | 698 | if (foundEntryName > ANIM_ENTRY_NAME_MAX || foundEntryName == -1) { |
| 699 | ALOGE("Error fetching entry file name"); |
| 700 | continue; |
| 701 | } |
| 702 | |
| 703 | const String8 entryName(name); |
| 704 | const String8 path(entryName.getPathDir()); |
| 705 | const String8 leaf(entryName.getPathLeaf()); |
| 706 | if (leaf.size() > 0) { |
Damien Bargiacchi | 0e3d2ab | 2016-08-29 04:11:19 -0700 | [diff] [blame] | 707 | if (entryName == CLOCK_FONT_ZIP_NAME) { |
| 708 | FileMap* map = zip->createEntryFileMap(entry); |
| 709 | if (map) { |
| 710 | animation.clockFont.map = map; |
| 711 | } |
| 712 | continue; |
| 713 | } |
| 714 | |
Geoffrey Pitsch | dd214a7 | 2016-06-27 17:14:30 -0400 | [diff] [blame] | 715 | for (size_t j = 0; j < pcount; j++) { |
Narayan Kamath | afd31e0 | 2013-12-03 13:16:03 +0000 | [diff] [blame] | 716 | if (path == animation.parts[j].path) { |
Narayan Kamath | 4600dd0 | 2015-06-16 12:02:57 +0100 | [diff] [blame] | 717 | uint16_t method; |
Narayan Kamath | afd31e0 | 2013-12-03 13:16:03 +0000 | [diff] [blame] | 718 | // supports only stored png files |
Geoffrey Pitsch | dd214a7 | 2016-06-27 17:14:30 -0400 | [diff] [blame] | 719 | if (zip->getEntryInfo(entry, &method, NULL, NULL, NULL, NULL, NULL)) { |
Narayan Kamath | afd31e0 | 2013-12-03 13:16:03 +0000 | [diff] [blame] | 720 | if (method == ZipFileRO::kCompressStored) { |
Geoffrey Pitsch | dd214a7 | 2016-06-27 17:14:30 -0400 | [diff] [blame] | 721 | FileMap* map = zip->createEntryFileMap(entry); |
Narayan Kamath | afd31e0 | 2013-12-03 13:16:03 +0000 | [diff] [blame] | 722 | if (map) { |
Narayan Kamath | afd31e0 | 2013-12-03 13:16:03 +0000 | [diff] [blame] | 723 | Animation::Part& part(animation.parts.editItemAt(j)); |
Mike Lockwood | ebf9a0d | 2014-10-02 16:08:47 -0700 | [diff] [blame] | 724 | if (leaf == "audio.wav") { |
| 725 | // a part may have at most one audio file |
Geoffrey Pitsch | d6d9a1d | 2016-06-08 00:38:58 -0700 | [diff] [blame] | 726 | part.audioData = (uint8_t *)map->getDataPtr(); |
| 727 | part.audioLength = map->getDataLength(); |
Geoffrey Pitsch | a91a2d7 | 2016-07-12 14:46:19 -0400 | [diff] [blame] | 728 | partWithAudio = ∂ |
Geoffrey Pitsch | dd214a7 | 2016-06-27 17:14:30 -0400 | [diff] [blame] | 729 | } else if (leaf == "trim.txt") { |
| 730 | part.trimData.setTo((char const*)map->getDataPtr(), |
| 731 | map->getDataLength()); |
Mike Lockwood | ebf9a0d | 2014-10-02 16:08:47 -0700 | [diff] [blame] | 732 | } else { |
| 733 | Animation::Frame frame; |
| 734 | frame.name = leaf; |
| 735 | frame.map = map; |
Geoffrey Pitsch | dd214a7 | 2016-06-27 17:14:30 -0400 | [diff] [blame] | 736 | frame.trimWidth = animation.width; |
| 737 | frame.trimHeight = animation.height; |
| 738 | frame.trimX = 0; |
| 739 | frame.trimY = 0; |
Mike Lockwood | ebf9a0d | 2014-10-02 16:08:47 -0700 | [diff] [blame] | 740 | part.frames.add(frame); |
| 741 | } |
Mathias Agopian | a8826d6 | 2009-10-01 03:10:14 -0700 | [diff] [blame] | 742 | } |
Geoffrey Pitsch | d6d9a1d | 2016-06-08 00:38:58 -0700 | [diff] [blame] | 743 | } else { |
| 744 | ALOGE("bootanimation.zip is compressed; must be only stored"); |
Mathias Agopian | a8826d6 | 2009-10-01 03:10:14 -0700 | [diff] [blame] | 745 | } |
| 746 | } |
| 747 | } |
| 748 | } |
| 749 | } |
| 750 | } |
| 751 | |
Geoffrey Pitsch | dd214a7 | 2016-06-27 17:14:30 -0400 | [diff] [blame] | 752 | // If there is trimData present, override the positioning defaults. |
| 753 | for (Animation::Part& part : animation.parts) { |
| 754 | const char* trimDataStr = part.trimData.string(); |
| 755 | for (size_t frameIdx = 0; frameIdx < part.frames.size(); frameIdx++) { |
| 756 | const char* endl = strstr(trimDataStr, "\n"); |
| 757 | // No more trimData for this part. |
| 758 | if (endl == NULL) { |
| 759 | break; |
| 760 | } |
| 761 | String8 line(trimDataStr, endl - trimDataStr); |
| 762 | const char* lineStr = line.string(); |
| 763 | trimDataStr = ++endl; |
| 764 | int width = 0, height = 0, x = 0, y = 0; |
| 765 | if (sscanf(lineStr, "%dx%d+%d+%d", &width, &height, &x, &y) == 4) { |
| 766 | Animation::Frame& frame(part.frames.editItemAt(frameIdx)); |
| 767 | frame.trimWidth = width; |
| 768 | frame.trimHeight = height; |
| 769 | frame.trimX = x; |
| 770 | frame.trimY = y; |
| 771 | } else { |
| 772 | ALOGE("Error parsing trim.txt, line: %s", lineStr); |
| 773 | break; |
| 774 | } |
| 775 | } |
| 776 | } |
| 777 | |
Geoffrey Pitsch | d6d9a1d | 2016-06-08 00:38:58 -0700 | [diff] [blame] | 778 | // Create and initialize audioplay if there is a wav file in any of the animations. |
Geoffrey Pitsch | a917353 | 2016-07-19 14:56:39 -0400 | [diff] [blame] | 779 | // Do it on a separate thread so we don't hold up the animation intro. |
Geoffrey Pitsch | a91a2d7 | 2016-07-12 14:46:19 -0400 | [diff] [blame] | 780 | if (partWithAudio != NULL) { |
Geoffrey Pitsch | d6d9a1d | 2016-06-08 00:38:58 -0700 | [diff] [blame] | 781 | ALOGD("found audio.wav, creating playback engine"); |
Geoffrey Pitsch | a917353 | 2016-07-19 14:56:39 -0400 | [diff] [blame] | 782 | mInitAudioThread = new InitAudioThread(partWithAudio->audioData, |
| 783 | partWithAudio->audioLength); |
| 784 | mInitAudioThread->run("BootAnimation::InitAudioThread", PRIORITY_NORMAL); |
Geoffrey Pitsch | d6d9a1d | 2016-06-08 00:38:58 -0700 | [diff] [blame] | 785 | } |
| 786 | |
Geoffrey Pitsch | dd214a7 | 2016-06-27 17:14:30 -0400 | [diff] [blame] | 787 | zip->endIteration(cookie); |
Narayan Kamath | afd31e0 | 2013-12-03 13:16:03 +0000 | [diff] [blame] | 788 | |
Andriy Naborskyy | 39218ba | 2015-08-16 21:32:50 -0700 | [diff] [blame] | 789 | return true; |
| 790 | } |
| 791 | |
| 792 | bool BootAnimation::movie() |
| 793 | { |
Andriy Naborskyy | 39218ba | 2015-08-16 21:32:50 -0700 | [diff] [blame] | 794 | Animation* animation = loadAnimation(mZipFileName); |
| 795 | if (animation == NULL) |
| 796 | return false; |
| 797 | |
Damien Bargiacchi | 9748086 | 2016-03-29 14:55:55 -0700 | [diff] [blame] | 798 | bool anyPartHasClock = false; |
| 799 | for (size_t i=0; i < animation->parts.size(); i++) { |
Damien Bargiacchi | 0e3d2ab | 2016-08-29 04:11:19 -0700 | [diff] [blame] | 800 | if(validClock(animation->parts[i])) { |
Damien Bargiacchi | 9748086 | 2016-03-29 14:55:55 -0700 | [diff] [blame] | 801 | anyPartHasClock = true; |
| 802 | break; |
| 803 | } |
| 804 | } |
| 805 | if (!anyPartHasClock) { |
| 806 | mClockEnabled = false; |
| 807 | } |
| 808 | |
Sai Kiran Korwar | 2716749 | 2015-07-07 20:00:06 +0530 | [diff] [blame] | 809 | // Check if npot textures are supported |
| 810 | mUseNpotTextures = false; |
| 811 | String8 gl_extensions; |
| 812 | const char* exts = reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS)); |
| 813 | if (!exts) { |
| 814 | glGetError(); |
| 815 | } else { |
| 816 | gl_extensions.setTo(exts); |
| 817 | if ((gl_extensions.find("GL_ARB_texture_non_power_of_two") != -1) || |
| 818 | (gl_extensions.find("GL_OES_texture_npot") != -1)) { |
| 819 | mUseNpotTextures = true; |
| 820 | } |
| 821 | } |
| 822 | |
Damien Bargiacchi | a704b7d | 2016-02-16 16:55:49 -0800 | [diff] [blame] | 823 | // Blend required to draw time on top of animation frames. |
| 824 | glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
Mathias Agopian | a8826d6 | 2009-10-01 03:10:14 -0700 | [diff] [blame] | 825 | glShadeModel(GL_FLAT); |
| 826 | glDisable(GL_DITHER); |
| 827 | glDisable(GL_SCISSOR_TEST); |
| 828 | glDisable(GL_BLEND); |
Mathias Agopian | a8826d6 | 2009-10-01 03:10:14 -0700 | [diff] [blame] | 829 | |
| 830 | glBindTexture(GL_TEXTURE_2D, 0); |
| 831 | glEnable(GL_TEXTURE_2D); |
| 832 | glTexEnvx(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); |
| 833 | glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); |
| 834 | glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); |
| 835 | glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); |
| 836 | glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); |
| 837 | |
Damien Bargiacchi | 0e3d2ab | 2016-08-29 04:11:19 -0700 | [diff] [blame] | 838 | bool clockFontInitialized = false; |
Damien Bargiacchi | a704b7d | 2016-02-16 16:55:49 -0800 | [diff] [blame] | 839 | if (mClockEnabled) { |
Damien Bargiacchi | 0e3d2ab | 2016-08-29 04:11:19 -0700 | [diff] [blame] | 840 | clockFontInitialized = |
| 841 | (initFont(&animation->clockFont, CLOCK_FONT_ASSET) == NO_ERROR); |
| 842 | mClockEnabled = clockFontInitialized; |
Damien Bargiacchi | a704b7d | 2016-02-16 16:55:49 -0800 | [diff] [blame] | 843 | } |
| 844 | |
Damien Bargiacchi | 9748086 | 2016-03-29 14:55:55 -0700 | [diff] [blame] | 845 | if (mClockEnabled && !updateIsTimeAccurate()) { |
| 846 | mTimeCheckThread = new TimeCheckThread(this); |
| 847 | mTimeCheckThread->run("BootAnimation::TimeCheckThread", PRIORITY_NORMAL); |
| 848 | } |
| 849 | |
Andriy Naborskyy | 39218ba | 2015-08-16 21:32:50 -0700 | [diff] [blame] | 850 | playAnimation(*animation); |
Damien Bargiacchi | 9748086 | 2016-03-29 14:55:55 -0700 | [diff] [blame] | 851 | |
Geoffrey Pitsch | a917353 | 2016-07-19 14:56:39 -0400 | [diff] [blame] | 852 | if (mTimeCheckThread != nullptr) { |
Damien Bargiacchi | 9748086 | 2016-03-29 14:55:55 -0700 | [diff] [blame] | 853 | mTimeCheckThread->requestExit(); |
Geoffrey Pitsch | a917353 | 2016-07-19 14:56:39 -0400 | [diff] [blame] | 854 | mTimeCheckThread = nullptr; |
| 855 | } |
| 856 | |
| 857 | if (mInitAudioThread != nullptr) { |
| 858 | mInitAudioThread->requestExit(); |
| 859 | mInitAudioThread = nullptr; |
Damien Bargiacchi | 9748086 | 2016-03-29 14:55:55 -0700 | [diff] [blame] | 860 | } |
| 861 | |
Andriy Naborskyy | 39218ba | 2015-08-16 21:32:50 -0700 | [diff] [blame] | 862 | releaseAnimation(animation); |
| 863 | |
Damien Bargiacchi | 0e3d2ab | 2016-08-29 04:11:19 -0700 | [diff] [blame] | 864 | if (clockFontInitialized) { |
| 865 | glDeleteTextures(1, &animation->clockFont.texture.name); |
Andriy Naborskyy | 815e51d | 2016-03-24 16:43:34 -0700 | [diff] [blame] | 866 | } |
| 867 | |
Andriy Naborskyy | 39218ba | 2015-08-16 21:32:50 -0700 | [diff] [blame] | 868 | return false; |
| 869 | } |
| 870 | |
| 871 | bool BootAnimation::playAnimation(const Animation& animation) |
| 872 | { |
| 873 | const size_t pcount = animation.parts.size(); |
Mathias Agopian | a8826d6 | 2009-10-01 03:10:14 -0700 | [diff] [blame] | 874 | nsecs_t frameDuration = s2ns(1) / animation.fps; |
Geoffrey Pitsch | dd214a7 | 2016-06-27 17:14:30 -0400 | [diff] [blame] | 875 | const int animationX = (mWidth - animation.width) / 2; |
| 876 | const int animationY = (mHeight - animation.height) / 2; |
Mathias Agopian | 9f3020d | 2009-11-06 16:30:18 -0800 | [diff] [blame] | 877 | |
Narayan Kamath | afd31e0 | 2013-12-03 13:16:03 +0000 | [diff] [blame] | 878 | for (size_t i=0 ; i<pcount ; i++) { |
Mathias Agopian | a8826d6 | 2009-10-01 03:10:14 -0700 | [diff] [blame] | 879 | const Animation::Part& part(animation.parts[i]); |
| 880 | const size_t fcount = part.frames.size(); |
| 881 | glBindTexture(GL_TEXTURE_2D, 0); |
| 882 | |
Andriy Naborskyy | 39218ba | 2015-08-16 21:32:50 -0700 | [diff] [blame] | 883 | // Handle animation package |
| 884 | if (part.animation != NULL) { |
| 885 | playAnimation(*part.animation); |
| 886 | if (exitPending()) |
| 887 | break; |
| 888 | continue; //to next part |
| 889 | } |
| 890 | |
Mathias Agopian | a8826d6 | 2009-10-01 03:10:14 -0700 | [diff] [blame] | 891 | for (int r=0 ; !part.count || r<part.count ; r++) { |
Kevin Hester | d3782b2 | 2012-04-26 10:38:55 -0700 | [diff] [blame] | 892 | // Exit any non playuntil complete parts immediately |
| 893 | if(exitPending() && !part.playUntilComplete) |
| 894 | break; |
| 895 | |
Mike Lockwood | ebf9a0d | 2014-10-02 16:08:47 -0700 | [diff] [blame] | 896 | // only play audio file the first time we animate the part |
Geoffrey Pitsch | 290c435 | 2016-08-09 14:35:10 -0400 | [diff] [blame] | 897 | if (r == 0 && part.audioData && playSoundsAllowed()) { |
| 898 | ALOGD("playing clip for part%d, size=%d", (int) i, part.audioLength); |
Geoffrey Pitsch | a917353 | 2016-07-19 14:56:39 -0400 | [diff] [blame] | 899 | // Block until the audio engine is finished initializing. |
| 900 | if (mInitAudioThread != nullptr) { |
| 901 | mInitAudioThread->join(); |
| 902 | } |
Geoffrey Pitsch | 290c435 | 2016-08-09 14:35:10 -0400 | [diff] [blame] | 903 | audioplay::playClip(part.audioData, part.audioLength); |
Mike Lockwood | ebf9a0d | 2014-10-02 16:08:47 -0700 | [diff] [blame] | 904 | } |
| 905 | |
Jesse Hall | 083b84c | 2014-09-22 10:51:09 -0700 | [diff] [blame] | 906 | glClearColor( |
| 907 | part.backgroundColor[0], |
| 908 | part.backgroundColor[1], |
| 909 | part.backgroundColor[2], |
| 910 | 1.0f); |
| 911 | |
Narayan Kamath | afd31e0 | 2013-12-03 13:16:03 +0000 | [diff] [blame] | 912 | for (size_t j=0 ; j<fcount && (!exitPending() || part.playUntilComplete) ; j++) { |
Mathias Agopian | a8826d6 | 2009-10-01 03:10:14 -0700 | [diff] [blame] | 913 | const Animation::Frame& frame(part.frames[j]); |
Mathias Agopian | db7dd2a | 2012-05-12 15:08:21 -0700 | [diff] [blame] | 914 | nsecs_t lastFrame = systemTime(); |
Mathias Agopian | a8826d6 | 2009-10-01 03:10:14 -0700 | [diff] [blame] | 915 | |
| 916 | if (r > 0) { |
| 917 | glBindTexture(GL_TEXTURE_2D, frame.tid); |
| 918 | } else { |
| 919 | if (part.count != 1) { |
| 920 | glGenTextures(1, &frame.tid); |
| 921 | glBindTexture(GL_TEXTURE_2D, frame.tid); |
| 922 | glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); |
| 923 | glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); |
| 924 | } |
Damien Bargiacchi | 0e3d2ab | 2016-08-29 04:11:19 -0700 | [diff] [blame] | 925 | int w, h; |
| 926 | initTexture(frame.map, &w, &h); |
Mathias Agopian | a8826d6 | 2009-10-01 03:10:14 -0700 | [diff] [blame] | 927 | } |
| 928 | |
Geoffrey Pitsch | dd214a7 | 2016-06-27 17:14:30 -0400 | [diff] [blame] | 929 | const int xc = animationX + frame.trimX; |
| 930 | const int yc = animationY + frame.trimY; |
| 931 | Region clearReg(Rect(mWidth, mHeight)); |
| 932 | clearReg.subtractSelf(Rect(xc, yc, xc+frame.trimWidth, yc+frame.trimHeight)); |
Mathias Agopian | 9f3020d | 2009-11-06 16:30:18 -0800 | [diff] [blame] | 933 | if (!clearReg.isEmpty()) { |
| 934 | Region::const_iterator head(clearReg.begin()); |
| 935 | Region::const_iterator tail(clearReg.end()); |
| 936 | glEnable(GL_SCISSOR_TEST); |
| 937 | while (head != tail) { |
Andreas Gampe | cfedceb | 2014-09-30 21:48:18 -0700 | [diff] [blame] | 938 | const Rect& r2(*head++); |
Geoffrey Pitsch | dd214a7 | 2016-06-27 17:14:30 -0400 | [diff] [blame] | 939 | glScissor(r2.left, mHeight - r2.bottom, r2.width(), r2.height()); |
Mathias Agopian | 9f3020d | 2009-11-06 16:30:18 -0800 | [diff] [blame] | 940 | glClear(GL_COLOR_BUFFER_BIT); |
| 941 | } |
| 942 | glDisable(GL_SCISSOR_TEST); |
| 943 | } |
Geoffrey Pitsch | dd214a7 | 2016-06-27 17:14:30 -0400 | [diff] [blame] | 944 | // specify the y center as ceiling((mHeight - frame.trimHeight) / 2) |
| 945 | // which is equivalent to mHeight - (yc + frame.trimHeight) |
| 946 | glDrawTexiOES(xc, mHeight - (yc + frame.trimHeight), |
| 947 | 0, frame.trimWidth, frame.trimHeight); |
Damien Bargiacchi | 0e3d2ab | 2016-08-29 04:11:19 -0700 | [diff] [blame] | 948 | if (mClockEnabled && mTimeIsAccurate && validClock(part)) { |
| 949 | drawClock(animation.clockFont, part.clockPosX, part.clockPosY); |
Damien Bargiacchi | a704b7d | 2016-02-16 16:55:49 -0800 | [diff] [blame] | 950 | } |
| 951 | |
Mathias Agopian | a8826d6 | 2009-10-01 03:10:14 -0700 | [diff] [blame] | 952 | eglSwapBuffers(mDisplay, mSurface); |
| 953 | |
| 954 | nsecs_t now = systemTime(); |
| 955 | nsecs_t delay = frameDuration - (now - lastFrame); |
Mathias Agopian | db7dd2a | 2012-05-12 15:08:21 -0700 | [diff] [blame] | 956 | //ALOGD("%lld, %lld", ns2ms(now - lastFrame), ns2ms(delay)); |
Mathias Agopian | a8826d6 | 2009-10-01 03:10:14 -0700 | [diff] [blame] | 957 | lastFrame = now; |
Mathias Agopian | db7dd2a | 2012-05-12 15:08:21 -0700 | [diff] [blame] | 958 | |
| 959 | if (delay > 0) { |
| 960 | struct timespec spec; |
| 961 | spec.tv_sec = (now + delay) / 1000000000; |
| 962 | spec.tv_nsec = (now + delay) % 1000000000; |
| 963 | int err; |
| 964 | do { |
| 965 | err = clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &spec, NULL); |
| 966 | } while (err<0 && errno == EINTR); |
| 967 | } |
Kevin Hester | d3782b2 | 2012-04-26 10:38:55 -0700 | [diff] [blame] | 968 | |
| 969 | checkExit(); |
Mathias Agopian | a8826d6 | 2009-10-01 03:10:14 -0700 | [diff] [blame] | 970 | } |
Kevin Hester | d3782b2 | 2012-04-26 10:38:55 -0700 | [diff] [blame] | 971 | |
Mathias Agopian | a8826d6 | 2009-10-01 03:10:14 -0700 | [diff] [blame] | 972 | usleep(part.pause * ns2us(frameDuration)); |
Kevin Hester | d3782b2 | 2012-04-26 10:38:55 -0700 | [diff] [blame] | 973 | |
| 974 | // For infinite parts, we've now played them at least once, so perhaps exit |
| 975 | if(exitPending() && !part.count) |
| 976 | break; |
Mathias Agopian | a8826d6 | 2009-10-01 03:10:14 -0700 | [diff] [blame] | 977 | } |
| 978 | |
Geoffrey Pitsch | 2fb30fb | 2016-07-06 16:16:20 -0400 | [diff] [blame] | 979 | } |
| 980 | |
| 981 | // Free textures created for looping parts now that the animation is done. |
| 982 | for (const Animation::Part& part : animation.parts) { |
Mathias Agopian | a8826d6 | 2009-10-01 03:10:14 -0700 | [diff] [blame] | 983 | if (part.count != 1) { |
Geoffrey Pitsch | 2fb30fb | 2016-07-06 16:16:20 -0400 | [diff] [blame] | 984 | const size_t fcount = part.frames.size(); |
| 985 | for (size_t j = 0; j < fcount; j++) { |
Mathias Agopian | a8826d6 | 2009-10-01 03:10:14 -0700 | [diff] [blame] | 986 | const Animation::Frame& frame(part.frames[j]); |
| 987 | glDeleteTextures(1, &frame.tid); |
| 988 | } |
| 989 | } |
| 990 | } |
Geoffrey Pitsch | d6d9a1d | 2016-06-08 00:38:58 -0700 | [diff] [blame] | 991 | |
| 992 | // we've finally played everything we're going to play |
| 993 | audioplay::setPlaying(false); |
| 994 | audioplay::destroy(); |
| 995 | |
Andriy Naborskyy | 39218ba | 2015-08-16 21:32:50 -0700 | [diff] [blame] | 996 | return true; |
Mathias Agopian | a8826d6 | 2009-10-01 03:10:14 -0700 | [diff] [blame] | 997 | } |
| 998 | |
Andriy Naborskyy | 39218ba | 2015-08-16 21:32:50 -0700 | [diff] [blame] | 999 | void BootAnimation::releaseAnimation(Animation* animation) const |
| 1000 | { |
| 1001 | for (Vector<Animation::Part>::iterator it = animation->parts.begin(), |
| 1002 | e = animation->parts.end(); it != e; ++it) { |
| 1003 | if (it->animation) |
| 1004 | releaseAnimation(it->animation); |
| 1005 | } |
| 1006 | if (animation->zip) |
| 1007 | delete animation->zip; |
| 1008 | delete animation; |
| 1009 | } |
| 1010 | |
| 1011 | BootAnimation::Animation* BootAnimation::loadAnimation(const String8& fn) |
| 1012 | { |
| 1013 | if (mLoadedFiles.indexOf(fn) >= 0) { |
| 1014 | ALOGE("File \"%s\" is already loaded. Cyclic ref is not allowed", |
| 1015 | fn.string()); |
| 1016 | return NULL; |
| 1017 | } |
| 1018 | ZipFileRO *zip = ZipFileRO::open(fn); |
| 1019 | if (zip == NULL) { |
| 1020 | ALOGE("Failed to open animation zip \"%s\": %s", |
| 1021 | fn.string(), strerror(errno)); |
| 1022 | return NULL; |
| 1023 | } |
| 1024 | |
| 1025 | Animation *animation = new Animation; |
| 1026 | animation->fileName = fn; |
| 1027 | animation->zip = zip; |
Damien Bargiacchi | 0e3d2ab | 2016-08-29 04:11:19 -0700 | [diff] [blame] | 1028 | animation->clockFont.map = nullptr; |
Andriy Naborskyy | 39218ba | 2015-08-16 21:32:50 -0700 | [diff] [blame] | 1029 | mLoadedFiles.add(animation->fileName); |
| 1030 | |
| 1031 | parseAnimationDesc(*animation); |
Geoffrey Pitsch | a91a2d7 | 2016-07-12 14:46:19 -0400 | [diff] [blame] | 1032 | if (!preloadZip(*animation)) { |
| 1033 | return NULL; |
| 1034 | } |
| 1035 | |
Andriy Naborskyy | 39218ba | 2015-08-16 21:32:50 -0700 | [diff] [blame] | 1036 | |
| 1037 | mLoadedFiles.remove(fn); |
| 1038 | return animation; |
| 1039 | } |
Damien Bargiacchi | 9748086 | 2016-03-29 14:55:55 -0700 | [diff] [blame] | 1040 | |
Geoffrey Pitsch | 290c435 | 2016-08-09 14:35:10 -0400 | [diff] [blame] | 1041 | bool BootAnimation::playSoundsAllowed() const { |
| 1042 | // Only play sounds for system boots, not runtime restarts. |
| 1043 | if (!mSystemBoot) { |
| 1044 | return false; |
| 1045 | } |
| 1046 | |
| 1047 | // Read the system property to see if we should play the sound. |
| 1048 | // If it's not present, default to allowed. |
| 1049 | if (!property_get_bool(PLAY_SOUND_PROP_NAME, 1)) { |
| 1050 | return false; |
| 1051 | } |
| 1052 | |
| 1053 | // Don't play sounds if this is a reboot due to an error. |
| 1054 | char bootreason[PROPERTY_VALUE_MAX]; |
| 1055 | if (property_get(BOOTREASON_PROP_NAME, bootreason, nullptr) > 0) { |
| 1056 | for (const auto& str : PLAY_SOUND_BOOTREASON_BLACKLIST) { |
| 1057 | if (strcasecmp(str.c_str(), bootreason) == 0) { |
| 1058 | return false; |
| 1059 | } |
| 1060 | } |
| 1061 | } |
| 1062 | return true; |
| 1063 | } |
| 1064 | |
Damien Bargiacchi | 9748086 | 2016-03-29 14:55:55 -0700 | [diff] [blame] | 1065 | bool BootAnimation::updateIsTimeAccurate() { |
| 1066 | static constexpr long long MAX_TIME_IN_PAST = 60000LL * 60LL * 24LL * 30LL; // 30 days |
| 1067 | static constexpr long long MAX_TIME_IN_FUTURE = 60000LL * 90LL; // 90 minutes |
| 1068 | |
| 1069 | if (mTimeIsAccurate) { |
| 1070 | return true; |
| 1071 | } |
| 1072 | |
| 1073 | struct stat statResult; |
Damien Bargiacchi | 9071db1 | 2016-10-28 17:38:22 -0700 | [diff] [blame] | 1074 | |
| 1075 | if(stat(TIME_FORMAT_12_HOUR_FLAG_FILE_PATH, &statResult) == 0) { |
| 1076 | mTimeFormat12Hour = true; |
| 1077 | } |
| 1078 | |
Damien Bargiacchi | 9748086 | 2016-03-29 14:55:55 -0700 | [diff] [blame] | 1079 | if(stat(ACCURATE_TIME_FLAG_FILE_PATH, &statResult) == 0) { |
| 1080 | mTimeIsAccurate = true; |
| 1081 | return true; |
| 1082 | } |
| 1083 | |
| 1084 | FILE* file = fopen(LAST_TIME_CHANGED_FILE_PATH, "r"); |
| 1085 | if (file != NULL) { |
| 1086 | long long lastChangedTime = 0; |
| 1087 | fscanf(file, "%lld", &lastChangedTime); |
| 1088 | fclose(file); |
| 1089 | if (lastChangedTime > 0) { |
| 1090 | struct timespec now; |
| 1091 | clock_gettime(CLOCK_REALTIME, &now); |
| 1092 | // Match the Java timestamp format |
| 1093 | long long rtcNow = (now.tv_sec * 1000LL) + (now.tv_nsec / 1000000LL); |
Damien Bargiacchi | 9676281 | 2016-07-12 15:53:40 -0700 | [diff] [blame] | 1094 | if (ACCURATE_TIME_EPOCH < rtcNow |
| 1095 | && lastChangedTime > (rtcNow - MAX_TIME_IN_PAST) |
| 1096 | && lastChangedTime < (rtcNow + MAX_TIME_IN_FUTURE)) { |
Damien Bargiacchi | 9748086 | 2016-03-29 14:55:55 -0700 | [diff] [blame] | 1097 | mTimeIsAccurate = true; |
| 1098 | } |
| 1099 | } |
| 1100 | } |
| 1101 | |
| 1102 | return mTimeIsAccurate; |
| 1103 | } |
| 1104 | |
| 1105 | BootAnimation::TimeCheckThread::TimeCheckThread(BootAnimation* bootAnimation) : Thread(false), |
| 1106 | mInotifyFd(-1), mSystemWd(-1), mTimeWd(-1), mBootAnimation(bootAnimation) {} |
| 1107 | |
| 1108 | BootAnimation::TimeCheckThread::~TimeCheckThread() { |
| 1109 | // mInotifyFd may be -1 but that's ok since we're not at risk of attempting to close a valid FD. |
| 1110 | close(mInotifyFd); |
| 1111 | } |
| 1112 | |
| 1113 | bool BootAnimation::TimeCheckThread::threadLoop() { |
| 1114 | bool shouldLoop = doThreadLoop() && !mBootAnimation->mTimeIsAccurate |
| 1115 | && mBootAnimation->mClockEnabled; |
| 1116 | if (!shouldLoop) { |
| 1117 | close(mInotifyFd); |
| 1118 | mInotifyFd = -1; |
| 1119 | } |
| 1120 | return shouldLoop; |
| 1121 | } |
| 1122 | |
| 1123 | bool BootAnimation::TimeCheckThread::doThreadLoop() { |
| 1124 | static constexpr int BUFF_LEN (10 * (sizeof(struct inotify_event) + NAME_MAX + 1)); |
| 1125 | |
| 1126 | // Poll instead of doing a blocking read so the Thread can exit if requested. |
| 1127 | struct pollfd pfd = { mInotifyFd, POLLIN, 0 }; |
| 1128 | ssize_t pollResult = poll(&pfd, 1, 1000); |
| 1129 | |
| 1130 | if (pollResult == 0) { |
| 1131 | return true; |
| 1132 | } else if (pollResult < 0) { |
| 1133 | ALOGE("Could not poll inotify events"); |
| 1134 | return false; |
| 1135 | } |
| 1136 | |
| 1137 | char buff[BUFF_LEN] __attribute__ ((aligned(__alignof__(struct inotify_event))));; |
| 1138 | ssize_t length = read(mInotifyFd, buff, BUFF_LEN); |
| 1139 | if (length == 0) { |
| 1140 | return true; |
| 1141 | } else if (length < 0) { |
| 1142 | ALOGE("Could not read inotify events"); |
| 1143 | return false; |
| 1144 | } |
| 1145 | |
| 1146 | const struct inotify_event *event; |
| 1147 | for (char* ptr = buff; ptr < buff + length; ptr += sizeof(struct inotify_event) + event->len) { |
| 1148 | event = (const struct inotify_event *) ptr; |
| 1149 | if (event->wd == mSystemWd && strcmp(SYSTEM_TIME_DIR_NAME, event->name) == 0) { |
| 1150 | addTimeDirWatch(); |
| 1151 | } else if (event->wd == mTimeWd && (strcmp(LAST_TIME_CHANGED_FILE_NAME, event->name) == 0 |
| 1152 | || strcmp(ACCURATE_TIME_FLAG_FILE_NAME, event->name) == 0)) { |
| 1153 | return !mBootAnimation->updateIsTimeAccurate(); |
| 1154 | } |
| 1155 | } |
| 1156 | |
| 1157 | return true; |
| 1158 | } |
| 1159 | |
| 1160 | void BootAnimation::TimeCheckThread::addTimeDirWatch() { |
| 1161 | mTimeWd = inotify_add_watch(mInotifyFd, SYSTEM_TIME_DIR_PATH, |
| 1162 | IN_CLOSE_WRITE | IN_MOVED_TO | IN_ATTRIB); |
| 1163 | if (mTimeWd > 0) { |
| 1164 | // No need to watch for the time directory to be created if it already exists |
| 1165 | inotify_rm_watch(mInotifyFd, mSystemWd); |
| 1166 | mSystemWd = -1; |
| 1167 | } |
| 1168 | } |
| 1169 | |
| 1170 | status_t BootAnimation::TimeCheckThread::readyToRun() { |
| 1171 | mInotifyFd = inotify_init(); |
| 1172 | if (mInotifyFd < 0) { |
| 1173 | ALOGE("Could not initialize inotify fd"); |
| 1174 | return NO_INIT; |
| 1175 | } |
| 1176 | |
| 1177 | mSystemWd = inotify_add_watch(mInotifyFd, SYSTEM_DATA_DIR_PATH, IN_CREATE | IN_ATTRIB); |
| 1178 | if (mSystemWd < 0) { |
| 1179 | close(mInotifyFd); |
| 1180 | mInotifyFd = -1; |
| 1181 | ALOGE("Could not add watch for %s", SYSTEM_DATA_DIR_PATH); |
| 1182 | return NO_INIT; |
| 1183 | } |
| 1184 | |
| 1185 | addTimeDirWatch(); |
| 1186 | |
| 1187 | if (mBootAnimation->updateIsTimeAccurate()) { |
| 1188 | close(mInotifyFd); |
| 1189 | mInotifyFd = -1; |
| 1190 | return ALREADY_EXISTS; |
| 1191 | } |
| 1192 | |
| 1193 | return NO_ERROR; |
| 1194 | } |
| 1195 | |
Geoffrey Pitsch | a917353 | 2016-07-19 14:56:39 -0400 | [diff] [blame] | 1196 | BootAnimation::InitAudioThread::InitAudioThread(uint8_t* exampleAudioData, int exampleAudioLength) |
| 1197 | : Thread(false), |
| 1198 | mExampleAudioData(exampleAudioData), |
| 1199 | mExampleAudioLength(exampleAudioLength) {} |
| 1200 | |
| 1201 | bool BootAnimation::InitAudioThread::threadLoop() { |
| 1202 | audioplay::create(mExampleAudioData, mExampleAudioLength); |
| 1203 | // Exit immediately |
| 1204 | return false; |
| 1205 | } |
| 1206 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1207 | // --------------------------------------------------------------------------- |
| 1208 | |
| 1209 | } |
| 1210 | ; // namespace android |