From 292b9a6f6ab27a3c520090e0e0d8aba4522abca8 Mon Sep 17 00:00:00 2001 From: Mathew King Date: Thu, 21 Nov 2019 14:51:28 -0700 Subject: vboot: Don't warn user if enter key is pressed if rec switch is physical When the recovery switch is physical then the propmt to enter dev mode will say to press the recovery switch not the enter key. In this case we do not want to warn the user that an internal keyboard is needed to confirm we will just silently ignore the enter key. BUG=b:144034020 TEST=On Drallion enter key does not work to switch to dev mode and does not beep or print a warning when the enter key is pressed BRANCH=none Change-Id: I250ea2622c9c38bfc0d7463eb95ca65a12b41153 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1929601 Tested-by: Mathew King Reviewed-by: Julius Werner Commit-Queue: Mathew King --- firmware/lib/vboot_ui.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/firmware/lib/vboot_ui.c b/firmware/lib/vboot_ui.c index 642f149e..f7e82a99 100644 --- a/firmware/lib/vboot_ui.c +++ b/firmware/lib/vboot_ui.c @@ -112,21 +112,31 @@ int VbUserConfirms(struct vb2_context *ctx, uint32_t confirm_flags) shutdown_requested = VbWantShutdown(ctx, key); switch (key) { case VB_KEY_ENTER: - /* If we require a trusted keyboard for confirmation, - * but the keyboard may be faked (for instance, a USB - * device), beep and keep waiting. + /* If we are using a trusted keyboard or a trusted + * keyboard is not required then return yes, otherwise + * keep waiting (for instance if the user is using a + * USB keyboard). */ - if (confirm_flags & VB_CONFIRM_MUST_TRUST_KEYBOARD && - !(key_flags & VB_KEY_FLAG_TRUSTED_KEYBOARD)) { + if (!(confirm_flags & VB_CONFIRM_MUST_TRUST_KEYBOARD) || + (key_flags & VB_KEY_FLAG_TRUSTED_KEYBOARD)) { + VB2_DEBUG("Yes (1)\n"); + return 1; + } + + /* Beep and notify the user if the recovery switch is + * not physical. If it is physical then the prompt will + * tell the user to press the switch and will not say + * anything about the ENTER key so we can silenty ingore + * ENTER in this case. + */ + if (shared->flags & VBSD_BOOT_REC_SWITCH_VIRTUAL) vb2_error_notify("Please use internal keyboard " "to confirm\n", "VbUserConfirms() - " - "Trusted keyboard is requierd\n", + "Trusted keyboard is required\n", VB_BEEP_NOT_ALLOWED); - break; - } - VB2_DEBUG("Yes (1)\n"); - return 1; + + break; case ' ': VB2_DEBUG("Space (%d)\n", confirm_flags & VB_CONFIRM_SPACE_MEANS_NO); -- cgit v1.2.1