From 5899ac9ca0eb871887e01644ba5b0d004597a98c Mon Sep 17 00:00:00 2001 From: "Koushik K. Dutta" Date: Fri, 19 Mar 2010 13:34:36 -0700 Subject: [PATCH] the beginnings of adding a format option, --- default_recovery_ui.c | 6 ++-- extendedcommands.c | 77 +++++++++++++++++++++++++++++++++---------- extendedcommands.h | 5 ++- recovery.c | 17 +++------- recovery_ui.h | 5 ++- 5 files changed, 72 insertions(+), 38 deletions(-) diff --git a/default_recovery_ui.c b/default_recovery_ui.c index 0b4bd13..c6955c0 100644 --- a/default_recovery_ui.c +++ b/default_recovery_ui.c @@ -27,9 +27,9 @@ char* MENU_ITEMS[] = { "reboot system now", "wipe data/factory reset", "wipe cache partition", "install zip from sdcard", - "backup", - "restore", - "mount partitions", + "nandroid", + "partitions menu", + "advanced", NULL }; int device_toggle_display(volatile char* key_pressed, int key_code) { diff --git a/extendedcommands.c b/extendedcommands.c index 4ea3787..50f4306 100644 --- a/extendedcommands.c +++ b/extendedcommands.c @@ -373,8 +373,10 @@ void show_mount_usb_storage_menu() __system("echo 0 > /sys/devices/platform/usb_mass_storage/lun0/enable"); } +#define MOUNTABLE_COUNT 4 +#define MTD_COUNT 3 -void show_mount_menu() +void show_partition_menu() { static char* headers[] = { "Mount and unmount partitions", "", @@ -382,47 +384,56 @@ void show_mount_menu() }; typedef char* string; - string mounts[4][3] = { - { "mount /system", "unmount /system", "SYSTEM:" }, - { "mount /data", "unmount /data", "DATA:" }, - { "mount /cache", "unmount /cache", "CACHE:" }, - { "mount /sdcard", "unmount /sdcard", "SDCARD:" } + string mounts[MOUNTABLE_COUNT][4] = { + { "mount /system", "unmount /system", "format SYSTEM:", "SYSTEM:" }, + { "mount /data", "unmount /data", "format DATA:", "DATA:" }, + { "mount /cache", "unmount /cache", "format CACHE:", "CACHE:" }, + { "mount /sdcard", "unmount /sdcard", NULL, "SDCARD:" } }; for (;;) { - int ismounted[4]; + int ismounted[MOUNTABLE_COUNT]; int i; - static string options[6]; - for (i = 0; i < 4; i++) + static string options[MOUNTABLE_COUNT + MTD_COUNT + 1 + 1]; // mountables, format mtds, usb storage, null + for (i = 0; i < MOUNTABLE_COUNT; i++) { - ismounted[i] = is_root_path_mounted(mounts[i][2]); + ismounted[i] = is_root_path_mounted(mounts[i][3]); options[i] = ismounted[i] ? mounts[i][1] : mounts[i][0]; } + + for (i = 0; i < MTD_COUNT; i++) + { + options[MOUNTABLE_COUNT + i] = mounts[i][2]; + } - options[4] = "mount USB storage"; - options[5] = NULL; + options[MOUNTABLE_COUNT + MTD_COUNT] = "mount USB storage"; + options[MOUNTABLE_COUNT + MTD_COUNT + 1] = NULL; int chosen_item = get_menu_selection(headers, options, 0); if (chosen_item == GO_BACK) break; - if (chosen_item == 4) + if (chosen_item == MOUNTABLE_COUNT + MTD_COUNT) { show_mount_usb_storage_menu(); } - else if (chosen_item < 4) + else if (chosen_item < MOUNTABLE_COUNT) { if (ismounted[chosen_item]) { - if (0 != ensure_root_path_unmounted(mounts[chosen_item][2])) - ui_print("Error unmounting %s!\n", mounts[chosen_item][2]); + if (0 != ensure_root_path_unmounted(mounts[chosen_item][3])) + ui_print("Error unmounting %s!\n", mounts[chosen_item][3]); } else { - if (0 != ensure_root_path_mounted(mounts[chosen_item][2])) - ui_print("Error mounting %s!\n", mounts[chosen_item][2]); + if (0 != ensure_root_path_mounted(mounts[chosen_item][3])) + ui_print("Error mounting %s!\n", mounts[chosen_item][3]); } } + else if (chosen_item < MOUNTABLE_COUNT + MTD_COUNT) + { + chosen_item = chosen_item - MOUNTABLE_COUNT; + } } } @@ -515,3 +526,33 @@ int amend_main(int argc, char** argv) } return run_script(argv[1], 0); } + +void show_nandroid_menu() +{ + static char* headers[] = { "Nandroid", + "", + NULL + }; + + static char* list[] = { "Backup", + "Restore", + NULL + }; + + int chosen_item = get_menu_selection(headers, list, 0); + switch (chosen_item) + { + case 0: + { + struct timeval tp; + gettimeofday(&tp, NULL); + char backup_path[PATH_MAX]; + sprintf(backup_path, "/sdcard/clockworkmod/backup/%d", tp.tv_sec); + nandroid_backup(backup_path); + } + break; + case 1: + show_nandroid_restore_menu(); + break; + } +} \ No newline at end of file diff --git a/extendedcommands.h b/extendedcommands.h index d525e65..9de8180 100644 --- a/extendedcommands.h +++ b/extendedcommands.h @@ -20,7 +20,10 @@ void show_nandroid_restore_menu(); void -show_mount_menu(); +show_nandroid_menu(); + +void +show_partition_menu(); void show_choose_zip_menu(); diff --git a/recovery.c b/recovery.c index cbc2914..85c4dc1 100644 --- a/recovery.c +++ b/recovery.c @@ -445,20 +445,11 @@ prompt_and_wait() case ITEM_INSTALL_ZIP: show_install_update_menu(); break; - case ITEM_BACKUP: - { - struct timeval tp; - gettimeofday(&tp, NULL); - char backup_path[PATH_MAX]; - sprintf(backup_path, "/sdcard/clockworkmod/backup/%d", tp.tv_sec); - nandroid_backup(backup_path); - } + case ITEM_NANDROID: + show_nandroid_menu(); break; - case ITEM_RESTORE: - show_nandroid_restore_menu(); - break; - case ITEM_MOUNT: - show_mount_menu(); + case ITEM_PARTITION: + show_partition_menu(); break; /* case ITEM_MOUNT_SDCARD: diff --git a/recovery_ui.h b/recovery_ui.h index bb22445..55fe40f 100644 --- a/recovery_ui.h +++ b/recovery_ui.h @@ -68,9 +68,8 @@ int device_wipe_data(); #define ITEM_WIPE_DATA 2 #define ITEM_WIPE_CACHE 3 #define ITEM_INSTALL_ZIP 4 -#define ITEM_BACKUP 5 -#define ITEM_RESTORE 6 -#define ITEM_MOUNT 7 +#define ITEM_NANDROID 5 +#define ITEM_PARTITION 6 // Header text to display above the main menu. extern char* MENU_HEADERS[];