From c049163234003ef463bca018920622bc8269c69b Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Wed, 6 May 2015 12:40:05 -0700 Subject: Add an alternate screen for viewing recovery logs. This makes it easier to go back and forth without losing current output. Also make the display more like regular more(1). Bug: http://b/20834540 Change-Id: Icc5703e9c8a378cc7072d8ebb79e34451267ee1b --- screen_ui.cpp | 110 ++++++++++++++++++++++++++++++++++------------------------ 1 file changed, 64 insertions(+), 46 deletions(-) (limited to 'screen_ui.cpp') diff --git a/screen_ui.cpp b/screen_ui.cpp index 5e73d37c4..ff9591514 100644 --- a/screen_ui.cpp +++ b/screen_ui.cpp @@ -58,18 +58,19 @@ ScreenRecoveryUI::ScreenRecoveryUI() : progressScopeSize(0), progress(0), pagesIdentical(false), - text(nullptr), - text_cols(0), - text_rows(0), - text_col(0), - text_row(0), - text_top(0), + text_cols_(0), + text_rows_(0), + text_(nullptr), + text_col_(0), + text_row_(0), + text_top_(0), show_text(false), show_text_ever(false), - menu(nullptr), + menu_(nullptr), show_menu(false), menu_items(0), menu_sel(0), + file_viewer_text_(nullptr), animation_fps(20), installing_frames(-1), stage(-1), @@ -255,7 +256,7 @@ void ScreenRecoveryUI::draw_screen_locked() { DrawTextLines(&y, HasThreeButtons() ? REGULAR_HELP : LONG_PRESS_HELP); SetColor(HEADER); - DrawTextLines(&y, menu_headers); + DrawTextLines(&y, menu_headers_); SetColor(MENU); DrawHorizontalRule(&y); @@ -267,10 +268,10 @@ void ScreenRecoveryUI::draw_screen_locked() { gr_fill(0, y - 2, gr_fb_width(), y + char_height + 2); // Bold white text for the selected item. SetColor(MENU_SEL_FG); - gr_text(4, y, menu[i], true); + gr_text(4, y, menu_[i], true); SetColor(MENU); } else { - gr_text(4, y, menu[i], false); + gr_text(4, y, menu_[i], false); } y += char_height + 4; } @@ -281,14 +282,14 @@ void ScreenRecoveryUI::draw_screen_locked() { // screen, the bottom of the menu, or we've displayed the // entire text buffer. SetColor(LOG); - int row = (text_top+text_rows-1) % text_rows; + int row = (text_top_ + text_rows_ - 1) % text_rows_; size_t count = 0; for (int ty = gr_fb_height() - char_height; - ty >= y && count < text_rows; + ty >= y && count < text_rows_; ty -= char_height, ++count) { - gr_text(0, ty, text[row], false); + gr_text(0, ty, text_[row], false); --row; - if (row < 0) row = text_rows-1; + if (row < 0) row = text_rows_ - 1; } } } @@ -391,14 +392,15 @@ void ScreenRecoveryUI::Init() { gr_init(); gr_font_size(&char_width, &char_height); - text_rows = gr_fb_height() / char_height; - text_cols = gr_fb_width() / char_width; + text_rows_ = gr_fb_height() / char_height; + text_cols_ = gr_fb_width() / char_width; - text = Alloc2d(text_rows, text_cols + 1); - menu = Alloc2d(text_rows, text_cols + 1); + text_ = Alloc2d(text_rows_, text_cols_ + 1); + file_viewer_text_ = Alloc2d(text_rows_, text_cols_ + 1); + menu_ = Alloc2d(text_rows_, text_cols_ + 1); - text_col = text_row = 0; - text_top = 1; + text_col_ = text_row_ = 0; + text_top_ = 1; backgroundIcon[NONE] = nullptr; LoadBitmapArray("icon_installing", &installing_frames, &installation); @@ -514,17 +516,17 @@ void ScreenRecoveryUI::Print(const char *fmt, ...) { fputs(buf, stdout); pthread_mutex_lock(&updateMutex); - if (text_rows > 0 && text_cols > 0) { + if (text_rows_ > 0 && text_cols_ > 0) { for (const char* ptr = buf; *ptr != '\0'; ++ptr) { - if (*ptr == '\n' || text_col >= text_cols) { - text[text_row][text_col] = '\0'; - text_col = 0; - text_row = (text_row + 1) % text_rows; - if (text_row == text_top) text_top = (text_top + 1) % text_rows; + if (*ptr == '\n' || text_col_ >= text_cols_) { + text_[text_row_][text_col_] = '\0'; + text_col_ = 0; + text_row_ = (text_row_ + 1) % text_rows_; + if (text_row_ == text_top_) text_top_ = (text_top_ + 1) % text_rows_; } - if (*ptr != '\n') text[text_row][text_col++] = *ptr; + if (*ptr != '\n') text_[text_row_][text_col_++] = *ptr; } - text[text_row][text_col] = '\0'; + text_[text_row_][text_col_] = '\0'; update_screen_locked(); } pthread_mutex_unlock(&updateMutex); @@ -532,21 +534,23 @@ void ScreenRecoveryUI::Print(const char *fmt, ...) { void ScreenRecoveryUI::PutChar(char ch) { pthread_mutex_lock(&updateMutex); - if (ch != '\n') text[text_row][text_col++] = ch; - if (ch == '\n' || text_col >= text_cols) { - text_col = 0; - ++text_row; + if (ch != '\n') text_[text_row_][text_col_++] = ch; + if (ch == '\n' || text_col_ >= text_cols_) { + text_col_ = 0; + ++text_row_; + + if (text_row_ == text_top_) text_top_ = (text_top_ + 1) % text_rows_; } pthread_mutex_unlock(&updateMutex); } void ScreenRecoveryUI::ClearText() { pthread_mutex_lock(&updateMutex); - text_col = 0; - text_row = 0; - text_top = 1; - for (size_t i = 0; i < text_rows; ++i) { - memset(text[i], 0, text_cols + 1); + text_col_ = 0; + text_row_ = 0; + text_top_ = 1; + for (size_t i = 0; i < text_rows_; ++i) { + memset(text_[i], 0, text_cols_ + 1); } pthread_mutex_unlock(&updateMutex); } @@ -590,12 +594,11 @@ void ScreenRecoveryUI::ShowFile(FILE* fp) { int ch = getc(fp); if (ch == EOF) { - text_row = text_top = text_rows - 2; + while (text_row_ < text_rows_ - 1) PutChar('\n'); show_prompt = true; } else { PutChar(ch); - if (text_col == 0 && text_row >= text_rows - 2) { - text_top = text_row; + if (text_col_ == 0 && text_row_ >= text_rows_ - 1) { show_prompt = true; } } @@ -608,19 +611,34 @@ void ScreenRecoveryUI::ShowFile(const char* filename) { Print(" Unable to open %s: %s\n", filename, strerror(errno)); return; } + + char** old_text = text_; + size_t old_text_col = text_col_; + size_t old_text_row = text_row_; + size_t old_text_top = text_top_; + + // Swap in the alternate screen and clear it. + text_ = file_viewer_text_; + ClearText(); + ShowFile(fp); fclose(fp); + + text_ = old_text; + text_col_ = old_text_col; + text_row_ = old_text_row; + text_top_ = old_text_top; } void ScreenRecoveryUI::StartMenu(const char* const * headers, const char* const * items, int initial_selection) { pthread_mutex_lock(&updateMutex); - if (text_rows > 0 && text_cols > 0) { - menu_headers = headers; + if (text_rows_ > 0 && text_cols_ > 0) { + menu_headers_ = headers; size_t i = 0; - for (; i < text_rows && items[i] != nullptr; ++i) { - strncpy(menu[i], items[i], text_cols-1); - menu[i][text_cols-1] = '\0'; + for (; i < text_rows_ && items[i] != nullptr; ++i) { + strncpy(menu_[i], items[i], text_cols_ - 1); + menu_[i][text_cols_ - 1] = '\0'; } menu_items = i; show_menu = true; @@ -649,7 +667,7 @@ int ScreenRecoveryUI::SelectMenu(int sel) { void ScreenRecoveryUI::EndMenu() { pthread_mutex_lock(&updateMutex); - if (show_menu && text_rows > 0 && text_cols > 0) { + if (show_menu && text_rows_ > 0 && text_cols_ > 0) { show_menu = false; update_screen_locked(); } -- cgit v1.2.3 From b6918c7c433054ac4352d5f7746f7c2bf2971083 Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Tue, 19 May 2015 17:02:16 -0700 Subject: Log update outputs in order Although stdout and stderr are both redirected to log file with no buffering, we are seeing some outputs are mixed in random order. This is because ui_print commands from the updater are passed to the recovery binary via a pipe, which may interleave with other outputs that go to stderr directly. In recovery, adding ui::PrintOnScreenOnly() function to handle ui_print command, which skips printing to stdout. Meanwhile, updater prints the contents to stderr in addition to piping them to recovery. Change-Id: Idda93ea940d2e23a0276bb8ead4aa70a3cb97700 --- screen_ui.cpp | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) (limited to 'screen_ui.cpp') diff --git a/screen_ui.cpp b/screen_ui.cpp index ff9591514..ddf85c19e 100644 --- a/screen_ui.cpp +++ b/screen_ui.cpp @@ -30,8 +30,10 @@ #include -#include "base/strings.h" -#include "cutils/properties.h" +#include +#include +#include + #include "common.h" #include "device.h" #include "minui/minui.h" @@ -506,18 +508,17 @@ void ScreenRecoveryUI::SetStage(int current, int max) { pthread_mutex_unlock(&updateMutex); } -void ScreenRecoveryUI::Print(const char *fmt, ...) { - char buf[256]; - va_list ap; - va_start(ap, fmt); - vsnprintf(buf, 256, fmt, ap); - va_end(ap); +void ScreenRecoveryUI::PrintV(const char* fmt, bool copy_to_stdout, va_list ap) { + std::string str; + android::base::StringAppendV(&str, fmt, ap); - fputs(buf, stdout); + if (copy_to_stdout) { + fputs(str.c_str(), stdout); + } pthread_mutex_lock(&updateMutex); if (text_rows_ > 0 && text_cols_ > 0) { - for (const char* ptr = buf; *ptr != '\0'; ++ptr) { + for (const char* ptr = str.c_str(); *ptr != '\0'; ++ptr) { if (*ptr == '\n' || text_col_ >= text_cols_) { text_[text_row_][text_col_] = '\0'; text_col_ = 0; @@ -532,6 +533,20 @@ void ScreenRecoveryUI::Print(const char *fmt, ...) { pthread_mutex_unlock(&updateMutex); } +void ScreenRecoveryUI::Print(const char* fmt, ...) { + va_list ap; + va_start(ap, fmt); + PrintV(fmt, true, ap); + va_end(ap); +} + +void ScreenRecoveryUI::PrintOnScreenOnly(const char *fmt, ...) { + va_list ap; + va_start(ap, fmt); + PrintV(fmt, false, ap); + va_end(ap); +} + void ScreenRecoveryUI::PutChar(char ch) { pthread_mutex_lock(&updateMutex); if (ch != '\n') text_[text_row_][text_col_++] = ch; -- cgit v1.2.3 From 9a7fd80d2dd706343f24c91b0756771aca8504a5 Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Thu, 10 Sep 2015 13:33:58 -0700 Subject: recovery: Remove redirect_stdio() when calling ShowFile(). When calling ScreenRecoveryUI::ShowFile(), the only thing that gets inadequately logged is the progress bar. Replace the call to ScreenRecoveryUI::Print() with ScreenRecoveryUI::PrintOnScreenOnly() for the progress bar, so we can avoid calling redirect_stdio(). Change-Id: I4d7c5d5b39bebe0d5880a99d7a72cee4f0b8f325 --- screen_ui.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'screen_ui.cpp') diff --git a/screen_ui.cpp b/screen_ui.cpp index ddf85c19e..f2fda2fb5 100644 --- a/screen_ui.cpp +++ b/screen_ui.cpp @@ -581,7 +581,7 @@ void ScreenRecoveryUI::ShowFile(FILE* fp) { bool show_prompt = false; while (true) { if (show_prompt) { - Print("--(%d%% of %d bytes)--", + PrintOnScreenOnly("--(%d%% of %d bytes)--", static_cast(100 * (double(ftell(fp)) / double(sb.st_size))), static_cast(sb.st_size)); Redraw(); -- cgit v1.2.3 From 4b166f0e69d46858ff998414da2a01e0266fa339 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Fri, 4 Dec 2015 15:30:20 -0800 Subject: Track rename from base/ to android-base/. Change-Id: I354a8c424d340a9abe21fd716a4ee0d3b177d86f --- screen_ui.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'screen_ui.cpp') diff --git a/screen_ui.cpp b/screen_ui.cpp index f2fda2fb5..23fc90154 100644 --- a/screen_ui.cpp +++ b/screen_ui.cpp @@ -30,8 +30,8 @@ #include -#include -#include +#include +#include #include #include "common.h" -- cgit v1.2.3 From b723f4f38f53a38502abb1a63165ac0749bc9cd9 Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Fri, 11 Dec 2015 15:18:51 -0800 Subject: res: Embed FPS into icon_installing.png. We allow vendor-specific icon installing image but have defined private animation_fps that can't be overridden. This CL changes the image generator to optionally embed FPS (otherwise use the default value of 20) into the generated image. For wear devices, they are using individual images instead of the interlaced one. Change the animation_fps from private to protected so that it can be customized. Bug: 26009230 Change-Id: I9fbf64ec717029d4c54f72316f6cb079e8dbfb5e --- screen_ui.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'screen_ui.cpp') diff --git a/screen_ui.cpp b/screen_ui.cpp index 23fc90154..522aa6b23 100644 --- a/screen_ui.cpp +++ b/screen_ui.cpp @@ -73,7 +73,7 @@ ScreenRecoveryUI::ScreenRecoveryUI() : menu_items(0), menu_sel(0), file_viewer_text_(nullptr), - animation_fps(20), + animation_fps(-1), installing_frames(-1), stage(-1), max_stage(-1) { @@ -367,8 +367,9 @@ void ScreenRecoveryUI::LoadBitmap(const char* filename, GRSurface** surface) { } } -void ScreenRecoveryUI::LoadBitmapArray(const char* filename, int* frames, GRSurface*** surface) { - int result = res_create_multi_display_surface(filename, frames, surface); +void ScreenRecoveryUI::LoadBitmapArray(const char* filename, int* frames, int* fps, + GRSurface*** surface) { + int result = res_create_multi_display_surface(filename, frames, fps, surface); if (result < 0) { LOGE("missing bitmap %s\n(Code %d)\n", filename, result); } @@ -405,7 +406,7 @@ void ScreenRecoveryUI::Init() { text_top_ = 1; backgroundIcon[NONE] = nullptr; - LoadBitmapArray("icon_installing", &installing_frames, &installation); + LoadBitmapArray("icon_installing", &installing_frames, &animation_fps, &installation); backgroundIcon[INSTALLING_UPDATE] = installing_frames ? installation[0] : nullptr; backgroundIcon[ERASING] = backgroundIcon[INSTALLING_UPDATE]; LoadBitmap("icon_error", &backgroundIcon[ERROR]); -- cgit v1.2.3 From 1c7b2230d8aac9f064f68c48b6aa26aca000cc9d Mon Sep 17 00:00:00 2001 From: Prashant Malani Date: Tue, 8 Mar 2016 15:23:51 -0800 Subject: recovery: More refactoring of WearUI This patch performs the following modifications: - Remove setBackground function, and currentIcon member variable. - Remove common Progress*, Redraw and EndMenu functions. Bug: 27407422 Change-Id: Ic3c0e16b67941484c3bc1d04c9b61288e8896808 Signed-off-by: Prashant Malani --- screen_ui.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'screen_ui.cpp') diff --git a/screen_ui.cpp b/screen_ui.cpp index 522aa6b23..dc596314c 100644 --- a/screen_ui.cpp +++ b/screen_ui.cpp @@ -51,7 +51,6 @@ static double now() { } ScreenRecoveryUI::ScreenRecoveryUI() : - currentIcon(NONE), installingFrame(0), locale(nullptr), rtl_locale(false), @@ -76,7 +75,8 @@ ScreenRecoveryUI::ScreenRecoveryUI() : animation_fps(-1), installing_frames(-1), stage(-1), - max_stage(-1) { + max_stage(-1), + currentIcon(NONE) { for (int i = 0; i < 5; i++) { backgroundIcon[i] = nullptr; -- cgit v1.2.3 From f7f9e50528761022989c4f0cac6a92716b54674f Mon Sep 17 00:00:00 2001 From: Prashant Malani Date: Thu, 10 Mar 2016 03:40:20 +0000 Subject: Revert "recovery: More refactoring of WearUI" This reverts commit 1c7b2230d8aac9f064f68c48b6aa26aca000cc9d. This change can lead to the derived class indirectly (and incorrectly) calling some functions from the base class, which can lead to unpredictable behavior. Bug: 27407422 Change-Id: I126a7489b0787dc195e942e2ceea6769de20d70c --- screen_ui.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'screen_ui.cpp') diff --git a/screen_ui.cpp b/screen_ui.cpp index dc596314c..522aa6b23 100644 --- a/screen_ui.cpp +++ b/screen_ui.cpp @@ -51,6 +51,7 @@ static double now() { } ScreenRecoveryUI::ScreenRecoveryUI() : + currentIcon(NONE), installingFrame(0), locale(nullptr), rtl_locale(false), @@ -75,8 +76,7 @@ ScreenRecoveryUI::ScreenRecoveryUI() : animation_fps(-1), installing_frames(-1), stage(-1), - max_stage(-1), - currentIcon(NONE) { + max_stage(-1) { for (int i = 0; i < 5; i++) { backgroundIcon[i] = nullptr; -- cgit v1.2.3 From 0ba21cff07ceafeaa43e17aa26e341d961f6f29f Mon Sep 17 00:00:00 2001 From: Prashant Malani Date: Thu, 10 Mar 2016 14:51:25 -0800 Subject: recovery: Remove duplicate variables and functions The function that modifies rtl_locale exists only in the base class, and so the variable should not have a duplicate in the derived class, otherwise there may be incosistent values when it is read by the derived class (the thinking being that invoking the function will modify the base class version of the variable, and not the derived class version). Remove the updateMutex variable, and instead re-use the one in the base class. Also remove LoadBitmap from WearUI since it is identical to the one in ScreenRecoveryUI. Bug: 27407422 Change-Id: Idd823fa93dfa16d7b2c9c7160f8d0c2559d28731 --- screen_ui.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'screen_ui.cpp') diff --git a/screen_ui.cpp b/screen_ui.cpp index 522aa6b23..9f72de4b8 100644 --- a/screen_ui.cpp +++ b/screen_ui.cpp @@ -54,7 +54,6 @@ ScreenRecoveryUI::ScreenRecoveryUI() : currentIcon(NONE), installingFrame(0), locale(nullptr), - rtl_locale(false), progressBarType(EMPTY), progressScopeStart(0), progressScopeSize(0), @@ -76,7 +75,8 @@ ScreenRecoveryUI::ScreenRecoveryUI() : animation_fps(-1), installing_frames(-1), stage(-1), - max_stage(-1) { + max_stage(-1), + rtl_locale(false) { for (int i = 0; i < 5; i++) { backgroundIcon[i] = nullptr; -- cgit v1.2.3 From 7a491225bbbb24593a4eda5dabe2fc1850d60dd1 Mon Sep 17 00:00:00 2001 From: Prashant Malani Date: Fri, 11 Mar 2016 10:00:55 -0800 Subject: recovery: Remove SetColor, and other refactoring for WearUI The only difference from SetColor in ScreenRecoveryUI is the that the LOG messages have slightly different colors. That's not enough to warrant a duplicate function. So this patch removes SetColor and uses the parent class version. This patch also moves the DrawTextLine* functions into ScreenRecoveryUI since they're mostly the same. It also moves char_width and char_height into the class instead of keeping them as static variables. Bug: 27407422 Change-Id: I30428c9433baab8410cf710a01c9b1c44c217bf1 --- screen_ui.cpp | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'screen_ui.cpp') diff --git a/screen_ui.cpp b/screen_ui.cpp index 9f72de4b8..3614e7a83 100644 --- a/screen_ui.cpp +++ b/screen_ui.cpp @@ -40,8 +40,7 @@ #include "screen_ui.h" #include "ui.h" -static int char_width; -static int char_height; +#define TEXT_INDENT 4 // Return the current time as a double (including fractions of a second). static double now() { @@ -213,14 +212,14 @@ void ScreenRecoveryUI::DrawHorizontalRule(int* y) { *y += 4; } -void ScreenRecoveryUI::DrawTextLine(int* y, const char* line, bool bold) { - gr_text(4, *y, line, bold); - *y += char_height + 4; +void ScreenRecoveryUI::DrawTextLine(int x, int* y, const char* line, bool bold) { + gr_text(x, *y, line, bold); + *y += char_height_ + 4; } -void ScreenRecoveryUI::DrawTextLines(int* y, const char* const* lines) { +void ScreenRecoveryUI::DrawTextLines(int x, int* y, const char* const* lines) { for (size_t i = 0; lines != nullptr && lines[i] != nullptr; ++i) { - DrawTextLine(y, lines[i], false); + DrawTextLine(x, y, lines[i], false); } } @@ -251,14 +250,15 @@ void ScreenRecoveryUI::draw_screen_locked() { property_get("ro.bootimage.build.fingerprint", recovery_fingerprint, ""); SetColor(INFO); - DrawTextLine(&y, "Android Recovery", true); + DrawTextLine(TEXT_INDENT, &y, "Android Recovery", true); for (auto& chunk : android::base::Split(recovery_fingerprint, ":")) { - DrawTextLine(&y, chunk.c_str(), false); + DrawTextLine(TEXT_INDENT, &y, chunk.c_str(), false); } - DrawTextLines(&y, HasThreeButtons() ? REGULAR_HELP : LONG_PRESS_HELP); + DrawTextLines(TEXT_INDENT, &y, + HasThreeButtons() ? REGULAR_HELP : LONG_PRESS_HELP); SetColor(HEADER); - DrawTextLines(&y, menu_headers_); + DrawTextLines(TEXT_INDENT, &y, menu_headers_); SetColor(MENU); DrawHorizontalRule(&y); @@ -267,7 +267,7 @@ void ScreenRecoveryUI::draw_screen_locked() { if (i == menu_sel) { // Draw the highlight bar. SetColor(IsLongPress() ? MENU_SEL_BG_ACTIVE : MENU_SEL_BG); - gr_fill(0, y - 2, gr_fb_width(), y + char_height + 2); + gr_fill(0, y - 2, gr_fb_width(), y + char_height_ + 2); // Bold white text for the selected item. SetColor(MENU_SEL_FG); gr_text(4, y, menu_[i], true); @@ -275,7 +275,7 @@ void ScreenRecoveryUI::draw_screen_locked() { } else { gr_text(4, y, menu_[i], false); } - y += char_height + 4; + y += char_height_ + 4; } DrawHorizontalRule(&y); } @@ -286,9 +286,9 @@ void ScreenRecoveryUI::draw_screen_locked() { SetColor(LOG); int row = (text_top_ + text_rows_ - 1) % text_rows_; size_t count = 0; - for (int ty = gr_fb_height() - char_height; + for (int ty = gr_fb_height() - char_height_; ty >= y && count < text_rows_; - ty -= char_height, ++count) { + ty -= char_height_, ++count) { gr_text(0, ty, text_[row], false); --row; if (row < 0) row = text_rows_ - 1; @@ -394,9 +394,9 @@ static char** Alloc2d(size_t rows, size_t cols) { void ScreenRecoveryUI::Init() { gr_init(); - gr_font_size(&char_width, &char_height); - text_rows_ = gr_fb_height() / char_height; - text_cols_ = gr_fb_width() / char_width; + gr_font_size(&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); -- cgit v1.2.3 From 498cda6ef6c610efb055221d6c689185d49447bb Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Thu, 14 Apr 2016 16:49:04 -0700 Subject: Update the system update animation. Switch to a Wear-like intro/loop system. We don't have an intro yet, but hopefully this will let Wear delete more code when they move to N. Unlike them, we don't hard-code the number of frames: we just look to see what we have available. We do hard-code the fps though. Also add a graphics test mode so you can see a demo of the UI components without having to actually apply an OTA. Also fix a bug where default locale is null rather than en-US: it's more useful to show _some_ text if we don't have a locale (which should only be during development anyway). Bug: http://b/26548285 Change-Id: I63422e3fef3c41109f924d96fb5ded0b3ae7815d --- screen_ui.cpp | 143 +++++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 92 insertions(+), 51 deletions(-) (limited to 'screen_ui.cpp') diff --git a/screen_ui.cpp b/screen_ui.cpp index 3614e7a83..b32df3649 100644 --- a/screen_ui.cpp +++ b/screen_ui.cpp @@ -14,6 +14,7 @@ * limitations under the License. */ +#include #include #include #include @@ -51,8 +52,9 @@ static double now() { ScreenRecoveryUI::ScreenRecoveryUI() : currentIcon(NONE), - installingFrame(0), locale(nullptr), + intro_done(false), + current_frame(0), progressBarType(EMPTY), progressScopeStart(0), progressScopeSize(0), @@ -71,31 +73,43 @@ ScreenRecoveryUI::ScreenRecoveryUI() : menu_items(0), menu_sel(0), file_viewer_text_(nullptr), - animation_fps(-1), - installing_frames(-1), + intro_frames(0), + loop_frames(0), + animation_fps(30), // TODO: there's currently no way to infer this. stage(-1), max_stage(-1), rtl_locale(false) { - for (int i = 0; i < 5; i++) { - backgroundIcon[i] = nullptr; - } pthread_mutex_init(&updateMutex, nullptr); } +GRSurface* ScreenRecoveryUI::GetCurrentFrame() { + if (currentIcon == INSTALLING_UPDATE || currentIcon == ERASING) { + return intro_done ? loopFrames[current_frame] : introFrames[current_frame]; + } + return error_icon; +} + +GRSurface* ScreenRecoveryUI::GetCurrentText() { + switch (currentIcon) { + case ERASING: return erasing_text; + case ERROR: return error_text; + case INSTALLING_UPDATE: return installing_text; + case NO_COMMAND: return no_command_text; + case NONE: abort(); + } +} + // Clear the screen and draw the currently selected background icon (if any). // Should only be called with updateMutex locked. -void ScreenRecoveryUI::draw_background_locked(Icon icon) { +void ScreenRecoveryUI::draw_background_locked() { pagesIdentical = false; gr_color(0, 0, 0, 255); gr_clear(); - if (icon) { - GRSurface* surface = backgroundIcon[icon]; - if (icon == INSTALLING_UPDATE || icon == ERASING) { - surface = installation[installingFrame]; - } - GRSurface* text_surface = backgroundText[icon]; + if (currentIcon != NONE) { + GRSurface* surface = GetCurrentFrame(); + GRSurface* text_surface = GetCurrentText(); int iconWidth = gr_get_width(surface); int iconHeight = gr_get_height(surface); @@ -132,14 +146,15 @@ void ScreenRecoveryUI::draw_background_locked(Icon icon) { // Should only be called with updateMutex locked. void ScreenRecoveryUI::draw_progress_locked() { if (currentIcon == ERROR) return; + if (progressBarType != DETERMINATE) return; if (currentIcon == INSTALLING_UPDATE || currentIcon == ERASING) { - GRSurface* icon = installation[installingFrame]; - gr_blit(icon, 0, 0, gr_get_width(icon), gr_get_height(icon), iconX, iconY); + GRSurface* frame = GetCurrentFrame(); + gr_blit(frame, 0, 0, gr_get_width(frame), gr_get_height(frame), iconX, iconY); } if (progressBarType != EMPTY) { - int iconHeight = gr_get_height(backgroundIcon[INSTALLING_UPDATE]); + int iconHeight = gr_get_height(loopFrames[0]); int width = gr_get_width(progressBarEmpty); int height = gr_get_height(progressBarEmpty); @@ -238,7 +253,7 @@ static const char* LONG_PRESS_HELP[] = { // Should only be called with updateMutex locked. void ScreenRecoveryUI::draw_screen_locked() { if (!show_text) { - draw_background_locked(currentIcon); + draw_background_locked(); draw_progress_locked(); } else { gr_color(0, 0, 0, 255); @@ -254,8 +269,7 @@ void ScreenRecoveryUI::draw_screen_locked() { for (auto& chunk : android::base::Split(recovery_fingerprint, ":")) { DrawTextLine(TEXT_INDENT, &y, chunk.c_str(), false); } - DrawTextLines(TEXT_INDENT, &y, - HasThreeButtons() ? REGULAR_HELP : LONG_PRESS_HELP); + DrawTextLines(TEXT_INDENT, &y, HasThreeButtons() ? REGULAR_HELP : LONG_PRESS_HELP); SetColor(HEADER); DrawTextLines(TEXT_INDENT, &y, menu_headers_); @@ -327,14 +341,23 @@ void ScreenRecoveryUI::ProgressThreadLoop() { double start = now(); pthread_mutex_lock(&updateMutex); - int redraw = 0; + bool redraw = false; // update the installation animation, if active // skip this if we have a text overlay (too expensive to update) - if ((currentIcon == INSTALLING_UPDATE || currentIcon == ERASING) && - installing_frames > 0 && !show_text) { - installingFrame = (installingFrame + 1) % installing_frames; - redraw = 1; + if ((currentIcon == INSTALLING_UPDATE || currentIcon == ERASING) && !show_text) { + if (!intro_done) { + if (current_frame == intro_frames - 1) { + intro_done = true; + current_frame = 0; + } else { + ++current_frame; + } + } else { + current_frame = (current_frame + 1) % loop_frames; + } + + redraw = true; } // move the progress bar forward on timed intervals, if configured @@ -345,7 +368,7 @@ void ScreenRecoveryUI::ProgressThreadLoop() { if (p > 1.0) p = 1.0; if (p > progress) { progress = p; - redraw = 1; + redraw = true; } } @@ -363,22 +386,14 @@ void ScreenRecoveryUI::ProgressThreadLoop() { void ScreenRecoveryUI::LoadBitmap(const char* filename, GRSurface** surface) { int result = res_create_display_surface(filename, surface); if (result < 0) { - LOGE("missing bitmap %s\n(Code %d)\n", filename, result); - } -} - -void ScreenRecoveryUI::LoadBitmapArray(const char* filename, int* frames, int* fps, - GRSurface*** surface) { - int result = res_create_multi_display_surface(filename, frames, fps, surface); - if (result < 0) { - LOGE("missing bitmap %s\n(Code %d)\n", filename, result); + LOGE("missing bitmap %s (error %d)\n", filename, result); } } void ScreenRecoveryUI::LoadLocalizedBitmap(const char* filename, GRSurface** surface) { int result = res_create_localized_alpha_surface(filename, locale, surface); if (result < 0) { - LOGE("missing bitmap %s\n(Code %d)\n", filename, result); + LOGE("missing bitmap %s (error %d)\n", filename, result); } } @@ -405,31 +420,60 @@ void ScreenRecoveryUI::Init() { text_col_ = text_row_ = 0; text_top_ = 1; - backgroundIcon[NONE] = nullptr; - LoadBitmapArray("icon_installing", &installing_frames, &animation_fps, &installation); - backgroundIcon[INSTALLING_UPDATE] = installing_frames ? installation[0] : nullptr; - backgroundIcon[ERASING] = backgroundIcon[INSTALLING_UPDATE]; - LoadBitmap("icon_error", &backgroundIcon[ERROR]); - backgroundIcon[NO_COMMAND] = backgroundIcon[ERROR]; + LoadBitmap("icon_error", &error_icon); LoadBitmap("progress_empty", &progressBarEmpty); LoadBitmap("progress_fill", &progressBarFill); + LoadBitmap("stage_empty", &stageMarkerEmpty); LoadBitmap("stage_fill", &stageMarkerFill); - LoadLocalizedBitmap("installing_text", &backgroundText[INSTALLING_UPDATE]); - LoadLocalizedBitmap("erasing_text", &backgroundText[ERASING]); - LoadLocalizedBitmap("no_command_text", &backgroundText[NO_COMMAND]); - LoadLocalizedBitmap("error_text", &backgroundText[ERROR]); + LoadLocalizedBitmap("installing_text", &installing_text); + LoadLocalizedBitmap("erasing_text", &erasing_text); + LoadLocalizedBitmap("no_command_text", &no_command_text); + LoadLocalizedBitmap("error_text", &error_text); + + 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(opendir("/res/images"), closedir); + dirent* de; + 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; + } + } + + // 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(); + + introFrames = new GRSurface*[intro_frames]; + for (int i = 0; i < intro_frames; ++i) { + LoadBitmap(android::base::StringPrintf("intro%02d", i).c_str(), &introFrames[i]); + } + + loopFrames = new GRSurface*[loop_frames]; + for (int i = 0; i < loop_frames; ++i) { + LoadBitmap(android::base::StringPrintf("loop%02d", i).c_str(), &loopFrames[i]); + } +} + void ScreenRecoveryUI::SetLocale(const char* new_locale) { - if (new_locale) { - this->locale = new_locale; + this->locale = new_locale; + this->rtl_locale = false; + + if (locale) { char* lang = strdup(locale); for (char* p = lang; *p; ++p) { if (*p == '_') { @@ -438,8 +482,7 @@ void ScreenRecoveryUI::SetLocale(const char* new_locale) { } } - // A bit cheesy: keep an explicit list of supported languages - // that are RTL. + // A bit cheesy: keep an explicit list of supported RTL languages. if (strcmp(lang, "ar") == 0 || // Arabic strcmp(lang, "fa") == 0 || // Persian (Farsi) strcmp(lang, "he") == 0 || // Hebrew (new language code) @@ -448,8 +491,6 @@ void ScreenRecoveryUI::SetLocale(const char* new_locale) { rtl_locale = true; } free(lang); - } else { - new_locale = nullptr; } } -- cgit v1.2.3 From 692941be79fd765f8873d810ae627a917dfd791b Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Thu, 21 Apr 2016 14:26:14 -0700 Subject: Go back to the old ear-wiggling Android animation. But keep the new code so we can easily test new animations when we have them. This change includes tbao's de-interlace script, plus a one-liner that's necessary to play the animation at the correct speed when there's no progress bar showing. (This was always a bug, it's just way more noticeable when your animation only has 7 frames.) Bug: http://b/28316654 Bug: http://b/26548285 Change-Id: I32c601c352d6be235d1b44f14fca7e125defd77d --- screen_ui.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'screen_ui.cpp') diff --git a/screen_ui.cpp b/screen_ui.cpp index b32df3649..55cb74120 100644 --- a/screen_ui.cpp +++ b/screen_ui.cpp @@ -146,7 +146,6 @@ void ScreenRecoveryUI::draw_background_locked() { // Should only be called with updateMutex locked. void ScreenRecoveryUI::draw_progress_locked() { if (currentIcon == ERROR) return; - if (progressBarType != DETERMINATE) return; if (currentIcon == INSTALLING_UPDATE || currentIcon == ERASING) { GRSurface* frame = GetCurrentFrame(); -- cgit v1.2.3 From faf36e04ed6f7e7b92a90ce7fc4ecc113eee4993 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Wed, 20 Apr 2016 17:22:16 -0700 Subject: Update recovery UI. * Use new animation. * Use new non-holo progress bars. * Use recommended spacing for recovery UI. Bug: http://b/26548285 Change-Id: I8411e89d6a6a9ce638b8645e19e5082d0d968cee --- screen_ui.cpp | 116 ++++++++++++++++++++++++++++++++++------------------------ 1 file changed, 69 insertions(+), 47 deletions(-) (limited to 'screen_ui.cpp') diff --git a/screen_ui.cpp b/screen_ui.cpp index 55cb74120..465be23fa 100644 --- a/screen_ui.cpp +++ b/screen_ui.cpp @@ -78,9 +78,8 @@ ScreenRecoveryUI::ScreenRecoveryUI() : animation_fps(30), // TODO: there's currently no way to infer this. stage(-1), max_stage(-1), + updateMutex(PTHREAD_MUTEX_INITIALIZER), rtl_locale(false) { - - pthread_mutex_init(&updateMutex, nullptr); } GRSurface* ScreenRecoveryUI::GetCurrentFrame() { @@ -100,6 +99,35 @@ GRSurface* ScreenRecoveryUI::GetCurrentText() { } } +int ScreenRecoveryUI::PixelsFromDp(int dp) { + return dp * density_; +} + +// Here's the intended layout: + +// 162dp +// icon (200dp) +// 62dp +// text (14sp) +// 24dp +// progress (2dp) +// 172dp + +// Note that "baseline" is actually the *top* of each icon (because that's how our drawing +// routines work), so that's the more useful measurement. + +int ScreenRecoveryUI::GetAnimationBaseline() { + return GetTextBaseline() - PixelsFromDp(68) - gr_get_height(loopFrames[0]); +} + +int ScreenRecoveryUI::GetTextBaseline() { + return GetProgressBaseline() - PixelsFromDp(32) - gr_get_height(installing_text); +} + +int ScreenRecoveryUI::GetProgressBaseline() { + return gr_fb_height() - PixelsFromDp(is_large_ ? 340 : 194) - gr_get_height(progressBarFill); +} + // Clear the screen and draw the currently selected background icon (if any). // Should only be called with updateMutex locked. void ScreenRecoveryUI::draw_background_locked() { @@ -108,61 +136,49 @@ void ScreenRecoveryUI::draw_background_locked() { gr_clear(); if (currentIcon != NONE) { - GRSurface* surface = GetCurrentFrame(); - GRSurface* text_surface = GetCurrentText(); - - int iconWidth = gr_get_width(surface); - int iconHeight = gr_get_height(surface); - int textWidth = gr_get_width(text_surface); - int textHeight = gr_get_height(text_surface); - int stageHeight = gr_get_height(stageMarkerEmpty); - - int sh = (max_stage >= 0) ? stageHeight : 0; - - iconX = (gr_fb_width() - iconWidth) / 2; - iconY = (gr_fb_height() - (iconHeight+textHeight+40+sh)) / 2; - - int textX = (gr_fb_width() - textWidth) / 2; - int textY = ((gr_fb_height() - (iconHeight+textHeight+40+sh)) / 2) + iconHeight + 40; - - gr_blit(surface, 0, 0, iconWidth, iconHeight, iconX, iconY); - if (stageHeight > 0) { - int sw = gr_get_width(stageMarkerEmpty); + if (max_stage != -1) { + int stage_height = gr_get_height(stageMarkerEmpty); + int stage_width = gr_get_width(stageMarkerEmpty); int x = (gr_fb_width() - max_stage * gr_get_width(stageMarkerEmpty)) / 2; - int y = iconY + iconHeight + 20; + int y = gr_fb_height() - stage_height; for (int i = 0; i < max_stage; ++i) { - gr_blit((i < stage) ? stageMarkerFill : stageMarkerEmpty, - 0, 0, sw, stageHeight, x, y); - x += sw; + GRSurface* stage_surface = (i < stage) ? stageMarkerFill : stageMarkerEmpty; + gr_blit(stage_surface, 0, 0, stage_width, stage_height, x, y); + x += stage_width; } } + GRSurface* text_surface = GetCurrentText(); + int text_x = (gr_fb_width() - gr_get_width(text_surface)) / 2; + int text_y = GetTextBaseline(); gr_color(255, 255, 255, 255); - gr_texticon(textX, textY, text_surface); + gr_texticon(text_x, text_y, text_surface); } } -// Draw the progress bar (if any) on the screen. Does not flip pages. +// Draws the animation and progress bar (if any) on the screen. +// Does not flip pages. // Should only be called with updateMutex locked. -void ScreenRecoveryUI::draw_progress_locked() { - if (currentIcon == ERROR) return; - - if (currentIcon == INSTALLING_UPDATE || currentIcon == ERASING) { +void ScreenRecoveryUI::draw_foreground_locked() { + if (currentIcon != NONE) { GRSurface* frame = GetCurrentFrame(); - gr_blit(frame, 0, 0, gr_get_width(frame), gr_get_height(frame), iconX, iconY); + int frame_width = gr_get_width(frame); + int frame_height = gr_get_height(frame); + int frame_x = (gr_fb_width() - frame_width) / 2; + int frame_y = GetAnimationBaseline(); + gr_blit(frame, 0, 0, frame_width, frame_height, frame_x, frame_y); } if (progressBarType != EMPTY) { - int iconHeight = gr_get_height(loopFrames[0]); int width = gr_get_width(progressBarEmpty); int height = gr_get_height(progressBarEmpty); - int dx = (gr_fb_width() - width)/2; - int dy = (3*gr_fb_height() + iconHeight - 2*height)/4; + int progress_x = (gr_fb_width() - width)/2; + int progress_y = GetProgressBaseline(); // Erase behind the progress bar (in case this was a progress-only update) gr_color(0, 0, 0, 255); - gr_fill(dx, dy, width, height); + gr_fill(progress_x, progress_y, width, height); if (progressBarType == DETERMINATE) { float p = progressScopeStart + progress * progressScopeSize; @@ -171,18 +187,20 @@ void ScreenRecoveryUI::draw_progress_locked() { if (rtl_locale) { // Fill the progress bar from right to left. if (pos > 0) { - gr_blit(progressBarFill, width-pos, 0, pos, height, dx+width-pos, dy); + gr_blit(progressBarFill, width-pos, 0, pos, height, + progress_x+width-pos, progress_y); } if (pos < width-1) { - gr_blit(progressBarEmpty, 0, 0, width-pos, height, dx, dy); + gr_blit(progressBarEmpty, 0, 0, width-pos, height, progress_x, progress_y); } } else { // Fill the progress bar from left to right. if (pos > 0) { - gr_blit(progressBarFill, 0, 0, pos, height, dx, dy); + gr_blit(progressBarFill, 0, 0, pos, height, progress_x, progress_y); } if (pos < width-1) { - gr_blit(progressBarEmpty, pos, 0, width-pos, height, dx+pos, dy); + gr_blit(progressBarEmpty, pos, 0, width-pos, height, + progress_x+pos, progress_y); } } } @@ -253,7 +271,7 @@ static const char* LONG_PRESS_HELP[] = { void ScreenRecoveryUI::draw_screen_locked() { if (!show_text) { draw_background_locked(); - draw_progress_locked(); + draw_foreground_locked(); } else { gr_color(0, 0, 0, 255); gr_clear(); @@ -323,7 +341,7 @@ void ScreenRecoveryUI::update_progress_locked() { draw_screen_locked(); // Must redraw the whole screen pagesIdentical = true; } else { - draw_progress_locked(); // Draw only the progress bar and overlays + draw_foreground_locked(); // Draw only the progress bar and overlays } gr_flip(); } @@ -385,14 +403,14 @@ void ScreenRecoveryUI::ProgressThreadLoop() { void ScreenRecoveryUI::LoadBitmap(const char* filename, GRSurface** surface) { int result = res_create_display_surface(filename, surface); if (result < 0) { - LOGE("missing bitmap %s (error %d)\n", filename, result); + LOGE("couldn't load bitmap %s (error %d)\n", filename, result); } } void ScreenRecoveryUI::LoadLocalizedBitmap(const char* filename, GRSurface** surface) { int result = res_create_localized_alpha_surface(filename, locale, surface); if (result < 0) { - LOGE("missing bitmap %s (error %d)\n", filename, result); + LOGE("couldn't load bitmap %s (error %d)\n", filename, result); } } @@ -408,6 +426,9 @@ static char** Alloc2d(size_t rows, size_t cols) { void ScreenRecoveryUI::Init() { gr_init(); + density_ = static_cast(property_get_int32("ro.sf.lcd_density", 160)) / 160.f; + is_large_ = gr_fb_height() > PixelsFromDp(800); + gr_font_size(&char_width_, &char_height_); text_rows_ = gr_fb_height() / char_height_; text_cols_ = gr_fb_width() / char_width_; @@ -459,12 +480,13 @@ void ScreenRecoveryUI::LoadAnimation() { introFrames = new GRSurface*[intro_frames]; for (int i = 0; i < intro_frames; ++i) { - LoadBitmap(android::base::StringPrintf("intro%02d", i).c_str(), &introFrames[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]); } loopFrames = new GRSurface*[loop_frames]; for (int i = 0; i < loop_frames; ++i) { - LoadBitmap(android::base::StringPrintf("loop%02d", i).c_str(), &loopFrames[i]); + LoadBitmap(android::base::StringPrintf("loop%05d", i).c_str(), &loopFrames[i]); } } -- cgit v1.2.3 From a369104971a518c1f6ec5356f93c1a5f9548c833 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Wed, 27 Apr 2016 17:40:11 -0700 Subject: Improve the layout-related comments. Bug: http://b/26548285 Change-Id: I20ae75c4ec2dc64b982a047dba498ebda029c90d --- screen_ui.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'screen_ui.cpp') diff --git a/screen_ui.cpp b/screen_ui.cpp index 465be23fa..ccff5bae5 100644 --- a/screen_ui.cpp +++ b/screen_ui.cpp @@ -105,16 +105,18 @@ int ScreenRecoveryUI::PixelsFromDp(int dp) { // Here's the intended layout: -// 162dp -// icon (200dp) -// 62dp -// text (14sp) -// 24dp -// progress (2dp) -// 172dp +// | regular large +// ---------+-------------------- +// | 220dp 366dp +// icon | (200dp) (200dp) +// | 68dp 68dp +// text | (14sp) (14sp) +// | 32dp 32dp +// progress | (2dp) (2dp) +// | 194dp 340dp // Note that "baseline" is actually the *top* of each icon (because that's how our drawing -// routines work), so that's the more useful measurement. +// routines work), so that's the more useful measurement for calling code. int ScreenRecoveryUI::GetAnimationBaseline() { return GetTextBaseline() - PixelsFromDp(68) - gr_get_height(loopFrames[0]); -- cgit v1.2.3 From 35926c4b89f9dc51f3e55ef03a61e4da6dcb34be Mon Sep 17 00:00:00 2001 From: Tianjie Xu Date: Thu, 28 Apr 2016 18:06:26 -0700 Subject: Add ability to show "installing security update" Add a new command "--security" to boot commands. If this command is observed as part of BCB, choose a different background text picture for installing stage in recovery UI. As a result, users will see "installing security update" instead of "installing system update" when applying a security update package. Bug: 27837319 Change-Id: I2e2253a124993ecc24804fa1ee0b918ac96837c5 --- screen_ui.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'screen_ui.cpp') diff --git a/screen_ui.cpp b/screen_ui.cpp index ccff5bae5..85f789f3f 100644 --- a/screen_ui.cpp +++ b/screen_ui.cpp @@ -425,6 +425,16 @@ static char** Alloc2d(size_t rows, size_t cols) { return result; } +// Choose the right background string to display during update. +void ScreenRecoveryUI::SetSystemUpdateText(bool security_update) { + if (security_update) { + LoadLocalizedBitmap("installing_security_text", &installing_text); + } else { + LoadLocalizedBitmap("installing_text", &installing_text); + } + Redraw(); +} + void ScreenRecoveryUI::Init() { gr_init(); @@ -450,7 +460,10 @@ void ScreenRecoveryUI::Init() { LoadBitmap("stage_empty", &stageMarkerEmpty); LoadBitmap("stage_fill", &stageMarkerFill); - LoadLocalizedBitmap("installing_text", &installing_text); + // Background text for "installing_update" could be "installing update" + // or "installing security update". It will be set after UI init according + // to commands in BCB. + installing_text = nullptr; LoadLocalizedBitmap("erasing_text", &erasing_text); LoadLocalizedBitmap("no_command_text", &no_command_text); LoadLocalizedBitmap("error_text", &error_text); -- cgit v1.2.3