summaryrefslogtreecommitdiffstats
path: root/screen_ui.cpp
diff options
context:
space:
mode:
authorDamien Bargiacchi <drb@google.com>2016-09-08 01:40:53 +0200
committerandroid-build-merger <android-build-merger@google.com>2016-09-08 01:40:53 +0200
commit13c519396ebee8bb7fa4b3cf7b7bade816ffa385 (patch)
treea99d9330d0c862ce032ca993217d6550e842445b /screen_ui.cpp
parentMerge "Switch recovery to libbase logging" am: 61590bbf0d am: c5becf0ef8 am: ec6a47ae46 -s ours (diff)
parentRemove duplicate methods and variables from WearRecoveryUI (diff)
downloadandroid_bootable_recovery-13c519396ebee8bb7fa4b3cf7b7bade816ffa385.tar
android_bootable_recovery-13c519396ebee8bb7fa4b3cf7b7bade816ffa385.tar.gz
android_bootable_recovery-13c519396ebee8bb7fa4b3cf7b7bade816ffa385.tar.bz2
android_bootable_recovery-13c519396ebee8bb7fa4b3cf7b7bade816ffa385.tar.lz
android_bootable_recovery-13c519396ebee8bb7fa4b3cf7b7bade816ffa385.tar.xz
android_bootable_recovery-13c519396ebee8bb7fa4b3cf7b7bade816ffa385.tar.zst
android_bootable_recovery-13c519396ebee8bb7fa4b3cf7b7bade816ffa385.zip
Diffstat (limited to 'screen_ui.cpp')
-rw-r--r--screen_ui.cpp52
1 files changed, 32 insertions, 20 deletions
diff --git a/screen_ui.cpp b/screen_ui.cpp
index cfaecd922..ef32d3da7 100644
--- a/screen_ui.cpp
+++ b/screen_ui.cpp
@@ -54,8 +54,6 @@ static double now() {
ScreenRecoveryUI::ScreenRecoveryUI() :
currentIcon(NONE),
locale(nullptr),
- intro_done(false),
- current_frame(0),
progressBarType(EMPTY),
progressScopeStart(0),
progressScopeSize(0),
@@ -76,6 +74,8 @@ ScreenRecoveryUI::ScreenRecoveryUI() :
file_viewer_text_(nullptr),
intro_frames(0),
loop_frames(0),
+ current_frame(0),
+ intro_done(false),
animation_fps(30), // TODO: there's currently no way to infer this.
stage(-1),
max_stage(-1),
@@ -448,9 +448,18 @@ void ScreenRecoveryUI::SetSystemUpdateText(bool security_update) {
Redraw();
}
-void ScreenRecoveryUI::Init() {
+void ScreenRecoveryUI::InitTextParams() {
gr_init();
+ gr_font_size(gr_sys_font(), &char_width_, &char_height_);
+ text_rows_ = gr_fb_height() / char_height_;
+ text_cols_ = gr_fb_width() / char_width_;
+}
+
+void ScreenRecoveryUI::Init() {
+ RecoveryUI::Init();
+ InitTextParams();
+
density_ = static_cast<float>(property_get_int32("ro.sf.lcd_density", 160)) / 160.f;
// Are we portrait or landscape?
@@ -458,10 +467,6 @@ void ScreenRecoveryUI::Init() {
// Are we the large variant of our base layout?
if (gr_fb_height() > PixelsFromDp(800)) ++layout_;
- gr_font_size(gr_sys_font(), &char_width_, &char_height_);
- text_rows_ = gr_fb_height() / char_height_;
- text_cols_ = gr_fb_width() / char_width_;
-
text_ = Alloc2d(text_rows_, text_cols_ + 1);
file_viewer_text_ = Alloc2d(text_rows_, text_cols_ + 1);
menu_ = Alloc2d(text_rows_, text_cols_ + 1);
@@ -488,37 +493,44 @@ void ScreenRecoveryUI::Init() {
LoadAnimation();
pthread_create(&progress_thread_, nullptr, ProgressThreadStartRoutine, this);
-
- RecoveryUI::Init();
}
void ScreenRecoveryUI::LoadAnimation() {
- // How many frames of intro and loop do we have?
std::unique_ptr<DIR, decltype(&closedir)> dir(opendir("/res/images"), closedir);
dirent* de;
+ std::vector<std::string> intro_frame_names;
+ std::vector<std::string> loop_frame_names;
+
while ((de = readdir(dir.get())) != nullptr) {
- int value;
- if (sscanf(de->d_name, "intro%d", &value) == 1 && intro_frames < (value + 1)) {
- intro_frames = value + 1;
- } else if (sscanf(de->d_name, "loop%d", &value) == 1 && loop_frames < (value + 1)) {
- loop_frames = value + 1;
+ int value, num_chars;
+ if (sscanf(de->d_name, "intro%d%n.png", &value, &num_chars) == 1) {
+ intro_frame_names.emplace_back(de->d_name, num_chars);
+ } else if (sscanf(de->d_name, "loop%d%n.png", &value, &num_chars) == 1) {
+ loop_frame_names.emplace_back(de->d_name, num_chars);
}
}
+ intro_frames = intro_frame_names.size();
+ loop_frames = loop_frame_names.size();
+
+ LOGD("Recovery animation intro_frames: %d, loop_frames: %d\n", intro_frames, loop_frames);
+
// It's okay to not have an intro.
if (intro_frames == 0) intro_done = true;
// But you must have an animation.
if (loop_frames == 0) abort();
+ std::sort(intro_frame_names.begin(), intro_frame_names.end());
+ std::sort(loop_frame_names.begin(), loop_frame_names.end());
+
introFrames = new GRSurface*[intro_frames];
- for (int i = 0; i < intro_frames; ++i) {
- // TODO: remember the names above, so we don't have to hard-code the number of 0s.
- LoadBitmap(android::base::StringPrintf("intro%05d", i).c_str(), &introFrames[i]);
+ for (size_t i = 0; i < intro_frames; i++) {
+ LoadBitmap(intro_frame_names.at(i).c_str(), &introFrames[i]);
}
loopFrames = new GRSurface*[loop_frames];
- for (int i = 0; i < loop_frames; ++i) {
- LoadBitmap(android::base::StringPrintf("loop%05d", i).c_str(), &loopFrames[i]);
+ for (size_t i = 0; i < loop_frames; i++) {
+ LoadBitmap(loop_frame_names.at(i).c_str(), &loopFrames[i]);
}
}