diff options
author | Chung-Sheng Wu <chungsheng@google.com> | 2021-02-23 14:56:27 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-04-28 05:49:06 +0000 |
commit | 1addf33ccd22fac7d6d15f5a7c836866fa4fc72d (patch) | |
tree | 168c47df3a1a1f3dd8ec82d01c4556377dfe2e2a | |
parent | 46b38dab1b31111df6c575b4200f8ad8302d5d4e (diff) | |
download | vboot-1addf33ccd22fac7d6d15f5a7c836866fa4fc72d.tar.gz |
vboot/ui: Split out enabling/disabling buttons from log_page_* functions
Add a new log_page_update function to maintain the state of page up/down
buttons.
BUG=b:174127808
TEST=make clean && CC=x86_64-pc-linux-gnu-clang make runtests
BRANCH=none
Signed-off-by: Chung-Sheng Wu <chungsheng@google.com>
Change-Id: I6c396af3139229771557f017b816ea93aba27be2
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2641979
Tested-by: Chung-Sheng Wu <chungsheng@chromium.org>
Commit-Queue: Chung-Sheng Wu <chungsheng@chromium.org>
Reviewed-by: Meng-Huan Yu <menghuan@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2848045
Reviewed-by: Nick Vaccaro <nvaccaro@google.com>
Tested-by: Nick Vaccaro <nvaccaro@google.com>
-rw-r--r-- | firmware/2lib/2ui_screens.c | 56 |
1 files changed, 28 insertions, 28 deletions
diff --git a/firmware/2lib/2ui_screens.c b/firmware/2lib/2ui_screens.c index 8579c8f0..7f30af9a 100644 --- a/firmware/2lib/2ui_screens.c +++ b/firmware/2lib/2ui_screens.c @@ -60,7 +60,6 @@ static vb2_error_t power_off_action(struct vb2_ui_context *ui) * current_page is valid in prev and next actions, and the back_item is assigned * to a correct menu item index. */ -/* TODO(b/174127808): Split out enabling/disabling buttons. */ static vb2_error_t log_page_init(struct vb2_ui_context *ui) { @@ -68,6 +67,7 @@ static vb2_error_t log_page_init(struct vb2_ui_context *ui) ui->state->current_page = 0; + /* TODO(b/174127808): Split out enabling/disabling buttons. */ if (ui->state->page_count == 1) { VB2_SET_BIT(ui->state->disabled_item_mask, screen->page_up_item); @@ -83,50 +83,50 @@ static vb2_error_t log_page_init(struct vb2_ui_context *ui) return VB2_SUCCESS; } -static vb2_error_t log_page_prev_action(struct vb2_ui_context *ui) +static vb2_error_t log_page_update(struct vb2_ui_context *ui, + const char *new_log_string) { const struct vb2_screen_info *screen = ui->state->screen; - /* Validity check. */ - if (ui->state->current_page == 0) - return VB2_SUCCESS; - - ui->state->current_page--; - - /* Clear bits of page down. */ - if (ui->state->current_page != ui->state->page_count - 1) - VB2_CLR_BIT(ui->state->disabled_item_mask, - screen->page_down_item); - - /* Disable page up at the first page. */ + if (new_log_string) { + ui->state->page_count = vb2ex_prepare_log_screen( + screen->id, ui->locale_id, new_log_string); + if (ui->state->page_count == 0) + return VB2_ERROR_UI_LOG_INIT; + if (ui->state->current_page >= ui->state->page_count) + ui->state->current_page = ui->state->page_count - 1; + ui->force_display = 1; + } + VB2_CLR_BIT(ui->state->disabled_item_mask, screen->page_up_item); + VB2_CLR_BIT(ui->state->disabled_item_mask, screen->page_down_item); if (ui->state->current_page == 0) VB2_SET_BIT(ui->state->disabled_item_mask, screen->page_up_item); + if (ui->state->current_page == ui->state->page_count - 1) + VB2_SET_BIT(ui->state->disabled_item_mask, + screen->page_down_item); return VB2_SUCCESS; } -static vb2_error_t log_page_next_action(struct vb2_ui_context *ui) +static vb2_error_t log_page_prev_action(struct vb2_ui_context *ui) { - const struct vb2_screen_info *screen = ui->state->screen; - /* Validity check. */ - if (ui->state->current_page == ui->state->page_count - 1) + if (ui->state->current_page == 0) return VB2_SUCCESS; - ui->state->current_page++; - - /* Clear bits of page up. */ - if (ui->state->current_page != 0) - VB2_CLR_BIT(ui->state->disabled_item_mask, - screen->page_up_item); + ui->state->current_page--; + return log_page_update(ui, NULL); +} - /* Disable page down at the last page. */ +static vb2_error_t log_page_next_action(struct vb2_ui_context *ui) +{ + /* Validity check. */ if (ui->state->current_page == ui->state->page_count - 1) - VB2_SET_BIT(ui->state->disabled_item_mask, - screen->page_down_item); + return VB2_SUCCESS; - return VB2_SUCCESS; + ui->state->current_page++; + return log_page_update(ui, NULL); } #define PAGE_UP_ITEM ((struct vb2_menu_item){ \ |