Merge "Formatting RecoveryUI related files."
am: 8e7db8f4a6
Change-Id: I81e0e1e088da045f217aff957c7c5730d09cabbe
This commit is contained in:
+13
-9
@@ -91,11 +91,16 @@ GRSurface* ScreenRecoveryUI::GetCurrentFrame() {
|
|||||||
|
|
||||||
GRSurface* ScreenRecoveryUI::GetCurrentText() {
|
GRSurface* ScreenRecoveryUI::GetCurrentText() {
|
||||||
switch (currentIcon) {
|
switch (currentIcon) {
|
||||||
case ERASING: return erasing_text;
|
case ERASING:
|
||||||
case ERROR: return error_text;
|
return erasing_text;
|
||||||
case INSTALLING_UPDATE: return installing_text;
|
case ERROR:
|
||||||
case NO_COMMAND: return no_command_text;
|
return error_text;
|
||||||
case NONE: abort();
|
case INSTALLING_UPDATE:
|
||||||
|
return installing_text;
|
||||||
|
case NO_COMMAND:
|
||||||
|
return no_command_text;
|
||||||
|
case NONE:
|
||||||
|
abort();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,8 +133,7 @@ static constexpr int kLayouts[LAYOUT_MAX][DIMENSION_MAX] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
int ScreenRecoveryUI::GetAnimationBaseline() {
|
int ScreenRecoveryUI::GetAnimationBaseline() {
|
||||||
return GetTextBaseline() - PixelsFromDp(kLayouts[layout_][ICON]) -
|
return GetTextBaseline() - PixelsFromDp(kLayouts[layout_][ICON]) - gr_get_height(loopFrames[0]);
|
||||||
gr_get_height(loopFrames[0]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int ScreenRecoveryUI::GetTextBaseline() {
|
int ScreenRecoveryUI::GetTextBaseline() {
|
||||||
@@ -336,8 +340,8 @@ void ScreenRecoveryUI::draw_screen_locked() {
|
|||||||
SetColor(LOG);
|
SetColor(LOG);
|
||||||
int row = (text_top_ + text_rows_ - 1) % text_rows_;
|
int row = (text_top_ + text_rows_ - 1) % text_rows_;
|
||||||
size_t count = 0;
|
size_t count = 0;
|
||||||
for (int ty = gr_fb_height() - kMarginHeight - char_height_;
|
for (int ty = gr_fb_height() - kMarginHeight - char_height_; ty >= y && count < text_rows_;
|
||||||
ty >= y && count < text_rows_; ty -= char_height_, ++count) {
|
ty -= char_height_, ++count) {
|
||||||
int temp_y = ty;
|
int temp_y = ty;
|
||||||
DrawTextLine(x, &temp_y, text_[row], false);
|
DrawTextLine(x, &temp_y, text_[row], false);
|
||||||
--row;
|
--row;
|
||||||
|
|||||||
+9
-3
@@ -57,8 +57,7 @@ class ScreenRecoveryUI : public RecoveryUI {
|
|||||||
void ShowFile(const char* filename);
|
void ShowFile(const char* filename);
|
||||||
|
|
||||||
// menu display
|
// menu display
|
||||||
void StartMenu(const char* const * headers, const char* const * items,
|
void StartMenu(const char* const* headers, const char* const* items, int initial_selection);
|
||||||
int initial_selection);
|
|
||||||
int SelectMenu(int sel);
|
int SelectMenu(int sel);
|
||||||
void EndMenu();
|
void EndMenu();
|
||||||
|
|
||||||
@@ -67,7 +66,14 @@ class ScreenRecoveryUI : public RecoveryUI {
|
|||||||
void Redraw();
|
void Redraw();
|
||||||
|
|
||||||
enum UIElement {
|
enum UIElement {
|
||||||
HEADER, MENU, MENU_SEL_BG, MENU_SEL_BG_ACTIVE, MENU_SEL_FG, LOG, TEXT_FILL, INFO
|
HEADER,
|
||||||
|
MENU,
|
||||||
|
MENU_SEL_BG,
|
||||||
|
MENU_SEL_BG_ACTIVE,
|
||||||
|
MENU_SEL_FG,
|
||||||
|
LOG,
|
||||||
|
TEXT_FILL,
|
||||||
|
INFO
|
||||||
};
|
};
|
||||||
void SetColor(UIElement e);
|
void SetColor(UIElement e);
|
||||||
|
|
||||||
|
|||||||
@@ -228,7 +228,9 @@ void RecoveryUI::ProcessKey(int key_code, int updown) {
|
|||||||
case RecoveryUI::REBOOT:
|
case RecoveryUI::REBOOT:
|
||||||
if (reboot_enabled) {
|
if (reboot_enabled) {
|
||||||
reboot("reboot,");
|
reboot("reboot,");
|
||||||
while (true) { pause(); }
|
while (true) {
|
||||||
|
pause();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -332,8 +334,7 @@ int RecoveryUI::WaitKey() {
|
|||||||
bool RecoveryUI::IsUsbConnected() {
|
bool RecoveryUI::IsUsbConnected() {
|
||||||
int fd = open("/sys/class/android_usb/android0/state", O_RDONLY);
|
int fd = open("/sys/class/android_usb/android0/state", O_RDONLY);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
printf("failed to open /sys/class/android_usb/android0/state: %s\n",
|
printf("failed to open /sys/class/android_usb/android0/state: %s\n", strerror(errno));
|
||||||
strerror(errno));
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -341,8 +342,7 @@ bool RecoveryUI::IsUsbConnected() {
|
|||||||
// USB is connected if android_usb state is CONNECTED or CONFIGURED.
|
// USB is connected if android_usb state is CONNECTED or CONFIGURED.
|
||||||
int connected = (TEMP_FAILURE_RETRY(read(fd, &buf, 1)) == 1) && (buf == 'C');
|
int connected = (TEMP_FAILURE_RETRY(read(fd, &buf, 1)) == 1) && (buf == 'C');
|
||||||
if (close(fd) < 0) {
|
if (close(fd) < 0) {
|
||||||
printf("failed to close /sys/class/android_usb/android0/state: %s\n",
|
printf("failed to close /sys/class/android_usb/android0/state: %s\n", strerror(errno));
|
||||||
strerror(errno));
|
|
||||||
}
|
}
|
||||||
return connected;
|
return connected;
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-19
@@ -50,17 +50,13 @@ static double now() {
|
|||||||
return tv.tv_sec + tv.tv_usec / 1000000.0;
|
return tv.tv_sec + tv.tv_usec / 1000000.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
WearRecoveryUI::WearRecoveryUI() :
|
WearRecoveryUI::WearRecoveryUI()
|
||||||
progress_bar_y(259),
|
: progress_bar_y(259), outer_height(0), outer_width(0), menu_unusable_rows(0) {
|
||||||
outer_height(0),
|
|
||||||
outer_width(0),
|
|
||||||
menu_unusable_rows(0) {
|
|
||||||
intro_frames = 22;
|
intro_frames = 22;
|
||||||
loop_frames = 60;
|
loop_frames = 60;
|
||||||
animation_fps = 30;
|
animation_fps = 30;
|
||||||
|
|
||||||
for (size_t i = 0; i < 5; i++)
|
for (size_t i = 0; i < 5; i++) backgroundIcon[i] = NULL;
|
||||||
backgroundIcon[i] = NULL;
|
|
||||||
|
|
||||||
self = this;
|
self = this;
|
||||||
}
|
}
|
||||||
@@ -72,8 +68,7 @@ int WearRecoveryUI::GetProgressBaseline() {
|
|||||||
// Draw background frame on the screen. Does not flip pages.
|
// Draw background frame on the screen. Does not flip pages.
|
||||||
// Should only be called with updateMutex locked.
|
// Should only be called with updateMutex locked.
|
||||||
// TODO merge drawing routines with screen_ui
|
// TODO merge drawing routines with screen_ui
|
||||||
void WearRecoveryUI::draw_background_locked()
|
void WearRecoveryUI::draw_background_locked() {
|
||||||
{
|
|
||||||
pagesIdentical = false;
|
pagesIdentical = false;
|
||||||
gr_color(0, 0, 0, 255);
|
gr_color(0, 0, 0, 255);
|
||||||
gr_fill(0, 0, gr_fb_width(), gr_fb_height());
|
gr_fill(0, 0, gr_fb_width(), gr_fb_height());
|
||||||
@@ -86,8 +81,7 @@ void WearRecoveryUI::draw_background_locked()
|
|||||||
} else {
|
} else {
|
||||||
surface = loopFrames[current_frame];
|
surface = loopFrames[current_frame];
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
surface = backgroundIcon[currentIcon];
|
surface = backgroundIcon[currentIcon];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,8 +103,7 @@ static const char* HEADERS[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// TODO merge drawing routines with screen_ui
|
// TODO merge drawing routines with screen_ui
|
||||||
void WearRecoveryUI::draw_screen_locked()
|
void WearRecoveryUI::draw_screen_locked() {
|
||||||
{
|
|
||||||
char cur_selection_str[50];
|
char cur_selection_str[50];
|
||||||
|
|
||||||
draw_background_locked();
|
draw_background_locked();
|
||||||
@@ -148,7 +141,6 @@ void WearRecoveryUI::draw_screen_locked()
|
|||||||
SetColor(MENU);
|
SetColor(MENU);
|
||||||
|
|
||||||
for (int i = menu_start; i < menu_end; ++i) {
|
for (int i = menu_start; i < menu_end; ++i) {
|
||||||
|
|
||||||
if (i == menu_sel) {
|
if (i == menu_sel) {
|
||||||
// draw the highlight bar
|
// draw the highlight bar
|
||||||
SetColor(MENU_SEL_BG);
|
SetColor(MENU_SEL_BG);
|
||||||
@@ -178,8 +170,7 @@ void WearRecoveryUI::draw_screen_locked()
|
|||||||
int ty;
|
int ty;
|
||||||
int row = (text_top_ + text_rows_ - 1) % text_rows_;
|
int row = (text_top_ + text_rows_ - 1) % text_rows_;
|
||||||
size_t count = 0;
|
size_t count = 0;
|
||||||
for (int ty = gr_fb_height() - char_height_ - outer_height;
|
for (int ty = gr_fb_height() - char_height_ - outer_height; ty > y + 2 && count < text_rows_;
|
||||||
ty > y + 2 && count < text_rows_;
|
|
||||||
ty -= char_height_, ++count) {
|
ty -= char_height_, ++count) {
|
||||||
gr_text(gr_sys_font(), x + 4, ty, text_[row], 0);
|
gr_text(gr_sys_font(), x + 4, ty, text_[row], 0);
|
||||||
--row;
|
--row;
|
||||||
@@ -222,7 +213,8 @@ bool WearRecoveryUI::Init(const std::string& locale) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WearRecoveryUI::SetStage(int current, int max) {}
|
void WearRecoveryUI::SetStage(int current, int max) {
|
||||||
|
}
|
||||||
|
|
||||||
void WearRecoveryUI::Print(const char* fmt, ...) {
|
void WearRecoveryUI::Print(const char* fmt, ...) {
|
||||||
char buf[256];
|
char buf[256];
|
||||||
@@ -272,8 +264,7 @@ void WearRecoveryUI::StartMenu(const char* const * headers, const char* const *
|
|||||||
menu_sel = initial_selection;
|
menu_sel = initial_selection;
|
||||||
menu_start = 0;
|
menu_start = 0;
|
||||||
menu_end = visible_text_rows - 1 - menu_unusable_rows;
|
menu_end = visible_text_rows - 1 - menu_unusable_rows;
|
||||||
if (menu_items <= menu_end)
|
if (menu_items <= menu_end) menu_end = menu_items;
|
||||||
menu_end = menu_items;
|
|
||||||
update_screen_locked();
|
update_screen_locked();
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&updateMutex);
|
pthread_mutex_unlock(&updateMutex);
|
||||||
|
|||||||
Reference in New Issue
Block a user