@@ -146,7 +146,6 @@ static int amfi_service_send_msg(property_list_service_client_t amfi, plist_t ms
146
146
plist_t reply = NULL ;
147
147
perr = property_list_service_receive_plist (amfi , & reply );
148
148
if (perr == PROPERTY_LIST_SERVICE_E_SUCCESS ) {
149
- uint8_t success = 0 ;
150
149
plist_t val = plist_dict_get_item (reply , "Error" );
151
150
if (val ) {
152
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
156
res = 1 ;
158
157
}
159
158
} else {
160
- val = plist_dict_get_item (reply , "success" );
161
- if (val ) {
162
- plist_get_bool_val (val , & success );
163
- }
164
- if (success ) {
165
- res = 0 ;
166
- } else {
167
- res = 1 ;
168
- }
159
+ res = plist_dict_get_item (reply , "success" ) ? 0 : 1 ;
169
160
}
170
161
} else {
171
162
fprintf (stderr , "Could not receive reply from device: %d\n" , perr );
@@ -411,13 +402,30 @@ int main(int argc, char *argv[])
411
402
} else {
412
403
printf ("%s: Developer Mode armed, waiting for reboot...\n" , udid );
413
404
414
- // waiting for device to disconnect...
415
- WAIT_FOR (!device_connected , 20 );
416
-
417
- // waiting for device to reconnect...
418
- WAIT_FOR (device_connected , 60 );
419
-
420
- res = amfi_send_action (device , DEV_MODE_ENABLE );
405
+ do {
406
+ // waiting for device to disconnect...
407
+ idevice_free (device );
408
+ device = NULL ;
409
+ WAIT_FOR (!device_connected , 40 );
410
+ if (device_connected ) {
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
429
if (res == 0 ) {
422
430
printf ("%s: Developer Mode successfully enabled.\n" , udid );
423
431
} else {
0 commit comments