diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/idevicedevmodectl.c | 42 |
1 files changed, 25 insertions, 17 deletions
diff --git a/tools/idevicedevmodectl.c b/tools/idevicedevmodectl.c index a33ec84..9997cf3 100644 --- a/tools/idevicedevmodectl.c +++ b/tools/idevicedevmodectl.c | |||
@@ -146,7 +146,6 @@ static int amfi_service_send_msg(property_list_service_client_t amfi, plist_t ms | |||
146 | plist_t reply = NULL; | 146 | plist_t reply = NULL; |
147 | perr = property_list_service_receive_plist(amfi, &reply); | 147 | perr = property_list_service_receive_plist(amfi, &reply); |
148 | if (perr == PROPERTY_LIST_SERVICE_E_SUCCESS) { | 148 | if (perr == PROPERTY_LIST_SERVICE_E_SUCCESS) { |
149 | uint8_t success = 0; | ||
150 | plist_t val = plist_dict_get_item(reply, "Error"); | 149 | plist_t val = plist_dict_get_item(reply, "Error"); |
151 | if (val) { | 150 | if (val) { |
152 | const char* err = plist_get_string_ptr(val, NULL); | 151 | const char* err = plist_get_string_ptr(val, NULL); |
@@ -157,15 +156,7 @@ static int amfi_service_send_msg(property_list_service_client_t amfi, plist_t ms | |||
157 | res = 1; | 156 | res = 1; |
158 | } | 157 | } |
159 | } else { | 158 | } else { |
160 | val = plist_dict_get_item(reply, "success"); | 159 | res = plist_dict_get_item(reply, "success") ? 0 : 1; |
161 | if (val) { | ||
162 | plist_get_bool_val(val, &success); | ||
163 | } | ||
164 | if (success) { | ||
165 | res = 0; | ||
166 | } else { | ||
167 | res = 1; | ||
168 | } | ||
169 | } | 160 | } |
170 | } else { | 161 | } else { |
171 | fprintf(stderr, "Could not receive reply from device: %d\n", perr); | 162 | fprintf(stderr, "Could not receive reply from device: %d\n", perr); |
@@ -411,13 +402,30 @@ int main(int argc, char *argv[]) | |||
411 | } else { | 402 | } else { |
412 | printf("%s: Developer Mode armed, waiting for reboot...\n", udid); | 403 | printf("%s: Developer Mode armed, waiting for reboot...\n", udid); |
413 | 404 | ||
414 | // waiting for device to disconnect... | 405 | do { |
415 | WAIT_FOR(!device_connected, 20); | 406 | // waiting for device to disconnect... |
416 | 407 | idevice_free(device); | |
417 | // waiting for device to reconnect... | 408 | device = NULL; |
418 | WAIT_FOR(device_connected, 60); | 409 | WAIT_FOR(!device_connected, 40); |
419 | 410 | if (device_connected) { | |
420 | res = amfi_send_action(device, DEV_MODE_ENABLE); | 411 | printf("%s: ERROR: Device didn't reboot?!\n", udid); |
412 | res = 2; | ||
413 | break; | ||
414 | } | ||
415 | printf("disconnected\n"); | ||
416 | |||
417 | // waiting for device to reconnect... | ||
418 | WAIT_FOR(device_connected, 60); | ||
419 | if (!device_connected) { | ||
420 | printf("%s: ERROR: Device didn't re-connect?!\n", udid); | ||
421 | res = 2; | ||
422 | break; | ||
423 | } | ||
424 | printf("connected\n"); | ||
425 | |||
426 | idevice_new(&device, udid); | ||
427 | res = amfi_send_action(device, DEV_MODE_ENABLE); | ||
428 | } while (0); | ||
421 | if (res == 0) { | 429 | if (res == 0) { |
422 | printf("%s: Developer Mode successfully enabled.\n", udid); | 430 | printf("%s: Developer Mode successfully enabled.\n", udid); |
423 | } else { | 431 | } else { |