void show_reboot_menu() { static char* headers[] = { "Reboot", "", NULL }; static char* list[] = { "Reboot Recovery", "Reboot to Odin Mode", NULL }; for (;;) { int chosen_item = get_menu_selection(headers, list, 0, 0); if (chosen_item == GO_BACK) break; switch (chosen_item) { case 0: { reboot_wrapper("recovery"); break; } case 1: { reboot_wrapper("download"); break; } } } }
int reboot_main(int argc, char *argv[]) { int ret; int nosync = 0; int poweroff = 0; opterr = 0; do { int c; c = getopt(argc, argv, "np"); if (c == EOF) { break; } switch (c) { case 'n': nosync = 1; break; case 'p': poweroff = 1; break; case '?': fprintf(stderr, "usage: %s [-n] [-p] [rebootcommand]\n", argv[0]); exit(EXIT_FAILURE); } } while (1); if(argc > optind + 1) { fprintf(stderr, "%s: too many arguments\n", argv[0]); exit(EXIT_FAILURE); } if(!nosync) sync(); if(poweroff) ret = __reboot(LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, LINUX_REBOOT_CMD_POWER_OFF, NULL); else if(argc > optind) { ret = reboot_wrapper(argv[optind]); } else ret = reboot_wrapper(NULL); if(ret < 0) { perror("reboot"); exit(EXIT_FAILURE); } fprintf(stderr, "reboot returned\n"); return 0; }
/** * prompt_and_wait() * */ static void prompt_and_wait() { int select = 0; for (;;) { int chosen_item = get_menu_selection(main_headers, MENU_ITEMS, 0, select); // device-specific code may take some action here. It may // return one of the core actions handled in the switch // statement below. if (chosen_item >= 0 && chosen_item <= ITEM_LAST) { switch (chosen_item) { case ITEM_REBOOT: sync(); reboot_wrapper(NULL); return; case ITEM_BOOT: if (show_menu_boot()) return; break; #if STOCK_VERSION case ITEM_SYSTEM: if (show_menu_system()) return; break; #elif !defined(NO_OVERCLOCK) case ITEM_OVERCLOCK: if (show_menu_overclock()) return; break; #endif case ITEM_RECOVERY: if (show_menu_recovery()) return; break; case ITEM_TOOLS: if (show_menu_tools()) return; break; case ITEM_POWEROFF: sync(); __reboot(LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, LINUX_REBOOT_CMD_POWER_OFF, NULL); return; } select = chosen_item; } } }
void show_advanced_menu() { static char* headers[] = { "Advanced and Debugging Menu", "", NULL }; static char* list[] = { "Reboot Recovery", "Wipe Dalvik Cache", "Wipe Battery Stats", "Report Error", "Key Test", "Show log", #ifndef BOARD_HAS_SMALL_RECOVERY "Partition SD Card", "Fix Permissions", #ifdef BOARD_HAS_SDCARD_INTERNAL // "Partition Internal SD Card", #endif #endif NULL }; for (;;) { int chosen_item = get_menu_selection(headers, list, 0, 0); if (chosen_item == GO_BACK) break; switch (chosen_item) { case 0: { reboot_wrapper("recovery"); break; } case 1: { if (0 != ensure_path_mounted("/data")) break; ensure_path_mounted("/sd-ext"); ensure_path_mounted("/cache"); if (confirm_selection( "Confirm wipe?", "Yes - Wipe Dalvik Cache")) { __system("rm -r /data/dalvik-cache"); __system("rm -r /cache/dalvik-cache"); __system("rm -r /sd-ext/dalvik-cache"); } ensure_path_unmounted("/data"); ui_print("Dalvik Cache wiped.\n"); break; } case 2: { if (confirm_selection( "Confirm wipe?", "Yes - Wipe Battery Stats")) wipe_battery_stats(); break; } case 3: handle_failure(1); break; case 4: { ui_print("Outputting key codes.\n"); ui_print("Go back to end debugging.\n"); int key; int action; do { key = ui_wait_key(); action = device_handle_key(key, 1); ui_print("Key: %d\n", key); } while (action != GO_BACK); break; } case 5: { ui_printlogtail(12); break; } case 6: { static char* ext_sizes[] = { "128M", "256M", "512M", "1024M", "2048M", "4096M", NULL }; static char* swap_sizes[] = { "0M", "32M", "64M", "128M", "256M", NULL }; static char* ext_headers[] = { "Ext Size", "", NULL }; static char* swap_headers[] = { "Swap Size", "", NULL }; int ext_size = get_menu_selection(ext_headers, ext_sizes, 0, 0); if (ext_size == GO_BACK) continue; int swap_size = get_menu_selection(swap_headers, swap_sizes, 0, 0); if (swap_size == GO_BACK) continue; char sddevice[256]; #ifdef BOARD_HAS_SDCARD_INTERNAL Volume *vol = volume_for_path("/sdcard-ext"); #else Volume *vol = volume_for_path("/sdcard"); #endif strcpy(sddevice, vol->device); // we only want the mmcblk, not the partition sddevice[strlen("/dev/block/mmcblkX")] = NULL; char cmd[PATH_MAX]; setenv("SDPATH", sddevice, 1); sprintf(cmd, "sdparted -es %s -ss %s -efs ext3 -s", ext_sizes[ext_size], swap_sizes[swap_size]); ui_print("Partitioning SD Card... please wait...\n"); if (0 == __system(cmd)) ui_print("Done!\n"); else ui_print("An error occured while partitioning your SD Card. Please see /tmp/recovery.log for more details.\n"); break; } case 7: { ensure_path_mounted("/system"); ensure_path_mounted("/data"); ui_print("Fixing permissions...\n"); __system("fix_permissions"); ui_print("Done!\n"); break; } case 8: { static char* ext_sizes[] = { "128M", "256M", "512M", "1024M", "2048M", "4096M", NULL }; static char* swap_sizes[] = { "0M", "32M", "64M", "128M", "256M", NULL }; static char* ext_headers[] = { "Data Size", "", NULL }; static char* swap_headers[] = { "Swap Size", "", NULL }; int ext_size = get_menu_selection(ext_headers, ext_sizes, 0, 0); if (ext_size == GO_BACK) continue; int swap_size = 0; if (swap_size == GO_BACK) continue; char sddevice[256]; Volume *vol = volume_for_path("/emmc"); strcpy(sddevice, vol->device); // we only want the mmcblk, not the partition sddevice[strlen("/dev/block/mmcblkX")] = NULL; char cmd[PATH_MAX]; setenv("SDPATH", sddevice, 1); sprintf(cmd, "sdparted -es %s -ss %s -efs ext3 -s", ext_sizes[ext_size], swap_sizes[swap_size]); ui_print("Partitioning Internal SD Card... please wait...\n"); if (0 == __system(cmd)) ui_print("Done!\n"); else ui_print("An error occured while partitioning your Internal SD Card. Please see /tmp/recovery.log for more details.\n"); break; } } } }