// Redraw everything on the screen. Does not flip pages.
// Should only be called with updateMutex locked.
void ScreenRecoveryUI::draw_screen_locked() {
if (!show_text) {
draw_background_locked(currentIcon);
draw_progress_locked();
} else {
gr_color(0, 0, 0, 255);
gr_clear();
int y = 0;
if (show_menu) {
char recovery_fingerprint[PROPERTY_VALUE_MAX];
property_get("ro.bootimage.build.fingerprint", recovery_fingerprint, "");
SetColor(INFO);
DrawTextLine(&y, "Android Recovery", true);
for (auto& chunk : android::base::Split(recovery_fingerprint, ":")) {
DrawTextLine(&y, chunk.c_str(), false);
}
DrawTextLines(&y, HasThreeButtons() ? REGULAR_HELP : LONG_PRESS_HELP);
SetColor(HEADER);
DrawTextLines(&y, menu_headers_);
SetColor(MENU);
DrawHorizontalRule(&y);
y += 4;
for (int i = 0; i < menu_items; ++i) {
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);
// Bold white text for the selected item.
SetColor(MENU_SEL_FG);
gr_text(4, y, menu_[i], true);
SetColor(MENU);
} else {
gr_text(4, y, menu_[i], false);
}
y += char_height + 4;
}
DrawHorizontalRule(&y);
}
// display from the bottom up, until we hit the top of the
// 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_;
size_t count = 0;
for (int ty = gr_fb_height() - char_height;
ty >= y && count < text_rows_;
ty -= char_height, ++count) {
gr_text(0, ty, text_[row], false);
--row;
if (row < 0) row = text_rows_ - 1;
}
}
}
// Redraw everything on the screen. Does not flip pages.
// Should only be called with updateMutex locked.
void ScreenRecoveryUI::draw_screen_locked()
{
if (!show_text) {
draw_background_locked(currentIcon);
draw_progress_locked();
// MStar Android Patch Begin
draw_top_title_locked();
draw_tip_title_locked(currentTip);
draw_exit_recovery_tip_title_locked(currentExitRecoveryTip);
// MStar Android Patch End
} else {
gr_color(0, 0, 0, 255);
gr_clear();
int y = 0;
int i = 0;
if (show_menu) {
SetColor(HEADER);
for (; i < menu_top + menu_items; ++i) {
if (i == menu_top) SetColor(MENU);
if (i == menu_top + menu_sel) {
// draw the highlight bar
SetColor(MENU_SEL_BG);
gr_fill(0, y-2, gr_fb_width(), y+char_height+2);
// white text of selected item
SetColor(MENU_SEL_FG);
if (menu[i][0]) gr_text(4, y, menu[i], 1);
SetColor(MENU);
} else {
if (menu[i][0]) gr_text(4, y, menu[i], i < menu_top);
}
y += char_height+4;
}
SetColor(MENU);
y += 4;
gr_fill(0, y, gr_fb_width(), y+2);
y += 4;
++i;
}
SetColor(LOG);
// display from the bottom up, until we hit the top of the
// screen, the bottom of the menu, or we've displayed the
// entire text buffer.
int ty;
int row = (text_top+text_rows-1) % text_rows;
for (int ty = gr_fb_height() - char_height, count = 0;
ty > y+2 && count < text_rows;
ty -= char_height, ++count) {
gr_text(4, ty, text[row], 0);
--row;
if (row < 0) row = text_rows-1;
}
}
}
// Updates only the progress bar, if possible, otherwise redraws the screen.
// Should only be called with updateMutex locked.
void ScreenRecoveryUI::update_progress_locked() {
if (show_text || !pagesIdentical) {
draw_screen_locked(); // Must redraw the whole screen
pagesIdentical = true;
} else {
draw_progress_locked(); // Draw only the progress bar and overlays
}
gr_flip();
}
// Updates only the progress bar, if possible, otherwise redraws the screen.
// Should only be called with gUpdateMutex locked.
static void update_progress_locked(void)
{
if (show_text || !gPagesIdentical) {
draw_screen_locked(); // Must redraw the whole screen
gPagesIdentical = 1;
} else {
draw_progress_locked(); // Draw only the progress bar
}
gr_flip();
}
// Updates only the progress bar, if possible, otherwise redraws the screen.
// Should only be called with gUpdateMutex locked.
static void update_progress_locked(void)
{
if (!ui_has_initialized) return;
if (show_text || !gPagesIdentical) {
draw_screen_locked(); // Must redraw the whole screen
gPagesIdentical = 1;
} else {
draw_progress_locked(); // Draw only the progress bar and overlays
}
gr_flip();
}
// Updates only the progress bar, if possible, otherwise redraws the screen.
// Should only be called with gUpdateMutex locked.
static void update_progress_locked(void) {
if (!ui_has_initialized)
return;
// set minimum delay between progress updates if we have a text overlay
// exception: gProgressScopeDuration != 0: to keep zip installer refresh behavior
struct timeval curtime;
gettimeofday(&curtime, NULL);
long delta_ms = delta_milliseconds(lastprogupd, curtime);
if (show_text && gProgressScopeDuration == 0 && lastprogupd.tv_sec > 0
&& delta_ms < UI_MIN_PROG_DELTA_MS) {
return;
}
if (show_text || !gPagesIdentical) {
draw_screen_locked(); // Must redraw the whole screen
gPagesIdentical = 1;
} else {
draw_progress_locked(); // Draw only the progress bar and overlays
}
gr_flip();
}
// Redraw everything on the screen. Does not flip pages.
// Should only be called with gUpdateMutex locked.
// joeykrim-all the LOGI help me keep my sanity
static void draw_screen_locked(void)
{
draw_background_locked(gCurrentIcon);
draw_progress_locked();
if (show_text) {
gr_color(0, 0, 0, 160);
gr_fill(0, 0, gr_fb_width(), gr_fb_height());
int i = 0, j = 0;
int k = menu_top + 1; //counter for bottom horizontal text line location
if (show_menu) {
//LOGI("text_rows: %i\n", text_rows);
//LOGI("menu_items: %i\n", menu_items);
//LOGI("menu_top: %i\n", menu_top);
//LOGI("menu_show_start: %i\n", menu_show_start);
//menu line item selection highlight draws
gr_color(mihc.r, mihc.g, mihc.b, mihc.a);
gr_fill(0, (menu_top + menu_sel - menu_show_start+1) * CHAR_HEIGHT,
gr_fb_width(), (menu_top + menu_sel - menu_show_start + 2)*CHAR_HEIGHT+1);
//draw semi-static headers
for (i = 0; i < menu_top; ++i) {
gr_color(htc.r, htc.g, htc.b, htc.a);
draw_text_line(i, menu[i]);
//LOGI("Semi-static headers internal counter i: %i\n", i);
}
//LOGI("Drawing horizontal start bar at k and k = %i\n", k);
gr_color(mhebc.r, mhebc.g, mhebc.b, mhebc.a);
//draws horizontal line at bottom of the menu
gr_fill(0, (k-1)*CHAR_HEIGHT+CHAR_HEIGHT/2-1,
gr_fb_width(), (k-1)*CHAR_HEIGHT+CHAR_HEIGHT/2+1);
//adjust counter for current position of selection and menu display starting point
if (menu_items - menu_show_start + menu_top >= text_rows){
j = text_rows - menu_top;
//LOGI("j = text_rows - mneu_top and j = %i\n", j);
} else {
j = menu_items - menu_show_start;
//LOGI("j = mneu_items - menu_show_start and j = %i\n", j);
}
//LOGI("outside draw menu items for loop and i goes until limit. limit-menu_show_start + menu_top + j = %i\n", menu_show_start + menu_top + j);
//draw menu items dynamically based on current menu starting position, menu selection point and headers
for (i = menu_show_start + menu_top; i < (menu_show_start + menu_top + j); ++i) {
//LOGI("inside draw menu items for loop and i = %i\n", i);
if (i == menu_top + menu_sel) {
gr_color(miwhc.r, miwhc.g, miwhc.b, miwhc.a);
//LOGI("draw_text_line -menu_item_when_highlighted_color- at i + 1= %i\n", i+1);
draw_text_line(i - menu_show_start +1, menu[i]);
} else {
gr_color(mtc.r, mtc.g, mtc.b, mtc.a);
//LOGI("draw_text_line -menu_item_color- at i + 1= %i\n", i+1);
draw_text_line(i - menu_show_start +1, menu[i]);
}
//LOGI("inside draw menu items for loop and k = %i\n", k);
k++;
}
//LOGI("drawing horizontal end bar at k and k = %i\n", k);
gr_color(mhebc.r, mhebc.g, mhebc.b, mhebc.a);
//draws horizontal line at bottom of the menu
gr_fill(0, k*CHAR_HEIGHT+CHAR_HEIGHT/2-1,
gr_fb_width(), k*CHAR_HEIGHT+CHAR_HEIGHT/2+1);
}
k++; //keep ui_print below menu items display
gr_color(upc.r, upc.g, upc.b, upc.a); //called by at least ui_print
for (; k < text_rows; ++k) {
draw_text_line(k, text[(k+text_top) % text_rows]);
}
}
}
请发表评论