summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2019-10-07 02:58:45 +0200
committerGravatar Nikias Bassen2019-10-07 02:58:45 +0200
commit21f2060266be290283eae0e53a87de679364159f (patch)
tree865ea7cdf0482e97efe539ea9fc64508389cef94
parentabe88cdff1cfc5de20ed158d636397d131d0cf5d (diff)
downloadidevicerestore-21f2060266be290283eae0e53a87de679364159f.tar.gz
idevicerestore-21f2060266be290283eae0e53a87de679364159f.tar.bz2
Recovery: Properly detect iBEC execution (via device reconnect)
-rw-r--r--src/idevicerestore.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/src/idevicerestore.c b/src/idevicerestore.c
index f354b12..6a9add0 100644
--- a/src/idevicerestore.c
+++ b/src/idevicerestore.c
@@ -1163,10 +1163,27 @@ int idevicerestore_start(struct idevicerestore_client_t* client)
return -2;
}
recovery_client_free(client);
-
- /* this must be long enough to allow the device to run the iBEC */
- /* FIXME: Probably better to detect if the device is back then */
- sleep(7);
+
+ debug("Waiting for device to disconnect...\n");
+ WAIT_FOR(client->mode == &idevicerestore_modes[MODE_UNKNOWN] || (client->flags & FLAG_QUIT), 10);
+ if (client->mode != &idevicerestore_modes[MODE_UNKNOWN] || (client->flags & FLAG_QUIT)) {
+ if (!(client->flags & FLAG_QUIT)) {
+ error("ERROR: Device did not disconnect. Possibly invalid iBEC. Reset device and try again.\n");
+ }
+ if (delete_fs && filesystem)
+ unlink(filesystem);
+ return -2;
+ }
+ debug("Waiting for device to reconnect in recovery mode...\n");
+ WAIT_FOR(client->mode == &idevicerestore_modes[MODE_RECOVERY] || (client->flags & FLAG_QUIT), 10);
+ if (client->mode != &idevicerestore_modes[MODE_RECOVERY] || (client->flags & FLAG_QUIT)) {
+ if (!(client->flags & FLAG_QUIT)) {
+ error("ERROR: Device did not reconnect in recovery mode. Possibly invalid iBEC. Reset device and try again.\n");
+ }
+ if (delete_fs && filesystem)
+ unlink(filesystem);
+ return -2;
+ }
}
idevicerestore_progress(client, RESTORE_STEP_PREPARE, 0.5);
if (client->flags & FLAG_QUIT) {