minidiag/ui: Prevent calling update action if there were no updates
Add a return code `VB2_ERROR_EX_DIAG_TEST_UPDATED` to determine if
updating needed.
BUG=b:168776970
BRANCH=none
TEST=Build locally, boot recovery, select 'run diagnostics',
enter memory test (quick) screen,
and observe that the delay reduces while pressing keyboard
Cq-Depend: chromium:2423699
Signed-off-by: Hsuan Ting Chen <roccochen@chromium.org>
Change-Id: I7606911bee7257e8eed4ec35d197efaa57b72e13
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2424370
Reviewed-by: Yu-Ping Wu <yupingso@chromium.org>
diff --git a/firmware/2lib/2ui_screens.c b/firmware/2lib/2ui_screens.c
index 878b4ed..2ec779c 100644
--- a/firmware/2lib/2ui_screens.c
+++ b/firmware/2lib/2ui_screens.c
@@ -1129,7 +1129,12 @@
return VB2_REQUEST_UI_CONTINUE;
vb2_error_t rv = op(reset, &log_string);
- if ((rv && rv != VB2_ERROR_EX_DIAG_TEST_RUNNING) || !log_string) {
+
+ /* The test is still running but the output buffer was unchanged. */
+ if (rv == VB2_ERROR_EX_DIAG_TEST_RUNNING)
+ return VB2_REQUEST_UI_CONTINUE;
+
+ if ((rv && rv != VB2_ERROR_EX_DIAG_TEST_UPDATED) || !log_string) {
VB2_DEBUG("ERROR: Failed to retrieve memory test status\n");
ui->error_code = VB2_UI_ERROR_DIAGNOSTICS;
return vb2_ui_screen_back(ui);
@@ -1152,7 +1157,7 @@
VB2_CLR_BIT(ui->state->hidden_item_mask,
DIAGNOSTICS_MEMORY_ITEM_CANCEL);
VB2_CLR_BIT(ui->state->hidden_item_mask, DIAGNOSTICS_MEMORY_ITEM_BACK);
- if (rv == VB2_ERROR_EX_DIAG_TEST_RUNNING) {
+ if (rv == VB2_ERROR_EX_DIAG_TEST_UPDATED) {
VB2_SET_BIT(ui->state->hidden_item_mask,
DIAGNOSTICS_MEMORY_ITEM_BACK);
if (ui->state->selected_item == DIAGNOSTICS_MEMORY_ITEM_BACK)
diff --git a/firmware/2lib/include/2api.h b/firmware/2lib/include/2api.h
index b4dfadf..4c5e1dc 100644
--- a/firmware/2lib/include/2api.h
+++ b/firmware/2lib/include/2api.h
@@ -1513,7 +1513,7 @@
* control for a short period of time running memory test, and then return the
* result of current status. If `reset` is not zero, it will reset the memory
* test state.
- * *
+ *
* @param reset Discard the current memory test result and re-initialize
* a new test.
* @param out For returning a read-only pointer of full log string which is
@@ -1522,7 +1522,9 @@
* until next call.
* @return The status of memory test. VB2_SUCCESS means the test is finished,
* regardless of passing or failing. VB2_ERROR_EX_DIAG_TEST_RUNNING means
- * the test is still running. Other non-zero codes for internal errors.
+ * the test is still running but the output buffer was unchanged.
+ * VB2_ERROR_EX_DIAG_TEST_UPDATED means the test is still running and the output
+ * buffer was updated. Other non-zero codes for internal errors.
*/
vb2_error_t vb2ex_diag_memory_quick_test(int reset, const char **out);
vb2_error_t vb2ex_diag_memory_full_test(int reset, const char **out);
diff --git a/firmware/2lib/include/2return_codes.h b/firmware/2lib/include/2return_codes.h
index 3a50f94..4abe16a 100644
--- a/firmware/2lib/include/2return_codes.h
+++ b/firmware/2lib/include/2return_codes.h
@@ -731,9 +731,12 @@
/* Error setting vendor data (see: VbExSetVendorData). */
VB2_ERROR_EX_SET_VENDOR_DATA,
- /* The memory test is running. */
+ /* The memory test is running but the output buffer was unchanged. */
VB2_ERROR_EX_DIAG_TEST_RUNNING,
+ /* The memory test is running and the output buffer was updated. */
+ VB2_ERROR_EX_DIAG_TEST_UPDATED,
+
/* The memory test initialization failed. */
VB2_ERROR_EX_DIAG_TEST_INIT_FAILED,