From 26e7635460c7369be07455a7bcc7621cf53cdd2d Mon Sep 17 00:00:00 2001 From: Joshua Hill Date: Fri, 4 Jun 2010 16:02:05 -0400 Subject: Refactoring continued, lots of bug fixes, probably about half way through --- src/normal.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'src/normal.c') diff --git a/src/normal.c b/src/normal.c index 0420a82..3c2bf5c 100644 --- a/src/normal.c +++ b/src/normal.c @@ -21,10 +21,12 @@ #include #include +#include #include #include #include "normal.h" +#include "recovery.h" #include "idevicerestore.h" int normal_check_mode(const char* uuid) { @@ -112,9 +114,11 @@ int normal_get_device(const char* uuid) { int normal_enter_recovery(const char* uuid) { idevice_t device = NULL; + irecv_client_t recovery = NULL; lockdownd_client_t lockdown = NULL; + irecv_error_t recovery_error = IRECV_E_SUCCESS; idevice_error_t device_error = IDEVICE_E_SUCCESS; - lockdownd_error_t lockdown_error = IDEVICE_E_SUCCESS; + lockdownd_error_t lockdown_error = LOCKDOWN_E_SUCCESS; device_error = idevice_new(&device, uuid); if (device_error != IDEVICE_E_SUCCESS) { @@ -141,6 +145,29 @@ int normal_enter_recovery(const char* uuid) { idevice_free(device); lockdown = NULL; device = NULL; + + if(recovery_open_with_timeout(&recovery) < 0) { + error("ERROR: Unable to enter recovery mode\n"); + return -1; + } + + recovery_error = irecv_send_command(recovery, "setenv auto-boot true"); + if (recovery_error != IRECV_E_SUCCESS) { + error("ERROR: Unable to reset auto-boot variable\n"); + irecv_close(recovery); + return -1; + } + + recovery_error = irecv_send_command(recovery, "saveenv"); + if (recovery_error != IRECV_E_SUCCESS) { + error("ERROR: Unable to save auto-boot variable\n"); + irecv_close(recovery); + return -1; + } + + idevicerestore_mode = RECOVERY_MODE; + irecv_close(recovery); + recovery = NULL; return 0; } @@ -192,4 +219,5 @@ int normal_get_ecid(const char* uuid, uint64_t* ecid) { idevice_free(device); lockdown = NULL; device = NULL; + return 0; } -- cgit v1.1-32-gdbae