recovery: split in submenus
Squashed:
Author: Alessandro <ales.astone@gmail.com>
Date: Mon Apr 13 00:39:37 2020 +0200
recovery: fixup `split in submenus`
* If we return an action of type MENU_*, we will quickly redraw
the menu rather than going through finish_recovery(), which
is unnecessarily slow.
Change-Id: Ie7ade16a3e6ae97457fd45172af60f743436596d
Co-authored-by: aleasto <ales.astone@gmail.com>
Change-Id: I4426689634ca477955b67d2264999f450f02067f
diff --git a/recovery.cpp b/recovery.cpp
index 8ef5190..b7ebd4c 100644
--- a/recovery.cpp
+++ b/recovery.cpp
@@ -386,22 +386,18 @@
}
ui->SetProgressType(RecoveryUI::EMPTY);
- std::vector<std::string> headers;
- if (update_in_progress) {
- headers = { "WARNING: Previous installation has failed.",
- " Your device may fail to boot if you reboot or power off now." };
- }
-
+change_menu:
size_t chosen_item = ui->ShowMenu(
- headers, device->GetMenuItems(), 0, false,
+ device->GetMenuHeaders(), device->GetMenuItems(), 0, false,
std::bind(&Device::HandleMenuKey, device, std::placeholders::_1, std::placeholders::_2));
// Handle Interrupt key
if (chosen_item == static_cast<size_t>(RecoveryUI::KeyError::INTERRUPTED)) {
return Device::KEY_INTERRUPTED;
}
- // We are already in the main menu
+
if (chosen_item == Device::kGoBack || chosen_item == Device::kGoHome) {
- continue;
+ device->GoHome();
+ goto change_menu;
}
// Device-specific code may take some action here. It may return one of the core actions
@@ -412,6 +408,12 @@
: device->InvokeMenuItem(chosen_item);
switch (chosen_action) {
+ case Device::MENU_BASE:
+ case Device::MENU_UPDATE:
+ case Device::MENU_WIPE:
+ case Device::MENU_ADVANCED:
+ goto change_menu;
+
case Device::REBOOT_FROM_FASTBOOT: // Can not happen
case Device::SHUTDOWN_FROM_FASTBOOT: // Can not happen
case Device::NO_ACTION: