diff options
author | android-build-team Robot | 2017-09-10 02:28:56 -0500 |
---|---|---|
committer | android-build-team Robot | 2017-09-10 02:28:56 -0500 |
commit | 739b576006baf57cb09e56636648e550bfa4378e (patch) | |
tree | 567e0908c310f7b8e3e75ea18a9250445807f525 | |
parent | 3a3ccf8b0fbcf3fa7fb16f14d1769f679a47ee3a (diff) | |
parent | 17fa5c7cab503015bde05fbe0455f8a6a3344396 (diff) | |
download | platform-bootable-recovery-739b576006baf57cb09e56636648e550bfa4378e.tar.gz platform-bootable-recovery-739b576006baf57cb09e56636648e550bfa4378e.tar.xz platform-bootable-recovery-739b576006baf57cb09e56636648e550bfa4378e.zip |
release-request-946c768b-83eb-4b7b-83e7-5737856fa8ec-for-git_oc-mr1-release-4326576 snap-temp-L80300000101054689
Change-Id: Ie2b658ebaabe2fdfb39b9443cd1d1b544a573faa
-rw-r--r-- | screen_ui.cpp | 16 | ||||
-rw-r--r-- | screen_ui.h | 3 | ||||
-rw-r--r-- | wear_ui.cpp | 13 |
3 files changed, 15 insertions, 17 deletions
diff --git a/screen_ui.cpp b/screen_ui.cpp index 5c93b667..b8f6ea28 100644 --- a/screen_ui.cpp +++ b/screen_ui.cpp | |||
@@ -69,7 +69,7 @@ ScreenRecoveryUI::ScreenRecoveryUI() | |||
69 | text_top_(0), | 69 | text_top_(0), |
70 | show_text(false), | 70 | show_text(false), |
71 | show_text_ever(false), | 71 | show_text_ever(false), |
72 | menu_(nullptr), | 72 | menu_headers_(nullptr), |
73 | show_menu(false), | 73 | show_menu(false), |
74 | menu_items(0), | 74 | menu_items(0), |
75 | menu_sel(0), | 75 | menu_sel(0), |
@@ -356,10 +356,10 @@ void ScreenRecoveryUI::draw_screen_locked() { | |||
356 | DrawHighlightBar(0, y - 2, gr_fb_width(), char_height_ + 4); | 356 | DrawHighlightBar(0, y - 2, gr_fb_width(), char_height_ + 4); |
357 | // Bold white text for the selected item. | 357 | // Bold white text for the selected item. |
358 | SetColor(MENU_SEL_FG); | 358 | SetColor(MENU_SEL_FG); |
359 | y += DrawTextLine(x, y, menu_[i], true); | 359 | y += DrawTextLine(x, y, menu_[i].c_str(), true); |
360 | SetColor(MENU); | 360 | SetColor(MENU); |
361 | } else { | 361 | } else { |
362 | y += DrawTextLine(x, y, menu_[i], false); | 362 | y += DrawTextLine(x, y, menu_[i].c_str(), false); |
363 | } | 363 | } |
364 | } | 364 | } |
365 | y += DrawHorizontalRule(y); | 365 | y += DrawHorizontalRule(y); |
@@ -508,7 +508,6 @@ bool ScreenRecoveryUI::Init(const std::string& locale) { | |||
508 | 508 | ||
509 | text_ = Alloc2d(text_rows_, text_cols_ + 1); | 509 | text_ = Alloc2d(text_rows_, text_cols_ + 1); |
510 | file_viewer_text_ = Alloc2d(text_rows_, text_cols_ + 1); | 510 | file_viewer_text_ = Alloc2d(text_rows_, text_cols_ + 1); |
511 | menu_ = Alloc2d(text_rows_, text_cols_ + 1); | ||
512 | 511 | ||
513 | text_col_ = text_row_ = 0; | 512 | text_col_ = text_row_ = 0; |
514 | text_top_ = 1; | 513 | text_top_ = 1; |
@@ -771,12 +770,11 @@ void ScreenRecoveryUI::StartMenu(const char* const* headers, const char* const* | |||
771 | pthread_mutex_lock(&updateMutex); | 770 | pthread_mutex_lock(&updateMutex); |
772 | if (text_rows_ > 0 && text_cols_ > 0) { | 771 | if (text_rows_ > 0 && text_cols_ > 0) { |
773 | menu_headers_ = headers; | 772 | menu_headers_ = headers; |
774 | size_t i = 0; | 773 | menu_.clear(); |
775 | for (; i < text_rows_ && items[i] != nullptr; ++i) { | 774 | for (size_t i = 0; i < text_rows_ && items[i] != nullptr; ++i) { |
776 | strncpy(menu_[i], items[i], text_cols_ - 1); | 775 | menu_.emplace_back(std::string(items[i], strnlen(items[i], text_cols_ - 1))); |
777 | menu_[i][text_cols_ - 1] = '\0'; | ||
778 | } | 776 | } |
779 | menu_items = i; | 777 | menu_items = static_cast<int>(menu_.size()); |
780 | show_menu = true; | 778 | show_menu = true; |
781 | menu_sel = initial_selection; | 779 | menu_sel = initial_selection; |
782 | update_screen_locked(); | 780 | update_screen_locked(); |
diff --git a/screen_ui.h b/screen_ui.h index 62dda755..8231a2ba 100644 --- a/screen_ui.h +++ b/screen_ui.h | |||
@@ -21,6 +21,7 @@ | |||
21 | #include <stdio.h> | 21 | #include <stdio.h> |
22 | 22 | ||
23 | #include <string> | 23 | #include <string> |
24 | #include <vector> | ||
24 | 25 | ||
25 | #include "ui.h" | 26 | #include "ui.h" |
26 | 27 | ||
@@ -127,7 +128,7 @@ class ScreenRecoveryUI : public RecoveryUI { | |||
127 | bool show_text; | 128 | bool show_text; |
128 | bool show_text_ever; // has show_text ever been true? | 129 | bool show_text_ever; // has show_text ever been true? |
129 | 130 | ||
130 | char** menu_; | 131 | std::vector<std::string> menu_; |
131 | const char* const* menu_headers_; | 132 | const char* const* menu_headers_; |
132 | bool show_menu; | 133 | bool show_menu; |
133 | int menu_items, menu_sel; | 134 | int menu_items, menu_sel; |
diff --git a/wear_ui.cpp b/wear_ui.cpp index 169ef20e..624116c0 100644 --- a/wear_ui.cpp +++ b/wear_ui.cpp | |||
@@ -154,11 +154,11 @@ void WearRecoveryUI::draw_screen_locked() { | |||
154 | // white text of selected item | 154 | // white text of selected item |
155 | SetColor(MENU_SEL_FG); | 155 | SetColor(MENU_SEL_FG); |
156 | if (menu_[i][0]) { | 156 | if (menu_[i][0]) { |
157 | gr_text(gr_sys_font(), x + 4, y, menu_[i], 1); | 157 | gr_text(gr_sys_font(), x + 4, y, menu_[i].c_str(), 1); |
158 | } | 158 | } |
159 | SetColor(MENU); | 159 | SetColor(MENU); |
160 | } else if (menu_[i][0]) { | 160 | } else if (menu_[i][0]) { |
161 | gr_text(gr_sys_font(), x + 4, y, menu_[i], 0); | 161 | gr_text(gr_sys_font(), x + 4, y, menu_[i].c_str(), 0); |
162 | } | 162 | } |
163 | y += char_height_ + 4; | 163 | y += char_height_ + 4; |
164 | } | 164 | } |
@@ -255,17 +255,16 @@ void WearRecoveryUI::StartMenu(const char* const* headers, const char* const* it | |||
255 | pthread_mutex_lock(&updateMutex); | 255 | pthread_mutex_lock(&updateMutex); |
256 | if (text_rows_ > 0 && text_cols_ > 0) { | 256 | if (text_rows_ > 0 && text_cols_ > 0) { |
257 | menu_headers_ = headers; | 257 | menu_headers_ = headers; |
258 | size_t i = 0; | 258 | menu_.clear(); |
259 | // "i < text_rows_" is removed from the loop termination condition, | 259 | // "i < text_rows_" is removed from the loop termination condition, |
260 | // which is different from the one in ScreenRecoveryUI::StartMenu(). | 260 | // which is different from the one in ScreenRecoveryUI::StartMenu(). |
261 | // Because WearRecoveryUI supports scrollable menu, it's fine to have | 261 | // Because WearRecoveryUI supports scrollable menu, it's fine to have |
262 | // more entries than text_rows_. The menu may be truncated otherwise. | 262 | // more entries than text_rows_. The menu may be truncated otherwise. |
263 | // Bug: 23752519 | 263 | // Bug: 23752519 |
264 | for (; items[i] != nullptr; i++) { | 264 | for (size_t i = 0; items[i] != nullptr; i++) { |
265 | strncpy(menu_[i], items[i], text_cols_ - 1); | 265 | menu_.emplace_back(std::string(items[i], strnlen(items[i], text_cols_ - 1))); |
266 | menu_[i][text_cols_ - 1] = '\0'; | ||
267 | } | 266 | } |
268 | menu_items = i; | 267 | menu_items = static_cast<int>(menu_.size()); |
269 | show_menu = true; | 268 | show_menu = true; |
270 | menu_sel = initial_selection; | 269 | menu_sel = initial_selection; |
271 | menu_start = 0; | 270 | menu_start = 0; |