@@ -185,23 +185,14 @@ Boolean path_exists(CFTypeRef path) {
185
185
186
186
CFStringRef find_path (CFStringRef rootPath, CFStringRef namePattern, CFStringRef expression) {
187
187
FILE *fpipe = NULL ;
188
- CFStringRef quotedRootPath = rootPath;
189
188
CFStringRef cf_command;
190
189
CFRange slashLocation;
191
190
192
- if (CFStringGetCharacterAtIndex (rootPath, 0 ) != ' `' ) {
193
- quotedRootPath = CFStringCreateWithFormat (NULL , NULL , CFSTR (" '%@'" ), rootPath);
194
- }
195
-
196
191
slashLocation = CFStringFind (namePattern, CFSTR (" /" ), 0 );
197
192
if (slashLocation.location == kCFNotFound ) {
198
- cf_command = CFStringCreateWithFormat (NULL , NULL , CFSTR (" find %@ -name '%@' %@ 2>/dev/null | sort | tail -n 1" ), quotedRootPath , namePattern, expression);
193
+ cf_command = CFStringCreateWithFormat (NULL , NULL , CFSTR (" find %@ -name '%@' %@ 2>/dev/null | sort | tail -n 1" ), rootPath , namePattern, expression);
199
194
} else {
200
- cf_command = CFStringCreateWithFormat (NULL , NULL , CFSTR (" find %@ -path '%@' %@ 2>/dev/null | sort | tail -n 1" ), quotedRootPath, namePattern, expression);
201
- }
202
-
203
- if (quotedRootPath != rootPath) {
204
- CFRelease (quotedRootPath);
195
+ cf_command = CFStringCreateWithFormat (NULL , NULL , CFSTR (" find %@ -path '%@' %@ 2>/dev/null | sort | tail -n 1" ), rootPath, namePattern, expression);
205
196
}
206
197
207
198
char command[1024 ] = { ' \0 ' };
@@ -445,25 +436,39 @@ CFMutableArrayRef get_device_product_version_parts(AMDeviceRef device) {
445
436
CFStringRef copy_device_support_path (AMDeviceRef device) {
446
437
CFStringRef version = NULL ;
447
438
CFStringRef build = AMDeviceCopyValue (device, 0 , CFSTR (" BuildVersion" ));
439
+ CFStringRef deviceClass = AMDeviceCopyValue (device, 0 , CFSTR (" DeviceClass" ));
448
440
CFStringRef path = NULL ;
449
441
CFMutableArrayRef version_parts = get_device_product_version_parts (device);
450
442
443
+ NSLogVerbose (@" Device Class: %@ " , deviceClass);
444
+ NSLogVerbose (@" build: %@ " , build);
445
+
446
+ CFStringRef deviceClassPath_platform;
447
+ CFStringRef deviceClassPath_alt;
448
+ if (CFStringCompare (CFSTR (" AppleTV" ), deviceClass, 0 ) == kCFCompareEqualTo ) {
449
+ deviceClassPath_platform = CFSTR (" Platforms/AppleTVOS.platform/DeviceSupport" );
450
+ deviceClassPath_alt = CFSTR (" tvOS\\ DeviceSupport" );
451
+ } else {
452
+ deviceClassPath_platform = CFSTR (" Platforms/iPhoneOS.platform/DeviceSupport" );
453
+ deviceClassPath_alt = CFSTR (" iOS\\ DeviceSupport" );
454
+ }
451
455
while (CFArrayGetCount (version_parts) > 0 ) {
452
456
version = CFStringCreateByCombiningStrings (NULL , version_parts, CFSTR (" ." ));
457
+ NSLogVerbose (@" version: %@ " , version);
453
458
if (path == NULL ) {
454
- path = copy_xcode_path_for (CFSTR ( " iOS DeviceSupport " ) , CFStringCreateWithFormat (NULL , NULL , CFSTR (" %@ (%@)" ), version, build));
459
+ path = copy_xcode_path_for (deviceClassPath_alt , CFStringCreateWithFormat (NULL , NULL , CFSTR (" %@\\ \\ (%@\\ )" ), version, build));
455
460
}
456
461
if (path == NULL ) {
457
- path = copy_xcode_path_for (CFSTR ( " Platforms/iPhoneOS.platform/DeviceSupport " ) , CFStringCreateWithFormat (NULL , NULL , CFSTR (" %@ (%@)" ), version, build));
462
+ path = copy_xcode_path_for (deviceClassPath_platform , CFStringCreateWithFormat (NULL , NULL , CFSTR (" %@\\ \\ (%@\\ )" ), version, build));
458
463
}
459
464
if (path == NULL ) {
460
- path = copy_xcode_path_for (CFSTR ( " Platforms/iPhoneOS.platform/DeviceSupport " ) , CFStringCreateWithFormat (NULL , NULL , CFSTR (" %@ (* )" ), version));
465
+ path = copy_xcode_path_for (deviceClassPath_platform , CFStringCreateWithFormat (NULL , NULL , CFSTR (" %@\\ \\ (* \\ )" ), version));
461
466
}
462
467
if (path == NULL ) {
463
- path = copy_xcode_path_for (CFSTR ( " Platforms/iPhoneOS.platform/DeviceSupport " ) , version);
468
+ path = copy_xcode_path_for (deviceClassPath_platform , version);
464
469
}
465
470
if (path == NULL ) {
466
- path = copy_xcode_path_for (CFSTR (" Platforms/iPhoneOS.platform/DeviceSupport/ Latest" ), CFSTR (" " ));
471
+ path = copy_xcode_path_for (CFStringCreateWithFormat ( NULL , NULL , CFSTR (" %@%@ " ), deviceClassPath_platform, CFSTR ( " / Latest" ) ), CFSTR (" " ));
467
472
}
468
473
CFRelease (version);
469
474
if (path != NULL ) {
@@ -474,7 +479,7 @@ CFStringRef copy_device_support_path(AMDeviceRef device) {
474
479
475
480
CFRelease (version_parts);
476
481
CFRelease (build);
477
-
482
+ CFRelease (deviceClass);
478
483
if (path == NULL )
479
484
on_error (@" Unable to locate DeviceSupport directory. This probably means you don't have Xcode installed, you will need to launch the app manually and logging output will not be shown!" );
480
485
@@ -484,25 +489,40 @@ CFStringRef copy_device_support_path(AMDeviceRef device) {
484
489
CFStringRef copy_developer_disk_image_path (AMDeviceRef device) {
485
490
CFStringRef version = NULL ;
486
491
CFStringRef build = AMDeviceCopyValue (device, 0 , CFSTR (" BuildVersion" ));
492
+ CFStringRef deviceClass = AMDeviceCopyValue (device, 0 , CFSTR (" DeviceClass" ));
487
493
CFStringRef path = NULL ;
488
494
CFMutableArrayRef version_parts = get_device_product_version_parts (device);
489
495
496
+ NSLogVerbose (@" Device Class: %@ " , deviceClass);
497
+ NSLogVerbose (@" build: %@ " , build);
498
+ CFStringRef deviceClassPath_platform;
499
+ CFStringRef deviceClassPath_alt;
500
+ if (CFStringCompare (CFSTR (" AppleTV" ), deviceClass, 0 ) == kCFCompareEqualTo ) {
501
+ deviceClassPath_platform = CFSTR (" Platforms/AppleTVOS.platform/DeviceSupport" );
502
+ deviceClassPath_alt = CFSTR (" tvOS\\ DeviceSupport" );
503
+ } else {
504
+ deviceClassPath_platform = CFSTR (" Platforms/iPhoneOS.platform/DeviceSupport" );
505
+ deviceClassPath_alt = CFSTR (" iOS\\ DeviceSupport" );
506
+ }
507
+ // path = getPathForTVOS(device);
490
508
while (CFArrayGetCount (version_parts) > 0 ) {
491
509
version = CFStringCreateByCombiningStrings (NULL , version_parts, CFSTR (" ." ));
492
- if (path == NULL ) {
493
- path = copy_xcode_path_for (CFSTR (" iOS DeviceSupport" ), CFStringCreateWithFormat (NULL , NULL , CFSTR (" %@ (%@)/DeveloperDiskImage.dmg" ), version, build));
510
+ NSLogVerbose (@" version: %@ " , version);
511
+
512
+ if (path == NULL ) {
513
+ path = copy_xcode_path_for (CFStringCreateWithFormat (NULL , NULL , CFSTR (" %@/%@\\ \\ (%@\\ )" ), deviceClassPath_alt, version, build), CFSTR (" DeveloperDiskImage.dmg" ));
494
514
}
495
515
if (path == NULL ) {
496
- path = copy_xcode_path_for (CFSTR ( " Platforms/iPhoneOS.platform/DeviceSupport " ) , CFStringCreateWithFormat (NULL , NULL , CFSTR (" %@ (%@)/DeveloperDiskImage.dmg" ), version, build));
497
- }
516
+ path = copy_xcode_path_for (deviceClassPath_platform , CFStringCreateWithFormat (NULL , NULL , CFSTR (" %@ (%@)/DeveloperDiskImage.dmg" ), version, build));
517
+ }
498
518
if (path == NULL ) {
499
- path = copy_xcode_path_for (CFSTR ( " Platforms/iPhoneOS.platform/DeviceSupport " ), CFStringCreateWithFormat (NULL , NULL , CFSTR (" * /%@ (*)/DeveloperDiskImage.dmg " ), version));
519
+ path = copy_xcode_path_for (CFStringCreateWithFormat (NULL , NULL , CFSTR (" %@ /%@\\ \\ (* \\ ) " ), deviceClassPath_platform, version), CFSTR ( " DeveloperDiskImage.dmg " ));
500
520
}
501
521
if (path == NULL ) {
502
- path = copy_xcode_path_for (CFSTR ( " Platforms/iPhoneOS.platform/DeviceSupport " ) , CFStringCreateWithFormat (NULL , NULL , CFSTR (" %@/DeveloperDiskImage.dmg" ), version));
522
+ path = copy_xcode_path_for (deviceClassPath_platform , CFStringCreateWithFormat (NULL , NULL , CFSTR (" %@/DeveloperDiskImage.dmg" ), version));
503
523
}
504
524
if (path == NULL ) {
505
- path = copy_xcode_path_for (CFSTR (" Platforms/iPhoneOS.platform/DeviceSupport/ Latest" ), CFSTR (" DeveloperDiskImage.dmg" ));
525
+ path = copy_xcode_path_for (CFStringCreateWithFormat ( NULL , NULL , CFSTR (" %@/ Latest" ), deviceClassPath_platform), CFSTR (" / DeveloperDiskImage.dmg" ));
506
526
}
507
527
CFRelease (version);
508
528
if (path != NULL ) {
@@ -513,6 +533,7 @@ CFStringRef copy_developer_disk_image_path(AMDeviceRef device) {
513
533
514
534
CFRelease (version_parts);
515
535
CFRelease (build);
536
+ CFRelease (deviceClass);
516
537
if (path == NULL )
517
538
on_error (@" Unable to locate DeveloperDiskImage.dmg. This probably means you don't have Xcode installed, you will need to launch the app manually and logging output will not be shown!" );
518
539
@@ -643,7 +664,7 @@ CFStringRef copy_disk_app_identifier(CFURLRef disk_app_url) {
643
664
CFURLRef plist_url = CFURLCreateCopyAppendingPathComponent (NULL , disk_app_url, CFSTR (" Info.plist" ), false );
644
665
CFReadStreamRef plist_stream = CFReadStreamCreateWithFile (NULL , plist_url);
645
666
if (!CFReadStreamOpen (plist_stream)) {
646
- on_error (@" Cannot read Info.plist file: %@ " , plist_url);
667
+ on_error (@" Cannot read Info.plist file: %@ " , plist_url);
647
668
}
648
669
649
670
CFPropertyListRef plist = CFPropertyListCreateWithStream (NULL , plist_stream, 0 , kCFPropertyListImmutable , NULL , NULL );
@@ -1676,7 +1697,7 @@ void device_callback(struct am_device_notification_callback_info *info, void *ar
1676
1697
switch (info->msg ) {
1677
1698
case ADNCI_MSG_CONNECTED:
1678
1699
if (device_id != NULL || !debug || AMDeviceGetInterfaceType (info->dev ) != 2 ) {
1679
- if (no_wifi && AMDeviceGetInterfaceType (info->dev ) == 2 )
1700
+ if (no_wifi && AMDeviceGetInterfaceType (info->dev ) == 2 )
1680
1701
{
1681
1702
NSLogVerbose (@" Skipping wifi device (type: %d )" , AMDeviceGetInterfaceType(info->dev));
1682
1703
}
0 commit comments