diff --git a/extendedcommands.c b/extendedcommands.c index a59b9b0..0269f64 100644 --- a/extendedcommands.c +++ b/extendedcommands.c @@ -162,10 +162,16 @@ char* choose_file_menu(const char* directory, const char* extension, const char* return NULL; } - int chosen_item = get_menu_selection(headers, list, 1); - static char ret[PATH_MAX]; - strcpy(ret, files[chosen_item]); - return ret; + for (;;) + { + int chosen_item = get_menu_selection(headers, list, 0); + if (chosen_item == GO_BACK) + break; + static char ret[PATH_MAX]; + strcpy(ret, files[chosen_item]); + return ret; + } + return NULL; } void show_choose_zip_menu() @@ -211,33 +217,14 @@ void show_nandroid_restore_menu() "", NULL }; - - int ret = system("cat /proc/cmdline | sed 's/.*serialno=//' | cut -d' ' -f1 > /.deviceid"); - FILE *deviceIdFile = fopen(".deviceid", "r"); - char deviceId[256]; - if (deviceIdFile == NULL || ret == 0) - { - ui_print("Unable to retrieve device id.\n"); - return; - } - int readCount = fread(deviceId, 1, sizeof(deviceId), deviceIdFile); - if (readCount == 0) - { - ui_print("Unable to retrieve device id.\n"); - return; - } - deviceId[readCount - 1] = NULL; - fclose(deviceIdFile); - char backupDirectory[PATH_MAX]; - sprintf(backupDirectory, "/sdcard/nandroid/%s/", deviceId); - char* file = choose_file_menu(backupDirectory, "", headers); + char* file = choose_file_menu("/sdcard/nandroid/", "", headers); if (file == NULL) return; char* command[PATH_MAX]; sprintf(command, "nandroid-mobile.sh restore %s", file); ui_print("Performing restore...\n"); - ret = system(command); + int ret = system(command); if (ret != 0) { ui_print("Error while restoring!\n"); diff --git a/mtdutils/Android.mk b/mtdutils/Android.mk index e0cc524..c45a75d 100644 --- a/mtdutils/Android.mk +++ b/mtdutils/Android.mk @@ -30,26 +30,40 @@ include $(BUILD_EXECUTABLE) include $(CLEAR_VARS) LOCAL_SRC_FILES := flash_image.c -LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES +#LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES LOCAL_MODULE := recovery_flash_image -LOCAL_MODULE_TAGS := eng -LOCAL_STATIC_LIBRARIES := libmtdutils libcutils libc -LOCAL_MODULE_STEM := flash_image -LOCAL_FORCE_STATIC_EXECUTABLE := true -LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin -ADDITIONAL_RECOVERY_EXECUTABLES += recovery_flash_image -include $(BUILD_EXECUTABLE) +#LOCAL_MODULE_TAGS := eng +#LOCAL_STATIC_LIBRARIES := libmtdutils libcutils libc +#LOCAL_MODULE_STEM := flash_image +#LOCAL_FORCE_STATIC_EXECUTABLE := true +#LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin +LOCAL_CFLAGS += -Dmain=flash_image_main +#ADDITIONAL_RECOVERY_EXECUTABLES += recovery_flash_image +include $(BUILD_STATIC_LIBRARY) include $(CLEAR_VARS) LOCAL_SRC_FILES := dump_image.c -LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES +#LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES LOCAL_MODULE := recovery_dump_image +#LOCAL_MODULE_TAGS := eng +#LOCAL_STATIC_LIBRARIES := libmtdutils libcutils libc +#LOCAL_MODULE_STEM := dump_image +#LOCAL_FORCE_STATIC_EXECUTABLE := true +#LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin +LOCAL_CFLAGS += -Dmain=dump_image_main +#ADDITIONAL_RECOVERY_EXECUTABLES += recovery_dump_image +include $(BUILD_STATIC_LIBRARY) + + +include $(CLEAR_VARS) +LOCAL_SRC_FILES := driver.c +LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES +LOCAL_MODULE := recovery_tools LOCAL_MODULE_TAGS := eng -LOCAL_STATIC_LIBRARIES := libmtdutils libcutils libc -LOCAL_MODULE_STEM := dump_image +LOCAL_STATIC_LIBRARIES := recovery_mkyaffs2image recovery_unyaffs recovery_dump_image recovery_flash_image libmtdutils libcutils libc LOCAL_FORCE_STATIC_EXECUTABLE := true LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin -ADDITIONAL_RECOVERY_EXECUTABLES += recovery_dump_image +ADDITIONAL_RECOVERY_EXECUTABLES += recovery_tools include $(BUILD_EXECUTABLE) endif # TARGET_ARCH == arm diff --git a/mtdutils/dump_image.c b/mtdutils/dump_image.c index bc96abc..8c3a052 100644 --- a/mtdutils/dump_image.c +++ b/mtdutils/dump_image.c @@ -34,7 +34,7 @@ #define BLOCK_SIZE 2048 #define SPARE_SIZE (BLOCK_SIZE >> 5) -void die(const char *msg, ...) { +static void die(const char *msg, ...) { int err = errno; va_list args; va_start(args, msg); diff --git a/nandroid/nandroid-mobile.sh b/nandroid/nandroid-mobile.sh index e8ae697..ba4b85e 100755 --- a/nandroid/nandroid-mobile.sh +++ b/nandroid/nandroid-mobile.sh @@ -52,7 +52,6 @@ # 9. print success. -DEVICEID=foo RECOVERY=foo echo "nandroid-mobile v2.1" @@ -60,7 +59,7 @@ mkfstab.sh > /etc/fstab if [ "$1" == "" ]; then echo "Usage: $0 {backup|restore} [/path/to/nandroid/backup/]" - echo "- backup will store a full system backup on /sdcard/nandroid/$DEVICEID" + echo "- backup will store a full system backup on /sdcard/nandroid" echo "- restore path will restore the last made backup for boot, system, recovery and data" exit 0 fi @@ -104,16 +103,11 @@ case $1 in esac # 1 -DEVICEID=`cat /proc/cmdline | sed "s/.*serialno=//" | cut -d" " -f1` RECOVERY=`cat /proc/cmdline | grep "androidboot.mode=recovery"` if [ "$RECOVERY" == "foo" ]; then echo "error: not running in recovery mode, aborting" exit 1 fi -if [ "$DEVICEID" == "foo" ]; then - echo "error: device id not found in /proc/cmdline, aborting" - exit 1 -fi if [ ! "`id -u 2>/dev/null`" == "0" ]; then if [ "`whoami 2>&1 | grep 'uid 0'`" == "" ]; then echo "error: must run as root, aborting" @@ -178,7 +172,7 @@ case $1 in ;; *) echo "Usage: $0 {backup|restore} [/path/to/nandroid/backup/]" - echo "- backup will store a full system backup on /sdcard/nandroid/$DEVICEID" + echo "- backup will store a full system backup on /sdcard/nandroid" echo "- restore path will restore the last made backup for boot, system, recovery and data" exit 1 ;; @@ -199,7 +193,7 @@ case $FAIL in esac TIMESTAMP="`date +%Y%m%d-%H%M`" -DESTDIR="/sdcard/nandroid/$DEVICEID/$TIMESTAMP" +DESTDIR="/sdcard/nandroid/$TIMESTAMP" if [ ! -d $DESTDIR ]; then mkdir -p $DESTDIR if [ ! -d $DESTDIR ]; then diff --git a/recovery.c b/recovery.c index f7d61d2..45911ea 100644 --- a/recovery.c +++ b/recovery.c @@ -346,6 +346,7 @@ get_menu_selection(char** headers, char** items, int menu_only) { } ui_end_menu(); + ui_clear_key_queue(); return chosen_item; }