allow selective restore

This commit is contained in:
Koushik K. Dutta 2010-03-25 18:19:23 -07:00
parent 78686294eb
commit fe84a7ff84
5 changed files with 70 additions and 13 deletions

View File

@ -26,7 +26,7 @@ LOCAL_MODULE := recovery
LOCAL_FORCE_STATIC_EXECUTABLE := true
RECOVERY_VERSION := ClockworkMod Recovery v1.7.7.3
RECOVERY_VERSION := ClockworkMod Recovery v1.7.8.0
LOCAL_CFLAGS := -DRECOVERY_VERSION="$(RECOVERY_VERSION)"
RECOVERY_API_VERSION := 2
LOCAL_CFLAGS += -DRECOVERY_API_VERSION=$(RECOVERY_API_VERSION)

View File

@ -801,7 +801,7 @@ cmd_restore_rom(const char *name, void *cookie, int argc, const char *argv[],
return 1;
}
return nandroid_restore(argv[0]);
return nandroid_restore(argv[0], 1, 1, 1, 1);
}
static int

View File

@ -347,7 +347,7 @@ void show_nandroid_restore_menu()
char* file = choose_file_menu("/sdcard/clockworkmod/backup/", NULL, headers);
if (file == NULL)
return;
nandroid_restore(file);
nandroid_restore(file, 1, 1, 1, 1);
}
void show_mount_usb_storage_menu()
@ -568,6 +568,56 @@ int amend_main(int argc, char** argv)
return run_script(argv[1], 0);
}
void show_nandroid_advanced_restore_menu()
{
if (ensure_root_path_mounted("SDCARD:") != 0) {
LOGE ("Can't mount /sdcard\n");
return;
}
static char* advancedheaders[] = { "Choose an image to restore",
"",
"Choose an image to restore",
"first. The next menu will",
"you more options.",
"",
NULL
};
char* file = choose_file_menu("/sdcard/clockworkmod/backup/", NULL, advancedheaders);
if (file == NULL)
return;
static char* headers[] = { "Nandroid Advanced Restore",
"",
NULL
};
static char* list[] = { "Restore boot",
"Restore system",
"Restore data",
"Restore cache",
NULL
};
int chosen_item = get_menu_selection(headers, list, 0);
switch (chosen_item)
{
case 0:
nandroid_restore(file, 1, 0, 0, 0);
break;
case 1:
nandroid_restore(file, 0, 1, 0, 0);
break;
case 2:
nandroid_restore(file, 0, 0, 1, 0);
break;
case 3:
nandroid_restore(file, 0, 0, 0, 1);
break;
}
}
void show_nandroid_menu()
{
static char* headers[] = { "Nandroid",
@ -577,6 +627,7 @@ void show_nandroid_menu()
static char* list[] = { "Backup",
"Restore",
"Advanced Restore",
NULL
};
@ -595,6 +646,9 @@ void show_nandroid_menu()
case 1:
show_nandroid_restore_menu();
break;
case 2:
show_nandroid_advanced_restore_menu();
break;
}
}

View File

@ -174,7 +174,7 @@ int nandroid_restore_partition(char* backup_path, char* root, char* name) {
return 0;
}
int nandroid_restore(char* backup_path)
int nandroid_restore(char* backup_path, int restore_boot, int restore_system, int restore_data, int restore_cache)
{
ui_set_background(BACKGROUND_ICON_INSTALLING);
ui_show_indeterminate_progress();
@ -191,20 +191,23 @@ int nandroid_restore(char* backup_path)
return print_and_error("MD5 mismatch!\n");
int ret;
sprintf(tmp, "flash_image boot %s/boot.img", backup_path);
ui_print("Restoring boot image...\n");
if (0 != (ret = __system(tmp))) {
ui_print("Error while flashing boot image!");
return ret;
if (restore_boot)
{
sprintf(tmp, "flash_image boot %s/boot.img", backup_path);
ui_print("Restoring boot image...\n");
if (0 != (ret = __system(tmp))) {
ui_print("Error while flashing boot image!");
return ret;
}
}
if (0 != (ret = nandroid_restore_partition(backup_path, "SYSTEM:", "system")))
if (restore_system && 0 != (ret = nandroid_restore_partition(backup_path, "SYSTEM:", "system")))
return ret;
if (0 != (ret = nandroid_restore_partition(backup_path, "DATA:", "data")))
if (restore_data && 0 != (ret = nandroid_restore_partition(backup_path, "DATA:", "data")))
return ret;
if (0 != (ret = nandroid_restore_partition(backup_path, "CACHE:", "cache")))
if (restore_cache && 0 != (ret = nandroid_restore_partition(backup_path, "CACHE:", "cache")))
return ret;
sync();

View File

@ -3,6 +3,6 @@
int nandroid_main(int argc, char** argv);
int nandroid_backup(char* backup_path);
int nandroid_restore(char* backup_path);
int nandroid_restore(char* backup_path, int restore_boot, int restore_system, int restore_data, int restore_cache);
#endif