command line nandroid

This commit is contained in:
Koushik Dutta 2010-06-26 12:25:02 -07:00
parent d634bb2d2b
commit 0837091e8d
6 changed files with 59 additions and 14 deletions

View File

@ -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)

View File

@ -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;

View File

@ -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 <directory>\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();
}

View File

@ -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

View File

@ -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");

5
ui.c
View File

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