diff options
author | Nikias Bassen | 2022-06-20 14:14:43 +0200 |
---|---|---|
committer | Nikias Bassen | 2022-06-20 14:14:43 +0200 |
commit | aa25a29e1cf7bc81450a85fdc3320c48c2d95afb (patch) | |
tree | f35ca55518affa72cf50e26ae032d3fb4da79ff8 /src/dfu.c | |
parent | f6c3d53006733e1f5bae4b073d4e7f19cefd0870 (diff) | |
download | idevicerestore-aa25a29e1cf7bc81450a85fdc3320c48c2d95afb.tar.gz idevicerestore-aa25a29e1cf7bc81450a85fdc3320c48c2d95afb.tar.bz2 |
Remove more serial number checks, and get ECID early on in all modes
Some devices seem to not have a serial number, usually in restore mode, which
will cause the restore operation to fail since we specifically check for it.
An earlier commit already removed the actual comparison in favor of comparing
the ECID, but some checks would still result in restore failures as it can't
retrieve the serial number on said devices at all.
This commit also makes sure to get the ECID in all modes as early as possible
and removes all the helper functions for it since they are not needed anymore.
Diffstat (limited to 'src/dfu.c')
-rw-r--r-- | src/dfu.c | 43 |
1 files changed, 10 insertions, 33 deletions
@@ -42,8 +42,6 @@ static int dfu_progress_callback(irecv_client_t client, const irecv_event_t* eve int dfu_client_new(struct idevicerestore_client_t* client) { - int i = 0; - int attempts = 10; irecv_client_t dfu = NULL; if (client->dfu == NULL) { @@ -55,18 +53,9 @@ int dfu_client_new(struct idevicerestore_client_t* client) } } - for (i = 1; i <= attempts; i++) { - if (irecv_open_with_ecid(&dfu, client->ecid) == IRECV_E_SUCCESS) { - break; - } - - if (i >= attempts) { - error("ERROR: Unable to connect to device in DFU mode\n"); - return -1; - } - - sleep(1); - debug("Retrying connection...\n"); + if (irecv_open_with_ecid_and_attempts(&dfu, client->ecid, 10) != IRECV_E_SUCCESS) { + error("ERROR: Unable to connect to device in DFU mode\n"); + return -1; } irecv_event_subscribe(dfu, IRECV_PROGRESS, &dfu_progress_callback, NULL); @@ -95,11 +84,17 @@ irecv_device_t dfu_get_irecv_device(struct idevicerestore_client_t* client) irecv_device_t device = NULL; irecv_init(); - if (irecv_open_with_ecid(&dfu, client->ecid) != IRECV_E_SUCCESS) { + if (irecv_open_with_ecid_and_attempts(&dfu, client->ecid, 10) != IRECV_E_SUCCESS) { return NULL; } dfu_error = irecv_devices_get_device_by_client(dfu, &device); + if (dfu_error == IRECV_E_SUCCESS) { + if (client->ecid == 0) { + const struct irecv_device_info *device_info = irecv_get_device_info(dfu); + client->ecid = device_info->ecid; + } + } irecv_close(dfu); if (dfu_error != IRECV_E_SUCCESS) { return NULL; @@ -227,24 +222,6 @@ int dfu_get_cpid(struct idevicerestore_client_t* client, unsigned int* cpid) return 0; } -int dfu_get_ecid(struct idevicerestore_client_t* client, uint64_t* ecid) -{ - if(client->dfu == NULL) { - if (dfu_client_new(client) < 0) { - return -1; - } - } - - const struct irecv_device_info *device_info = irecv_get_device_info(client->dfu->client); - if (!device_info) { - return -1; - } - - *ecid = device_info->ecid; - - return 0; -} - int dfu_is_image4_supported(struct idevicerestore_client_t* client) { if(client->dfu == NULL) { |