From d634bb2d2b12add1021053221c39d3847b5aedb5 Mon Sep 17 00:00:00 2001 From: Koushik Dutta Date: Fri, 25 Jun 2010 12:23:35 -0700 Subject: [PATCH 01/13] 2.0.1.4 --- Android.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Android.mk b/Android.mk index 5879670..dad65c3 100644 --- a/Android.mk +++ b/Android.mk @@ -26,7 +26,7 @@ LOCAL_MODULE := recovery LOCAL_FORCE_STATIC_EXECUTABLE := true -RECOVERY_VERSION := ClockworkMod Recovery v2.0.1.3 +RECOVERY_VERSION := ClockworkMod Recovery v2.0.1.4 LOCAL_CFLAGS := -DRECOVERY_VERSION="$(RECOVERY_VERSION)" RECOVERY_API_VERSION := 2 LOCAL_CFLAGS += -DRECOVERY_API_VERSION=$(RECOVERY_API_VERSION) From 0837091e8de5a08383499b5fa2e85aaee22f1fff Mon Sep 17 00:00:00 2001 From: Koushik Dutta Date: Sat, 26 Jun 2010 12:25:02 -0700 Subject: [PATCH 02/13] command line nandroid --- Android.mk | 4 ++-- commands.c | 13 +------------ nandroid.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ nandroid.h | 1 + recovery.c | 2 ++ ui.c | 5 +++++ 6 files changed, 59 insertions(+), 14 deletions(-) diff --git a/Android.mk b/Android.mk index dad65c3..e625daf 100644 --- a/Android.mk +++ b/Android.mk @@ -26,7 +26,7 @@ LOCAL_MODULE := recovery LOCAL_FORCE_STATIC_EXECUTABLE := true -RECOVERY_VERSION := ClockworkMod Recovery v2.0.1.4 +RECOVERY_VERSION := ClockworkMod Recovery v2.0.1.7 LOCAL_CFLAGS := -DRECOVERY_VERSION="$(RECOVERY_VERSION)" RECOVERY_API_VERSION := 2 LOCAL_CFLAGS += -DRECOVERY_API_VERSION=$(RECOVERY_API_VERSION) @@ -92,7 +92,7 @@ LOCAL_STATIC_LIBRARIES += libstdc++ libc include $(BUILD_EXECUTABLE) -RECOVERY_LINKS := amend busybox flash_image dump_image mkyaffs2image unyaffs erase_image +RECOVERY_LINKS := amend busybox flash_image dump_image mkyaffs2image unyaffs erase_image nandroid # nc is provided by external/netcat SYMLINKS := $(addprefix $(TARGET_RECOVERY_ROOT_OUT)/sbin/,$(RECOVERY_LINKS)) $(SYMLINKS): RECOVERY_BINARY := $(LOCAL_MODULE) diff --git a/commands.c b/commands.c index 242fd2d..40c4461 100644 --- a/commands.c +++ b/commands.c @@ -782,18 +782,7 @@ cmd_backup_rom(const char *name, void *cookie, int argc, const char *argv[], case 0: { char backup_path[PATH_MAX]; - time_t t = time(NULL); - struct tm *tmp = localtime(&t); - if (tmp == NULL) - { - struct timeval tp; - gettimeofday(&tp, NULL); - sprintf(backup_path, "/sdcard/clockworkmod/backup/%d", tp.tv_sec); - } - else - { - strftime(backup_path, sizeof(backup_path), "/sdcard/clockworkmod/backup/%F.%H.%M.%S", tmp); - } + nandroid_generate_timestamp_path(backup_path); backup_name = backup_path; } break; diff --git a/nandroid.c b/nandroid.c index c38c39d..763ce5b 100644 --- a/nandroid.c +++ b/nandroid.c @@ -282,3 +282,51 @@ int nandroid_restore(const char* backup_path, int restore_boot, int restore_syst ui_print("\nRestore complete!\n"); return 0; } + +void nandroid_generate_timestamp_path(char* backup_path) +{ + time_t t = time(NULL); + struct tm *tmp = localtime(&t); + if (tmp == NULL) + { + struct timeval tp; + gettimeofday(&tp, NULL); + sprintf(backup_path, "/sdcard/clockworkmod/backup/%d", tp.tv_sec); + } + else + { + strftime(backup_path, PATH_MAX, "/sdcard/clockworkmod/backup/%F.%H.%M.%S", tmp); + } +} + +int nandroid_usage() +{ + printf("Usage: nandroid backup\n"); + printf("Usage: nandroid restore \n"); + return 1; +} + +int nandroid_main(int argc, char** argv) +{ + if (argc > 3 || argc < 2) + return nandroid_usage(); + + if (strcmp("backup", argv[1]) == 0) + { + if (argc != 2) + return nandroid_usage(); + + char backup_path[PATH_MAX]; + nandroid_generate_timestamp_path(backup_path); + return nandroid_backup(backup_path); + } + + if (strcmp("restore", argv[1]) == 0) + { + if (argc != 3) + return nandroid_usage(); + return nandroid_restore(argv[2], 1, 1, 1, 1, 1); + } + + return nandroid_usage(); +} diff --git a/nandroid.h b/nandroid.h index 30fee01..f124e11 100644 --- a/nandroid.h +++ b/nandroid.h @@ -4,5 +4,6 @@ int nandroid_main(int argc, char** argv); int nandroid_backup(const char* backup_path); int nandroid_restore(const char* backup_path, int restore_boot, int restore_system, int restore_data, int restore_cache, int restore_sdext); +void nandroid_generate_timestamp_path(char* backup_path); #endif \ No newline at end of file diff --git a/recovery.c b/recovery.c index 61f938d..25dd69e 100644 --- a/recovery.c +++ b/recovery.c @@ -492,6 +492,8 @@ main(int argc, char **argv) return unyaffs_main(argc, argv); if (strstr(argv[0], "amend")) return amend_main(argc, argv); + if (strstr(argv[0], "nandroid")) + return nandroid_main(argc, argv); return busybox_driver(argc, argv); } LOGI(EXPAND(RECOVERY_VERSION)"\n"); diff --git a/ui.c b/ui.c index 651eea1..2e0ff83 100644 --- a/ui.c +++ b/ui.c @@ -48,6 +48,7 @@ static gr_surface gBackgroundIcon[NUM_BACKGROUND_ICONS]; static gr_surface gProgressBarIndeterminate[PROGRESSBAR_INDETERMINATE_STATES]; static gr_surface gProgressBarEmpty[NUM_SIDES]; static gr_surface gProgressBarFill[NUM_SIDES]; +static int ui_has_initialized = 0; static const struct { gr_surface* surface; const char *name; } BITMAPS[] = { { &gBackgroundIcon[BACKGROUND_ICON_INSTALLING], "icon_installing" }, @@ -176,6 +177,7 @@ static void draw_text_line(int row, const char* t) { // Should only be called with gUpdateMutex locked. static void draw_screen_locked(void) { + if (!ui_has_initialized) return; draw_background_locked(gCurrentIcon); draw_progress_locked(); @@ -229,6 +231,7 @@ static void draw_screen_locked(void) // Should only be called with gUpdateMutex locked. static void update_screen_locked(void) { + if (!ui_has_initialized) return; draw_screen_locked(); gr_flip(); } @@ -237,6 +240,7 @@ static void update_screen_locked(void) // Should only be called with gUpdateMutex locked. static void update_progress_locked(void) { + if (!ui_has_initialized) return; if (show_text || !gPagesIdentical) { draw_screen_locked(); // Must redraw the whole screen gPagesIdentical = 1; @@ -346,6 +350,7 @@ static void *input_thread(void *cookie) void ui_init(void) { + ui_has_initialized = 1; gr_init(); ev_init(); From 1e8aabad3408e339a6f0dc4ef907db519c902a4c Mon Sep 17 00:00:00 2001 From: Koushik Dutta Date: Thu, 1 Jul 2010 00:23:25 -0700 Subject: [PATCH 03/13] alphabetical sort Change-Id: I4b1bb6787a5cbe1e99e3d8b0cc5bf37d7167398d --- extendedcommands.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/extendedcommands.c b/extendedcommands.c index 29adf56..c79836e 100644 --- a/extendedcommands.c +++ b/extendedcommands.c @@ -214,6 +214,21 @@ char** gather_files(const char* directory, const char* fileExtensionOrDirectory, return NULL; } + // sort the result + if (files != NULL) { + for (i = 0; i < total; i++) { + int curMax = -1; + int j; + for (j = 0; j < total - i; j++) { + if (curMax == -1 || strcmp(files[curMax], files[j]) < 0) + curMax = j; + } + char* temp = files[curMax]; + files[curMax] = files[total - i - 1]; + files[total - i - 1] = temp; + } + } + return files; } From b9c595c6544d3e52570fc98dd8039abaca79aa40 Mon Sep 17 00:00:00 2001 From: Koushik Dutta Date: Thu, 1 Jul 2010 12:39:15 -0700 Subject: [PATCH 04/13] change where the recovery version is spit --- recovery.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/recovery.c b/recovery.c index 25dd69e..c0caa66 100644 --- a/recovery.c +++ b/recovery.c @@ -404,7 +404,6 @@ static void prompt_and_wait() { char** headers = prepend_title(MENU_HEADERS); - ui_print(EXPAND(RECOVERY_VERSION)"\n"); for (;;) { finish_recovery(NULL); @@ -496,7 +495,7 @@ main(int argc, char **argv) return nandroid_main(argc, argv); return busybox_driver(argc, argv); } - LOGI(EXPAND(RECOVERY_VERSION)"\n"); + ui_print(EXPAND(RECOVERY_VERSION)"\n"); create_fstab(); __system("/sbin/postrecoveryboot.sh"); From 6440ed585f62ada039ebd9aa3eb934d3826a6357 Mon Sep 17 00:00:00 2001 From: Koushik Dutta Date: Thu, 1 Jul 2010 12:52:34 -0700 Subject: [PATCH 05/13] fail --- Android.mk | 2 +- recovery.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Android.mk b/Android.mk index e625daf..a951957 100644 --- a/Android.mk +++ b/Android.mk @@ -26,7 +26,7 @@ LOCAL_MODULE := recovery LOCAL_FORCE_STATIC_EXECUTABLE := true -RECOVERY_VERSION := ClockworkMod Recovery v2.0.1.7 +RECOVERY_VERSION := ClockworkMod Recovery v2.0.1.9 LOCAL_CFLAGS := -DRECOVERY_VERSION="$(RECOVERY_VERSION)" RECOVERY_API_VERSION := 2 LOCAL_CFLAGS += -DRECOVERY_API_VERSION=$(RECOVERY_API_VERSION) diff --git a/recovery.c b/recovery.c index c0caa66..d169cdb 100644 --- a/recovery.c +++ b/recovery.c @@ -495,7 +495,6 @@ main(int argc, char **argv) return nandroid_main(argc, argv); return busybox_driver(argc, argv); } - ui_print(EXPAND(RECOVERY_VERSION)"\n"); create_fstab(); __system("/sbin/postrecoveryboot.sh"); @@ -508,6 +507,7 @@ main(int argc, char **argv) fprintf(stderr, "Starting recovery on %s", ctime(&start)); ui_init(); + ui_print(EXPAND(RECOVERY_VERSION)"\n"); get_args(&argc, &argv); int previous_runs = 0; From 062d6b0bb38801393a94111b392640e16f73c69b Mon Sep 17 00:00:00 2001 From: Koushik Dutta Date: Sat, 3 Jul 2010 13:54:21 -0700 Subject: [PATCH 06/13] Backup of Froyo apps on external storage. --- extendedcommands.c | 1 - nandroid.c | 53 +++++++++++++++++++++++++++++++++++++++------- recovery.c | 1 + roots.c | 2 ++ 4 files changed, 48 insertions(+), 9 deletions(-) diff --git a/extendedcommands.c b/extendedcommands.c index c79836e..9310d21 100644 --- a/extendedcommands.c +++ b/extendedcommands.c @@ -448,7 +448,6 @@ int format_non_mtd_device(const char* root) ui_print("Error mounting %s!\n", path); ui_print("Skipping format...\n"); return 0; - } static char tmp[PATH_MAX]; diff --git a/nandroid.c b/nandroid.c index 763ce5b..00afbd9 100644 --- a/nandroid.c +++ b/nandroid.c @@ -75,7 +75,7 @@ void compute_directory_stats(char* directory) ui_show_progress(1, 0); } -int nandroid_backup_partition(const char* backup_path, char* root) { +int nandroid_backup_partition_extended(const char* backup_path, char* root, int umount_when_finished) { int ret = 0; char mount_point[PATH_MAX]; translate_root_path(root, mount_point, PATH_MAX); @@ -96,7 +96,9 @@ int nandroid_backup_partition(const char* backup_path, char* root) { char tmp[PATH_MAX]; sprintf(tmp, "%s/%s.img", backup_path, name); ret = mkyaffs2image(mount_point, tmp, 0, callback); - ensure_root_path_unmounted(root); + if (umount_when_finished) { + ensure_root_path_unmounted(root); + } if (0 != ret) { ui_print("Error while making a yaffs2 image of %s!\n", mount_point); return ret; @@ -104,6 +106,10 @@ int nandroid_backup_partition(const char* backup_path, char* root) { return 0; } +int nandroid_backup_partition(const char* backup_path, char* root) { + return nandroid_backup_partition_extended(backup_path, root, 1); +} + int nandroid_backup(const char* backup_path) { ui_set_background(BACKGROUND_ICON_INSTALLING); @@ -150,10 +156,20 @@ int nandroid_backup(const char* backup_path) return ret; #endif - if (0 != (ret = nandroid_backup_partition(backup_path, "CACHE:"))) + struct stat st; + if (0 != stat("/sdcard/.android_secure", &st)) + { + ui_print("No /sdcard/.android_secure found. Skipping backup of applications on external storage.\n"); + } + else + { + if (0 != (ret = nandroid_backup_partition_extended(backup_path, "SDCARD:/.android_secure", 0))) + return ret; + } + + if (0 != (ret = nandroid_backup_partition_extended(backup_path, "CACHE:", 0))) return ret; - struct stat st; if (0 != stat(SDEXT_DEVICE, &st)) { ui_print("No sd-ext found. Skipping backup of sd-ext.\n"); @@ -165,7 +181,7 @@ int nandroid_backup(const char* backup_path) else if (0 != (ret = nandroid_backup_partition(backup_path, "SDEXT:"))) return ret; } - + ui_print("Generating md5 sum...\n"); sprintf(tmp, "nandroid-md5.sh %s", backup_path); if (0 != (ret = __system(tmp))) { @@ -182,7 +198,7 @@ int nandroid_backup(const char* backup_path) typedef int (*format_function)(char* root); -int nandroid_restore_partition(const char* backup_path, const char* root) { +int nandroid_restore_partition_extended(const char* backup_path, const char* root, int umount_when_finished) { int ret = 0; char mount_point[PATH_MAX]; translate_root_path(root, mount_point, PATH_MAX); @@ -216,12 +232,17 @@ int nandroid_restore_partition(const char* backup_path, const char* root) { return ret; } - if (0 != strcmp(root, "CACHE")) { + if (umount_when_finished) { ensure_root_path_unmounted(root); } + return 0; } +int nandroid_restore_partition(const char* backup_path, const char* root) { + return nandroid_restore_partition_extended(backup_path, root, 1); +} + int nandroid_restore(const char* backup_path, int restore_boot, int restore_system, int restore_data, int restore_cache, int restore_sdext) { ui_set_background(BACKGROUND_ICON_INSTALLING); @@ -263,7 +284,23 @@ int nandroid_restore(const char* backup_path, int restore_boot, int restore_syst return ret; #endif - if (restore_cache && 0 != (ret = nandroid_restore_partition(backup_path, "CACHE:"))) + if (restore_data) + { + struct statfs s; + sprintf(tmp, "%s/.android_secure.img", backup_path); + if (0 != (ret = statfs(tmp, &s))) + { + ui_print(".android_secure.img not found. Skipping restore of applications on external storage."); + } + else + { + __system("mkdir -p /sdcard/.android_secure"); + if (0 != (ret = nandroid_restore_partition_extended(backup_path, "SDCARD:/.android_secure", 0))) + return ret; + } + } + + if (restore_cache && 0 != (ret = nandroid_restore_partition_extended(backup_path, "CACHE:", 0))) return ret; if (restore_sdext) diff --git a/recovery.c b/recovery.c index d169cdb..344ed46 100644 --- a/recovery.c +++ b/recovery.c @@ -397,6 +397,7 @@ wipe_data(int confirm) { #endif erase_root("CACHE:"); erase_root("SDEXT:"); + erase_root("SDCARD:/.android_secure"); ui_print("Data wipe complete.\n"); } diff --git a/roots.c b/roots.c index 535a1a7..d54de2d 100644 --- a/roots.c +++ b/roots.c @@ -314,10 +314,12 @@ format_root_device(const char *root) while (*c != '\0' && *c != ':') { c++; } + /* if (c[0] != ':' || c[1] != '\0') { LOGW("format_root_device: bad root name \"%s\"\n", root); return -1; } + */ const RootInfo *info = get_root_info_for_path(root); if (info == NULL || info->device == NULL) { From d8038e15f8ec20009f5631ee1f3d0a8427cdb7a5 Mon Sep 17 00:00:00 2001 From: Koushik Dutta Date: Sat, 3 Jul 2010 16:38:34 -0700 Subject: [PATCH 07/13] 2.0.2.0 --- Android.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Android.mk b/Android.mk index a951957..7c5f5f5 100644 --- a/Android.mk +++ b/Android.mk @@ -26,7 +26,7 @@ LOCAL_MODULE := recovery LOCAL_FORCE_STATIC_EXECUTABLE := true -RECOVERY_VERSION := ClockworkMod Recovery v2.0.1.9 +RECOVERY_VERSION := ClockworkMod Recovery v2.0.2.0 LOCAL_CFLAGS := -DRECOVERY_VERSION="$(RECOVERY_VERSION)" RECOVERY_API_VERSION := 2 LOCAL_CFLAGS += -DRECOVERY_API_VERSION=$(RECOVERY_API_VERSION) From 37186b19bce9994907a276f057468dfc28a98b00 Mon Sep 17 00:00:00 2001 From: Koushik Dutta Date: Wed, 7 Jul 2010 19:10:09 -0700 Subject: [PATCH 08/13] up the version --- Android.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Android.mk b/Android.mk index 7c5f5f5..55f7de7 100644 --- a/Android.mk +++ b/Android.mk @@ -26,7 +26,7 @@ LOCAL_MODULE := recovery LOCAL_FORCE_STATIC_EXECUTABLE := true -RECOVERY_VERSION := ClockworkMod Recovery v2.0.2.0 +RECOVERY_VERSION := ClockworkMod Recovery v2.0.2.2 LOCAL_CFLAGS := -DRECOVERY_VERSION="$(RECOVERY_VERSION)" RECOVERY_API_VERSION := 2 LOCAL_CFLAGS += -DRECOVERY_API_VERSION=$(RECOVERY_API_VERSION) From 1bf4f695d4784f304d6cac5a1addec31c2f3fdb9 Mon Sep 17 00:00:00 2001 From: Koushik Dutta Date: Wed, 14 Jul 2010 18:37:33 -0700 Subject: [PATCH 09/13] allow toggling of software back menu item. add recovery checkpoint file. mount auto now uses busybox mount. --- Android.mk | 2 +- common.h | 3 +++ default_recovery_ui.c | 18 +++++++++--------- extendedcommands.c | 1 + recovery.c | 30 ++++++++++++++++++++++++++---- roots.c | 17 +++++++++++++++-- roots.h | 2 +- ui.c | 30 ++++++++++++++++++++++-------- 8 files changed, 78 insertions(+), 25 deletions(-) diff --git a/Android.mk b/Android.mk index 55f7de7..9ecc2de 100644 --- a/Android.mk +++ b/Android.mk @@ -26,7 +26,7 @@ LOCAL_MODULE := recovery LOCAL_FORCE_STATIC_EXECUTABLE := true -RECOVERY_VERSION := ClockworkMod Recovery v2.0.2.2 +RECOVERY_VERSION := ClockworkMod Recovery v2.0.2.4 LOCAL_CFLAGS := -DRECOVERY_VERSION="$(RECOVERY_VERSION)" RECOVERY_API_VERSION := 2 LOCAL_CFLAGS += -DRECOVERY_API_VERSION=$(RECOVERY_API_VERSION) diff --git a/common.h b/common.h index 81d9029..6c60d07 100644 --- a/common.h +++ b/common.h @@ -47,6 +47,9 @@ int ui_menu_select(int sel); // statements will be displayed. void ui_end_menu(); +int ui_get_showing_back_button(); +void ui_set_showing_back_button(int showBackButton); + // Set the icon (normally the only thing visible besides the progress bar). enum { BACKGROUND_ICON_NONE, diff --git a/default_recovery_ui.c b/default_recovery_ui.c index f189da4..8ee1239 100644 --- a/default_recovery_ui.c +++ b/default_recovery_ui.c @@ -37,11 +37,10 @@ int device_toggle_display(volatile char* key_pressed, int key_code) { if (alt && key_code == KEY_L) return 1; // allow toggling of the display if the correct key is pressed, and the display toggle is allowed or the display is currently off -#ifdef KEY_POWER_IS_SELECT_ITEM - return get_allow_toggle_display() && (key_code == KEY_HOME || key_code == KEY_MENU || key_code == KEY_END); -#else + if (ui_get_showing_back_button()) { + return get_allow_toggle_display() && (key_code == KEY_HOME || key_code == KEY_MENU || key_code == KEY_END); + } return get_allow_toggle_display() && (key_code == KEY_HOME || key_code == KEY_MENU || key_code == KEY_POWER || key_code == KEY_END); -#endif } int device_reboot_now(volatile char* key_pressed, int key_code) { @@ -59,9 +58,13 @@ int device_handle_key(int key_code, int visible) { case KEY_VOLUMEUP: return HIGHLIGHT_UP; -#ifdef KEY_POWER_IS_SELECT_ITEM case KEY_POWER: -#endif + if (ui_get_showing_back_button()) { + return SELECT_ITEM; + } + if (!get_allow_toggle_display()) + return GO_BACK; + break; case KEY_ENTER: case BTN_MOUSE: case KEY_CENTER: @@ -70,9 +73,6 @@ int device_handle_key(int key_code, int visible) { case KEY_SEND: return SELECT_ITEM; -#ifndef KEY_POWER_IS_SELECT_ITEM - case KEY_POWER: -#endif case KEY_END: case KEY_BACKSPACE: case KEY_BACK: diff --git a/extendedcommands.c b/extendedcommands.c index 9310d21..baa72c5 100644 --- a/extendedcommands.c +++ b/extendedcommands.c @@ -627,6 +627,7 @@ int run_and_remove_extendedcommand() char tmp[PATH_MAX]; sprintf(tmp, "cp %s /tmp/%s", EXTENDEDCOMMAND_SCRIPT, basename(EXTENDEDCOMMAND_SCRIPT)); __system(tmp); + __system("rm /sdcard/clockworkmod/.recoverycheckpoint"); remove(EXTENDEDCOMMAND_SCRIPT); int i = 0; for (i = 20; i > 0; i--) { diff --git a/recovery.c b/recovery.c index 344ed46..34e02ab 100644 --- a/recovery.c +++ b/recovery.c @@ -317,12 +317,19 @@ get_menu_selection(char** headers, char** items, int menu_only) { int selected = 0; int chosen_item = -1; + // Some users with dead enter keys need a way to turn on power to select. + // Jiggering across the wrapping menu is one "secret" way to enable it. + // We can't rely on /cache or /sdcard since they may not be available. + int wrap_count = 0; + while (chosen_item < 0 && chosen_item != GO_BACK) { int key = ui_wait_key(); int visible = ui_text_visible(); int action = device_handle_key(key, visible); + int old_selected = selected; + if (action < 0) { switch (action) { case HIGHLIGHT_UP: @@ -335,11 +342,11 @@ get_menu_selection(char** headers, char** items, int menu_only) { break; case SELECT_ITEM: chosen_item = selected; -#ifdef KEY_POWER_IS_SELECT_ITEM - if (chosen_item == item_count) { - chosen_item = GO_BACK; + if (ui_get_showing_back_button()) { + if (chosen_item == item_count) { + chosen_item = GO_BACK; + } } -#endif break; case NO_ACTION: break; @@ -350,6 +357,21 @@ get_menu_selection(char** headers, char** items, int menu_only) { } else if (!menu_only) { chosen_item = action; } + + if (abs(selected - old_selected) > 1) { + wrap_count++; + if (wrap_count == 3) { + wrap_count = 0; + if (ui_get_showing_back_button()) { + ui_print("Back button disabled.\n"); + ui_set_showing_back_button(0); + } + else { + ui_print("Back button enabled.\n"); + ui_set_showing_back_button(1); + } + } + } } ui_end_menu(); diff --git a/roots.c b/roots.c index d54de2d..da10ee7 100644 --- a/roots.c +++ b/roots.c @@ -21,6 +21,8 @@ #include #include +#include + #include "mtdutils/mtdutils.h" #include "mtdutils/mounts.h" #include "minzip/Zip.h" @@ -205,6 +207,18 @@ is_root_path_mounted(const char *root_path) return internal_root_mounted(info) >= 0; } +static int mount_internal(const char* device, const char* mount_point, const char* filesystem) +{ + if (strcmp(filesystem, "auto") != 0) { + return mount(device, mount_point, filesystem, MS_NOATIME | MS_NODEV | MS_NODIRATIME, ""); + } + else { + char mount_cmd[PATH_MAX]; + sprintf(mount_cmd, "mount -onoatime,nodiratime,nodev %s %s", device, mount_point); + return __system(mount_cmd); + } +} + int ensure_root_path_mounted(const char *root_path) { @@ -245,8 +259,7 @@ ensure_root_path_mounted(const char *root_path) } mkdir(info->mount_point, 0755); // in case it doesn't already exist - if (mount(info->device, info->mount_point, info->filesystem, - MS_NOATIME | MS_NODEV | MS_NODIRATIME, "")) { + if (mount_internal(info->device, info->mount_point, info->filesystem)) { if (info->device2 == NULL) { LOGE("Can't mount %s\n(%s)\n", info->device, strerror(errno)); return -1; diff --git a/roots.h b/roots.h index 40aef87..e777093 100644 --- a/roots.h +++ b/roots.h @@ -33,7 +33,7 @@ #endif #ifndef SDEXT_FILESYSTEM -#define SDEXT_FILESYSTEM "ext4" +#define SDEXT_FILESYSTEM "auto" #endif #ifndef DATA_DEVICE diff --git a/ui.c b/ui.c index 2e0ff83..fe56c5d 100644 --- a/ui.c +++ b/ui.c @@ -29,6 +29,12 @@ #include "minui/minui.h" #include "recovery_ui.h" +#ifdef KEY_POWER_IS_SELECT_ITEM +static int gShowBackButton = 1; +#else +static int gShowBackButton = 0; +#endif + #define MAX_COLS 64 #define MAX_ROWS 32 @@ -511,10 +517,11 @@ int ui_start_menu(char** headers, char** items) { strncpy(menu[i] + MENU_ITEM_HEADER_LENGTH, items[i-menu_top], text_cols-1 - MENU_ITEM_HEADER_LENGTH); menu[i][text_cols-1] = '\0'; } -#ifdef KEY_POWER_IS_SELECT_ITEM - strcpy(menu[i], " - +++++Go Back+++++"); - ++i; -#endif + + if (gShowBackButton) { + strcpy(menu[i], " - +++++Go Back+++++"); + ++i; + } menu_items = i - menu_top; show_menu = 1; @@ -522,11 +529,10 @@ int ui_start_menu(char** headers, char** items) { update_screen_locked(); } pthread_mutex_unlock(&gUpdateMutex); -#ifdef KEY_POWER_IS_SELECT_ITEM - return menu_items - 1; -#else + if (gShowBackButton) { + return menu_items - 1; + } return menu_items; -#endif } int ui_menu_select(int sel) { @@ -602,3 +608,11 @@ void ui_clear_key_queue() { void ui_set_show_text(int value) { show_text = value; } + +void ui_set_showing_back_button(int showBackButton) { + gShowBackButton = showBackButton; +} + +int ui_get_showing_back_button() { + return gShowBackButton; +} \ No newline at end of file From ecd32fa2e84d917daca9cbad60b7406b977894e8 Mon Sep 17 00:00:00 2001 From: Koushik Dutta Date: Wed, 14 Jul 2010 18:38:02 -0700 Subject: [PATCH 10/13] Make generic confirmation function. --- extendedcommands.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/extendedcommands.c b/extendedcommands.c index baa72c5..aa9cbc6 100644 --- a/extendedcommands.c +++ b/extendedcommands.c @@ -403,14 +403,8 @@ void show_mount_usb_storage_menu() __system("echo 0 > /sys/devices/platform/usb_mass_storage/lun0/enable"); } -int confirm_format() +int confirm_selection(char* title_headers[], char* confirm) { - static char* title_headers[] = { "Confirm format?", - " THIS CAN NOT BE UNDONE.", - "", - NULL, - }; - char* items[] = { " No", " No", " No", @@ -418,7 +412,7 @@ int confirm_format() " No", " No", " No", - " Yes -- wipe partition", // [7] + confirm, //" Yes -- wipe partition", // [7 " No", " No", " No", @@ -491,6 +485,13 @@ void show_partition_menu() { "format sdcard", "SDCARD:" }, { "format sd-ext", "SDEXT:" } }; + + static char* confirm_format[] = { "Confirm format?", + " THIS CAN NOT BE UNDONE.", + "", + NULL, + }; + static char* confirm = "Yes - Format"; for (;;) { @@ -539,7 +540,7 @@ void show_partition_menu() else if (chosen_item < MOUNTABLE_COUNT + MTD_COUNT) { chosen_item = chosen_item - MOUNTABLE_COUNT; - if (!confirm_format()) + if (!confirm_selection(confirm_format, confirm)) continue; ui_print("Formatting %s...\n", mtds[chosen_item][1]); if (0 != format_root_device(mtds[chosen_item][1])) @@ -550,7 +551,7 @@ void show_partition_menu() else if (chosen_item < MOUNTABLE_COUNT + MTD_COUNT + MMC_COUNT) { chosen_item = chosen_item - MOUNTABLE_COUNT - MTD_COUNT; - if (!confirm_format()) + if (!confirm_selection(confirm_format, confirm)) continue; ui_print("Formatting %s...\n", mmcs[chosen_item][1]); if (0 != format_non_mtd_device(mmcs[chosen_item][1])) From d63eaef1794614d506416aafd8b99fdf81fdfc35 Mon Sep 17 00:00:00 2001 From: Koushik Dutta Date: Wed, 14 Jul 2010 21:01:21 -0700 Subject: [PATCH 11/13] add confirmations to anything that would change the system. --- extendedcommands.c | 74 +++++++++++++++++++++++++++++----------------- recovery.c | 44 +++++++++++++++------------ 2 files changed, 72 insertions(+), 46 deletions(-) diff --git a/extendedcommands.c b/extendedcommands.c index aa9cbc6..f09f24e 100644 --- a/extendedcommands.c +++ b/extendedcommands.c @@ -105,8 +105,11 @@ void show_install_update_menu() toggle_signature_check(); break; case ITEM_APPLY_SDCARD: - install_zip(SDCARD_PACKAGE_FILE); + { + if (confirm_selection("Confirm install?", "Yes - Install /sdcard/update.zip")) + install_zip(SDCARD_PACKAGE_FILE); break; + } case ITEM_CHOOSE_ZIP: show_choose_zip_menu(); break; @@ -316,7 +319,11 @@ void show_choose_zip_menu() char sdcard_package_file[1024]; strcpy(sdcard_package_file, "SDCARD:"); strcat(sdcard_package_file, file + strlen("/sdcard/")); - install_zip(sdcard_package_file); + static char* confirm_install = "Confirm install?"; + static char confirm[PATH_MAX]; + sprintf(confirm, "Yes - Install %s", basename(file)); + if (confirm_selection(confirm_install, confirm)) + install_zip(sdcard_package_file); } // This was pulled from bionic: The default system command always looks @@ -375,7 +382,9 @@ void show_nandroid_restore_menu() char* file = choose_file_menu("/sdcard/clockworkmod/backup/", NULL, headers); if (file == NULL) return; - nandroid_restore(file, 1, 1, 1, 1, 1); + + if (confirm_selection("Confirm restore?", "Yes - Restore")) + nandroid_restore(file, 1, 1, 1, 1, 1); } void show_mount_usb_storage_menu() @@ -403,22 +412,23 @@ void show_mount_usb_storage_menu() __system("echo 0 > /sys/devices/platform/usb_mass_storage/lun0/enable"); } -int confirm_selection(char* title_headers[], char* confirm) +int confirm_selection(const char* title, const char* confirm) { - char* items[] = { " No", - " No", - " No", - " No", - " No", - " No", - " No", + char* confirm_headers[] = { title, " THIS CAN NOT BE UNDONE.", "", NULL }; + char* items[] = { "No", + "No", + "No", + "No", + "No", + "No", + "No", confirm, //" Yes -- wipe partition", // [7 - " No", - " No", - " No", + "No", + "No", + "No", NULL }; - int chosen_item = get_menu_selection(title_headers, items, 0); + int chosen_item = get_menu_selection(confirm_headers, items, 0); return chosen_item == 7; } @@ -486,11 +496,7 @@ void show_partition_menu() { "format sd-ext", "SDEXT:" } }; - static char* confirm_format[] = { "Confirm format?", - " THIS CAN NOT BE UNDONE.", - "", - NULL, - }; + static char* confirm_format = "Confirm format?"; static char* confirm = "Yes - Format"; for (;;) @@ -695,23 +701,31 @@ void show_nandroid_advanced_restore_menu() NULL }; + + static char* confirm_restore = "Confirm restore?"; + int chosen_item = get_menu_selection(headers, list, 0); switch (chosen_item) { case 0: - nandroid_restore(file, 1, 0, 0, 0, 0); + if (confirm_selection(confirm_restore, "Yes - Restore boot")) + nandroid_restore(file, 1, 0, 0, 0, 0); break; case 1: - nandroid_restore(file, 0, 1, 0, 0, 0); + if (confirm_selection(confirm_restore, "Yes - Restore system")) + nandroid_restore(file, 0, 1, 0, 0, 0); break; case 2: - nandroid_restore(file, 0, 0, 1, 0, 0); + if (confirm_selection(confirm_restore, "Yes - Restore data")) + nandroid_restore(file, 0, 0, 1, 0, 0); break; case 3: - nandroid_restore(file, 0, 0, 0, 1, 0); + if (confirm_selection(confirm_restore, "Yes - Restore cache")) + nandroid_restore(file, 0, 0, 0, 1, 0); break; case 4: - nandroid_restore(file, 0, 0, 0, 0, 1); + if (confirm_selection(confirm_restore, "Yes - Restore sd-ext")) + nandroid_restore(file, 0, 0, 0, 0, 1); break; } } @@ -792,14 +806,20 @@ void show_advanced_menu() __reboot(LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, LINUX_REBOOT_CMD_RESTART2, "recovery"); break; case 1: + { if (0 != ensure_root_path_mounted("DATA:")) break; - __system("rm -r /data/dalvik-cache"); + if (confirm_selection( "Confirm wipe?", "Yes - Wipe Dalvik Cache")) + __system("rm -r /data/dalvik-cache"); ensure_root_path_unmounted("DATA:"); break; + } case 2: - wipe_battery_stats(); + { + if (confirm_selection( "Confirm wipe?", "Yes - Wipe Battery Stats")) + wipe_battery_stats(); break; + } case 3: handle_failure(1); break; diff --git a/recovery.c b/recovery.c index 34e02ab..b0123db 100644 --- a/recovery.c +++ b/recovery.c @@ -363,11 +363,11 @@ get_menu_selection(char** headers, char** items, int menu_only) { if (wrap_count == 3) { wrap_count = 0; if (ui_get_showing_back_button()) { - ui_print("Back button disabled.\n"); + ui_print("Back menu button disabled.\n"); ui_set_showing_back_button(0); } else { - ui_print("Back button enabled.\n"); + ui_print("Back menu button enabled.\n"); ui_set_showing_back_button(1); } } @@ -451,27 +451,33 @@ prompt_and_wait() break; case ITEM_WIPE_CACHE: - ui_print("\n-- Wiping cache...\n"); - erase_root("CACHE:"); - ui_print("Cache wipe complete.\n"); - if (!ui_text_visible()) return; + if (confirm_selection("Confirm wipe?", "Yes - Wipe Cache")) + { + ui_print("\n-- Wiping cache...\n"); + erase_root("CACHE:"); + ui_print("Cache wipe complete.\n"); + if (!ui_text_visible()) return; + } break; case ITEM_APPLY_SDCARD: - ui_print("\n-- Install from sdcard...\n"); - set_sdcard_update_bootloader_message(); - int status = install_package(SDCARD_PACKAGE_FILE); - if (status != INSTALL_SUCCESS) { - ui_set_background(BACKGROUND_ICON_ERROR); - ui_print("Installation aborted.\n"); - } else if (!ui_text_visible()) { - return; // reboot if logs aren't visible - } else { - if (firmware_update_pending()) { - ui_print("\nReboot via menu to complete\n" - "installation.\n"); + if (confirm_selection("Confirm install?", "Yes - Install /sdcard/update.zip")) + { + ui_print("\n-- Install from sdcard...\n"); + set_sdcard_update_bootloader_message(); + int status = install_package(SDCARD_PACKAGE_FILE); + if (status != INSTALL_SUCCESS) { + ui_set_background(BACKGROUND_ICON_ERROR); + ui_print("Installation aborted.\n"); + } else if (!ui_text_visible()) { + return; // reboot if logs aren't visible } else { - ui_print("\nInstall from sdcard complete.\n"); + if (firmware_update_pending()) { + ui_print("\nReboot via menu to complete\n" + "installation.\n"); + } else { + ui_print("\nInstall from sdcard complete.\n"); + } } } break; From fae335e159ba4dac8cce5836c906094563cd987d Mon Sep 17 00:00:00 2001 From: Koushik Dutta Date: Wed, 14 Jul 2010 21:01:44 -0700 Subject: [PATCH 12/13] version 2.5.0.0 --- Android.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Android.mk b/Android.mk index 9ecc2de..f964bc6 100644 --- a/Android.mk +++ b/Android.mk @@ -26,7 +26,7 @@ LOCAL_MODULE := recovery LOCAL_FORCE_STATIC_EXECUTABLE := true -RECOVERY_VERSION := ClockworkMod Recovery v2.0.2.4 +RECOVERY_VERSION := ClockworkMod Recovery v2.5.0.0 LOCAL_CFLAGS := -DRECOVERY_VERSION="$(RECOVERY_VERSION)" RECOVERY_API_VERSION := 2 LOCAL_CFLAGS += -DRECOVERY_API_VERSION=$(RECOVERY_API_VERSION) From 92077c15d601c47d206fb2ff2ac7898296f2bf17 Mon Sep 17 00:00:00 2001 From: Koushik Dutta Date: Thu, 15 Jul 2010 00:10:08 -0700 Subject: [PATCH 13/13] removal of the recovery checkpoint needs to happen AFTER sdcard is mounted. --- Android.mk | 2 +- extendedcommands.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Android.mk b/Android.mk index f964bc6..7c843b2 100644 --- a/Android.mk +++ b/Android.mk @@ -26,7 +26,7 @@ LOCAL_MODULE := recovery LOCAL_FORCE_STATIC_EXECUTABLE := true -RECOVERY_VERSION := ClockworkMod Recovery v2.5.0.0 +RECOVERY_VERSION := ClockworkMod Recovery v2.5.0.1 LOCAL_CFLAGS := -DRECOVERY_VERSION="$(RECOVERY_VERSION)" RECOVERY_API_VERSION := 2 LOCAL_CFLAGS += -DRECOVERY_API_VERSION=$(RECOVERY_API_VERSION) diff --git a/extendedcommands.c b/extendedcommands.c index f09f24e..9310305 100644 --- a/extendedcommands.c +++ b/extendedcommands.c @@ -634,7 +634,6 @@ int run_and_remove_extendedcommand() char tmp[PATH_MAX]; sprintf(tmp, "cp %s /tmp/%s", EXTENDEDCOMMAND_SCRIPT, basename(EXTENDEDCOMMAND_SCRIPT)); __system(tmp); - __system("rm /sdcard/clockworkmod/.recoverycheckpoint"); remove(EXTENDEDCOMMAND_SCRIPT); int i = 0; for (i = 20; i > 0; i--) { @@ -645,6 +644,7 @@ int run_and_remove_extendedcommand() } sleep(1); } + remove("/sdcard/clockworkmod/.recoverycheckpoint"); if (i == 0) { ui_print("Timed out waiting for SD card... continuing anyways."); }