diff options
author | Hsuan Ting Chen <roccochen@chromium.org> | 2020-09-24 12:06:06 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-10-14 05:58:49 +0000 |
commit | 519c608d2464b5b45b7bfe432a27eae119777971 (patch) | |
tree | 9f6053cb0e9b7457c564e7a197cf451958e599ea /firmware/2lib/2ui.c | |
parent | 4e93a487ff99c80777ee80f183193e07bc58c41d (diff) | |
download | vboot-519c608d2464b5b45b7bfe432a27eae119777971.tar.gz |
vboot/ui: Split disabled_item_mask into two masks for log screen
Add three macros in 2api.h for bitmask operations:
- VB2_SET_BIT(mask, index)
- VB2_CLR_BIT(mask, index)
- VB2_GET_BIT(mask, index)
These macros will be used in corresponding depthcharge CLs.
Split disabled_item_mask into:
- disabled_item_mask: Disabled style, but still visible and selectable.
- hidden_item_mask: Not visible.
Ignore selecting on disabled menu items.
Set appropriate disabled_item_mask for page up/down buttons in log
screen.
Revise tests of hidden_item_mask and add unit tests of disabled_item_mask.
BUG=b:163301076, b:146399181
BRANCH=none
TEST=CC=x86_64-pc-linux-gnu-clang;
make clean && make runtests
TEST=CC=x86_64-pc-linux-gnu-clang; DETACHABLE=1;
make clean && make runtests
TEST=CC=x86_64-pc-linux-gnu-clang; PHYSICAL_PRESENCE_KEYBOARD=1;
make clean && make runtests
TEST=CC=x86_64-pc-linux-gnu-clang; DIAGNOSTIC_UI=1;
make clean && make runtests
TEST=Build locally, navigate to debug info screen with <TAB>,
select page up or page down, and observe that nothing happens.
Cq-Depend: chromium:2432168
Signed-off-by: Hsuan Ting Chen <roccochen@chromium.org>
Change-Id: I1607af53f6e2b5c1cde568cb24606314051d2380
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2426154
Reviewed-by: Yu-Ping Wu <yupingso@chromium.org>
Commit-Queue: Yu-Ping Wu <yupingso@chromium.org>
Diffstat (limited to 'firmware/2lib/2ui.c')
-rw-r--r-- | firmware/2lib/2ui.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/firmware/2lib/2ui.c b/firmware/2lib/2ui.c index 44edc4a8..5b1e3394 100644 --- a/firmware/2lib/2ui.c +++ b/firmware/2lib/2ui.c @@ -144,8 +144,7 @@ vb2_error_t vb2_ui_menu_prev(struct vb2_ui_context *ui) return VB2_REQUEST_UI_CONTINUE; item = ui->state->selected_item - 1; - while (item >= 0 && - ((1 << item) & ui->state->disabled_item_mask)) + while (item >= 0 && VB2_GET_BIT(ui->state->hidden_item_mask, item)) item--; /* Only update if item is valid */ if (item >= 0) @@ -165,7 +164,7 @@ vb2_error_t vb2_ui_menu_next(struct vb2_ui_context *ui) menu = get_menu(ui); item = ui->state->selected_item + 1; while (item < menu->num_items && - ((1 << item) & ui->state->disabled_item_mask)) + VB2_GET_BIT(ui->state->hidden_item_mask, item)) item++; /* Only update if item is valid */ if (item < menu->num_items) @@ -188,6 +187,14 @@ vb2_error_t vb2_ui_menu_select(struct vb2_ui_context *ui) menu_item = &menu->items[ui->state->selected_item]; + /* Cannot select a disabled menu item */ + if (VB2_GET_BIT(ui->state->disabled_item_mask, + ui->state->selected_item)) { + VB2_DEBUG("Menu item <%s> disabled; ignoring\n", + menu_item->text); + return VB2_REQUEST_UI_CONTINUE; + } + if (menu_item->action) { VB2_DEBUG("Menu item <%s> run action\n", menu_item->text); return menu_item->action(ui); @@ -331,6 +338,7 @@ vb2_error_t ui_loop(struct vb2_context *ctx, enum vb2_screen root_screen_id, vb2ex_display_ui(ui.state->screen->id, ui.locale_id, ui.state->selected_item, ui.state->disabled_item_mask, + ui.state->hidden_item_mask, ui.disable_timer, ui.state->current_page, ui.error_code); |