From 93f1142d7a7bbee5c1bb551d197ce1e4c2c2ef87 Mon Sep 17 00:00:00 2001 From: Shelley Chen Date: Wed, 16 Aug 2017 11:31:05 -0700 Subject: [PATCH] detachables: Display recovery insert icon at recovery startup When user first starts up recovery (3 finger salute), display usb insert instructions and original insert graphic until user starts pushing volume buttons. If the user pushes power button during while the icon is displayed (no menu items), device will shut down (this is to accomodate users that accidentally enter the recovery screen and want to exit quickly). Upon user pressing the volume buttons, the insert icon will disappear and user will see the menu items and be able to scroll up/down. BUG=b:64400325 BRANCH=None TEST=boot into recovery. Make sure graphic shown until start pushing volume buttons. Change-Id: I4a5001271a0b84d1237d4bbc6a098afa10cb9372 Signed-off-by: Shelley Chen Reviewed-on: https://chromium-review.googlesource.com/617600 Reviewed-by: Julius Werner --- firmware/lib/vboot_ui_menu.c | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/firmware/lib/vboot_ui_menu.c b/firmware/lib/vboot_ui_menu.c index 4bc0cffc6d..3bda0c0120 100644 --- a/firmware/lib/vboot_ui_menu.c +++ b/firmware/lib/vboot_ui_menu.c @@ -167,6 +167,7 @@ typedef enum _VB_MENU { VB_MENU_RECOVERY, VB_MENU_TO_DEV, VB_MENU_LANGUAGES, + VB_MENU_RECOVERY_INSERT, VB_MENU_COUNT, } VB_MENU; @@ -368,6 +369,7 @@ static const uint32_t VB_MENU_TO_SCREEN_MAP[] = { VB_SCREEN_RECOVERY_MENU, VB_SCREEN_RECOVERY_TO_DEV_MENU, VB_SCREEN_LANGUAGES_MENU, + VB_SCREEN_RECOVERY_INSERT, }; VbError_t vb2_draw_current_screen(struct vb2_context *ctx, @@ -520,6 +522,10 @@ VbError_t vb2_update_menu(struct vb2_context *ctx) break; } break; + case VB_MENU_RECOVERY_INSERT: + vb2_set_menu_items(VB_MENU_RECOVERY, + VB_RECOVERY_POWER_OFF); + break; case VB_MENU_RECOVERY: switch(current_menu_idx) { case VB_RECOVERY_TO_DEV: @@ -1058,9 +1064,9 @@ VbError_t vb2_recovery_menu(struct vb2_context *ctx, VbCommonParams *cparams) VB2_DEBUG("waiting for a recovery image\n"); /* Initialize menu to recovery menu. */ - current_menu = VB_MENU_RECOVERY; - prev_menu = VB_MENU_RECOVERY; - current_menu_idx = VB_RECOVERY_POWER_OFF; + current_menu = VB_MENU_RECOVERY_INSERT; + prev_menu = VB_MENU_RECOVERY_INSERT; + current_menu_idx = 0; while (1) { VB2_DEBUG("attempting to load kernel2\n"); @@ -1101,13 +1107,15 @@ VbError_t vb2_recovery_menu(struct vb2_context *ctx, VbCommonParams *cparams) /* nothing pressed */ break; case VB_BUTTON_VOL_UP: - case VB_KEY_UP: - vb2_update_selection(cparams, key); - vb2_draw_current_screen(ctx, cparams); - break; case VB_BUTTON_VOL_DOWN: + case VB_KEY_UP: case VB_KEY_DOWN: - vb2_update_selection(cparams, key); + if (current_menu == VB_MENU_RECOVERY_INSERT) { + ret = vb2_update_menu(ctx); + vb2_set_disabled_idx_mask(shared->flags); + } else { + vb2_update_selection(cparams, key); + } vb2_draw_current_screen(ctx, cparams); break; case VB_BUTTON_POWER: @@ -1124,6 +1132,18 @@ VbError_t vb2_recovery_menu(struct vb2_context *ctx, VbCommonParams *cparams) vb2_set_disabled_idx_mask(shared->flags); + /* + * If user hits power button in + * initial recovery screen (ie: + * because didn't really want to go + * there), power button will turn off + * device. + */ + if (current_menu == VB_MENU_RECOVERY_INSERT) { + ret = VBERROR_SHUTDOWN_REQUESTED; + } + + if (current_menu != VB_MENU_RECOVERY || current_menu_idx != VB_RECOVERY_DBG_INFO) { /*