diff options
author | Michael Bestas <mikeioannina@gmail.com> | 2013-07-12 13:29:45 +0300 |
---|---|---|
committer | Michael Bestas <mikeioannina@gmail.com> | 2013-07-24 22:52:22 +0300 |
commit | b9ecf6480514bdd21e5a546a7ff376920b31153b (patch) | |
tree | 07b7c12e5aae7e175c28a1af997d7a84b210e58c | |
parent | 8736cc11d9dc7f4921008a4a5744092103cdac11 (diff) | |
download | bootable_recovery-b9ecf6480514bdd21e5a546a7ff376920b31153b.zip bootable_recovery-b9ecf6480514bdd21e5a546a7ff376920b31153b.tar.gz bootable_recovery-b9ecf6480514bdd21e5a546a7ff376920b31153b.tar.bz2 |
Add power off & reboot to bootloader mode in advanced menu
Also:
Cleanup leftovers from previous poweroff option
Always ensure a clean reboot (Thanks to PhilZ for his implementation)
Bootloader option defaults to "bootloader" (fastboot mode), it can be overriden
by defining "ro.bootloader.mode=download" prop for samsung download mode
We leave reboot to bootloader option always enabled, that way we can
override the get_filtered_menu_selection bug that breaks the order
of the options when NULLifying menu options.
Signed-off-by: Michael Bestas <mikeioannina@gmail.com>
Change-Id: I6d674b37ab41ab342b105993719277360b4707e4
-rw-r--r-- | extendedcommands.c | 48 | ||||
-rw-r--r-- | recovery.c | 13 | ||||
-rw-r--r-- | recovery_ui.h | 4 |
3 files changed, 49 insertions, 16 deletions
diff --git a/extendedcommands.c b/extendedcommands.c index 6759335..fb64e75 100644 --- a/extendedcommands.c +++ b/extendedcommands.c @@ -1318,6 +1318,8 @@ void show_advanced_menu() }; static char* list[] = { "reboot recovery", + "reboot to bootloader", + "power off", "wipe dalvik cache", "report error", "key test", @@ -1328,14 +1330,20 @@ void show_advanced_menu() NULL }; + char bootloader_mode[PROPERTY_VALUE_MAX]; + property_get("ro.bootloader.mode", bootloader_mode, ""); + if (!strcmp(bootloader_mode, "download")) { + list[1] = "reboot to download mode"; + } + if (!can_partition("/sdcard")) { - list[5] = NULL; + list[7] = NULL; } if (!can_partition("/external_sd")) { - list[6] = NULL; + list[8] = NULL; } if (!can_partition("/emmc")) { - list[7] = NULL; + list[9] = NULL; } for (;;) @@ -1346,9 +1354,29 @@ void show_advanced_menu() switch (chosen_item) { case 0: - android_reboot(ANDROID_RB_RESTART2, 0, "recovery"); + { + ui_print("Rebooting recovery...\n"); + reboot_main_system(ANDROID_RB_RESTART2, 0, "recovery"); break; + } case 1: + { + if (!strcmp(bootloader_mode, "download")) { + ui_print("Rebooting to download mode...\n"); + reboot_main_system(ANDROID_RB_RESTART2, 0, "download"); + } else { + ui_print("Rebooting to bootloader...\n"); + reboot_main_system(ANDROID_RB_RESTART2, 0, "bootloader"); + } + break; + } + case 2: + { + ui_print("Shutting down...\n"); + reboot_main_system(ANDROID_RB_POWEROFF, 0, 0); + break; + } + case 3: if (0 != ensure_path_mounted("/data")) break; ensure_path_mounted("/sd-ext"); @@ -1361,10 +1389,10 @@ void show_advanced_menu() } ensure_path_unmounted("/data"); break; - case 2: + case 4: handle_failure(1); break; - case 3: + case 5: { ui_print("Outputting key codes.\n"); ui_print("Go back to end debugging.\n"); @@ -1379,16 +1407,16 @@ void show_advanced_menu() while (action != GO_BACK); break; } - case 4: + case 6: ui_printlogtail(12); break; - case 5: + case 7: partition_sdcard("/sdcard"); break; - case 6: + case 8: partition_sdcard("/external_sd"); break; - case 7: + case 9: partition_sdcard("/emmc"); break; } @@ -716,7 +716,7 @@ prompt_and_wait() { int status; switch (chosen_item) { case ITEM_REBOOT: - poweroff=0; + poweroff = 0; return; case ITEM_WIPE_DATA: @@ -749,10 +749,6 @@ prompt_and_wait() { case ITEM_ADVANCED: show_advanced_menu(); break; - - case ITEM_POWEROFF: - poweroff = 1; - return; } } } @@ -795,6 +791,13 @@ setup_adbd() { property_set("service.adb.root", "1"); } +// call a clean reboot +void reboot_main_system(int cmd, int flags, char *arg) { + verify_root_and_recovery(); + finish_recovery(NULL); // sync() in here + android_reboot(cmd, flags, arg); +} + int main(int argc, char **argv) { diff --git a/recovery_ui.h b/recovery_ui.h index ec88d95..0555122 100644 --- a/recovery_ui.h +++ b/recovery_ui.h @@ -83,7 +83,6 @@ int device_wipe_data(); #define ITEM_NANDROID 4 #define ITEM_PARTITION 5 #define ITEM_ADVANCED 6 -#define ITEM_POWEROFF 7 // Header text to display above the main menu. extern char* MENU_HEADERS[]; @@ -102,4 +101,7 @@ set_sdcard_update_bootloader_message(); extern int ui_handle_key(int key, int visible); +// call a clean reboot +void reboot_main_system(int cmd, int flags, char *arg); + #endif |