allow selective restore
diff --git a/Android.mk b/Android.mk
index 749059a..b5def18 100644
--- a/Android.mk
+++ b/Android.mk
@@ -26,7 +26,7 @@
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)
diff --git a/commands.c b/commands.c
index 520c143..3114569 100644
--- a/commands.c
+++ b/commands.c
@@ -801,7 +801,7 @@
return 1;
}
- return nandroid_restore(argv[0]);
+ return nandroid_restore(argv[0], 1, 1, 1, 1);
}
static int
diff --git a/extendedcommands.c b/extendedcommands.c
index 5b3f7d4..f3ddd00 100644
--- a/extendedcommands.c
+++ b/extendedcommands.c
@@ -347,7 +347,7 @@
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 @@
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 @@
static char* list[] = { "Backup",
"Restore",
+ "Advanced Restore",
NULL
};
@@ -595,6 +646,9 @@
case 1:
show_nandroid_restore_menu();
break;
+ case 2:
+ show_nandroid_advanced_restore_menu();
+ break;
}
}
diff --git a/nandroid.c b/nandroid.c
index 7201438..5a54f45 100644
--- a/nandroid.c
+++ b/nandroid.c
@@ -174,7 +174,7 @@
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 @@
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();
diff --git a/nandroid.h b/nandroid.h
index 3f6c5a8..2ab0308 100644
--- a/nandroid.h
+++ b/nandroid.h
@@ -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
\ No newline at end of file