summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChung-Sheng Wu <chungsheng@google.com>2021-02-23 14:56:27 +0800
committerCommit Bot <commit-bot@chromium.org>2021-03-09 09:17:54 +0000
commit810195426623690a476c15e7ac0fadb4d17418d2 (patch)
tree0bc91fa37700037a44c4edb4032cbc436d8a9b65
parent7e0f6948ddf74d6822242d0b1d4bb6b98e6264e6 (diff)
downloadvboot-810195426623690a476c15e7ac0fadb4d17418d2.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>
-rw-r--r--firmware/2lib/2ui_screens.c56
1 files changed, 28 insertions, 28 deletions
diff --git a/firmware/2lib/2ui_screens.c b/firmware/2lib/2ui_screens.c
index fd1d5d2b..cda9400b 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){ \