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();