summaryrefslogtreecommitdiffstats
path: root/wear_ui.cpp
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2017-09-10 09:28:56 +0200
committerandroid-build-team Robot <android-build-team-robot@google.com>2017-09-10 09:28:56 +0200
commit739b576006baf57cb09e56636648e550bfa4378e (patch)
tree567e0908c310f7b8e3e75ea18a9250445807f525 /wear_ui.cpp
parentrelease-request-81b48854-d0e0-49af-bcf2-857273cbb8dc-for-git_oc-mr1-release-4306444 snap-temp-L17300000097872583 (diff)
parentui: Manage menu_ with std::vector. (diff)
downloadandroid_bootable_recovery-739b576006baf57cb09e56636648e550bfa4378e.tar
android_bootable_recovery-739b576006baf57cb09e56636648e550bfa4378e.tar.gz
android_bootable_recovery-739b576006baf57cb09e56636648e550bfa4378e.tar.bz2
android_bootable_recovery-739b576006baf57cb09e56636648e550bfa4378e.tar.lz
android_bootable_recovery-739b576006baf57cb09e56636648e550bfa4378e.tar.xz
android_bootable_recovery-739b576006baf57cb09e56636648e550bfa4378e.tar.zst
android_bootable_recovery-739b576006baf57cb09e56636648e550bfa4378e.zip
Diffstat (limited to '')
-rw-r--r--wear_ui.cpp13
1 files changed, 6 insertions, 7 deletions
diff --git a/wear_ui.cpp b/wear_ui.cpp
index 169ef20e1..624116c0c 100644
--- a/wear_ui.cpp
+++ b/wear_ui.cpp
@@ -154,11 +154,11 @@ void WearRecoveryUI::draw_screen_locked() {
// white text of selected item
SetColor(MENU_SEL_FG);
if (menu_[i][0]) {
- gr_text(gr_sys_font(), x + 4, y, menu_[i], 1);
+ gr_text(gr_sys_font(), x + 4, y, menu_[i].c_str(), 1);
}
SetColor(MENU);
} else if (menu_[i][0]) {
- gr_text(gr_sys_font(), x + 4, y, menu_[i], 0);
+ gr_text(gr_sys_font(), x + 4, y, menu_[i].c_str(), 0);
}
y += char_height_ + 4;
}
@@ -255,17 +255,16 @@ void WearRecoveryUI::StartMenu(const char* const* headers, const char* const* it
pthread_mutex_lock(&updateMutex);
if (text_rows_ > 0 && text_cols_ > 0) {
menu_headers_ = headers;
- size_t i = 0;
+ menu_.clear();
// "i < text_rows_" is removed from the loop termination condition,
// which is different from the one in ScreenRecoveryUI::StartMenu().
// Because WearRecoveryUI supports scrollable menu, it's fine to have
// more entries than text_rows_. The menu may be truncated otherwise.
// Bug: 23752519
- for (; items[i] != nullptr; i++) {
- strncpy(menu_[i], items[i], text_cols_ - 1);
- menu_[i][text_cols_ - 1] = '\0';
+ for (size_t i = 0; items[i] != nullptr; i++) {
+ menu_.emplace_back(std::string(items[i], strnlen(items[i], text_cols_ - 1)));
}
- menu_items = i;
+ menu_items = static_cast<int>(menu_.size());
show_menu = true;
menu_sel = initial_selection;
menu_start = 0;