@@ -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 ' };
@@ -457,25 +448,39 @@ CFMutableArrayRef get_device_product_version_parts(AMDeviceRef device) {
457
448
CFStringRef copy_device_support_path (AMDeviceRef device) {
458
449
CFStringRef version = NULL ;
459
450
CFStringRef build = AMDeviceCopyValue (device, 0 , CFSTR (" BuildVersion" ));
451
+ CFStringRef deviceClass = AMDeviceCopyValue (device, 0 , CFSTR (" DeviceClass" ));
460
452
CFStringRef path = NULL ;
461
453
CFMutableArrayRef version_parts = get_device_product_version_parts (device);
462
454
455
+ NSLogVerbose (@" Device Class: %@ " , deviceClass);
456
+ NSLogVerbose (@" build: %@ " , build);
457
+
458
+ CFStringRef deviceClassPath_platform;
459
+ CFStringRef deviceClassPath_alt;
460
+ if (CFStringCompare (CFSTR (" AppleTV" ), deviceClass, 0 ) == kCFCompareEqualTo ) {
461
+ deviceClassPath_platform = CFSTR (" Platforms/AppleTVOS.platform/DeviceSupport" );
462
+ deviceClassPath_alt = CFSTR (" tvOS\\ DeviceSupport" );
463
+ } else {
464
+ deviceClassPath_platform = CFSTR (" Platforms/iPhoneOS.platform/DeviceSupport" );
465
+ deviceClassPath_alt = CFSTR (" iOS\\ DeviceSupport" );
466
+ }
463
467
while (CFArrayGetCount (version_parts) > 0 ) {
464
468
version = CFStringCreateByCombiningStrings (NULL , version_parts, CFSTR (" ." ));
469
+ NSLogVerbose (@" version: %@ " , version);
465
470
if (path == NULL ) {
466
- path = copy_xcode_path_for (CFSTR ( " iOS DeviceSupport " ) , CFStringCreateWithFormat (NULL , NULL , CFSTR (" %@ (%@)" ), version, build));
471
+ path = copy_xcode_path_for (deviceClassPath_alt , CFStringCreateWithFormat (NULL , NULL , CFSTR (" %@\\ \\ (%@\\ )" ), version, build));
467
472
}
468
473
if (path == NULL ) {
469
- path = copy_xcode_path_for (CFSTR ( " Platforms/iPhoneOS.platform/DeviceSupport " ) , CFStringCreateWithFormat (NULL , NULL , CFSTR (" %@ (%@)" ), version, build));
474
+ path = copy_xcode_path_for (deviceClassPath_platform , CFStringCreateWithFormat (NULL , NULL , CFSTR (" %@\\ \\ (%@\\ )" ), version, build));
470
475
}
471
476
if (path == NULL ) {
472
- path = copy_xcode_path_for (CFSTR ( " Platforms/iPhoneOS.platform/DeviceSupport " ) , CFStringCreateWithFormat (NULL , NULL , CFSTR (" %@ (* )" ), version));
477
+ path = copy_xcode_path_for (deviceClassPath_platform , CFStringCreateWithFormat (NULL , NULL , CFSTR (" %@\\ \\ (* \\ )" ), version));
473
478
}
474
479
if (path == NULL ) {
475
- path = copy_xcode_path_for (CFSTR ( " Platforms/iPhoneOS.platform/DeviceSupport " ) , version);
480
+ path = copy_xcode_path_for (deviceClassPath_platform , version);
476
481
}
477
482
if (path == NULL ) {
478
- path = copy_xcode_path_for (CFSTR (" Platforms/iPhoneOS.platform/DeviceSupport/ Latest" ), CFSTR (" " ));
483
+ path = copy_xcode_path_for (CFStringCreateWithFormat ( NULL , NULL , CFSTR (" %@%@ " ), deviceClassPath_platform, CFSTR ( " / Latest" ) ), CFSTR (" " ));
479
484
}
480
485
CFRelease (version);
481
486
if (path != NULL ) {
@@ -486,7 +491,7 @@ CFStringRef copy_device_support_path(AMDeviceRef device) {
486
491
487
492
CFRelease (version_parts);
488
493
CFRelease (build);
489
-
494
+ CFRelease (deviceClass);
490
495
if (path == NULL )
491
496
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!" );
492
497
@@ -496,25 +501,40 @@ CFStringRef copy_device_support_path(AMDeviceRef device) {
496
501
CFStringRef copy_developer_disk_image_path (AMDeviceRef device) {
497
502
CFStringRef version = NULL ;
498
503
CFStringRef build = AMDeviceCopyValue (device, 0 , CFSTR (" BuildVersion" ));
504
+ CFStringRef deviceClass = AMDeviceCopyValue (device, 0 , CFSTR (" DeviceClass" ));
499
505
CFStringRef path = NULL ;
500
506
CFMutableArrayRef version_parts = get_device_product_version_parts (device);
501
507
508
+ NSLogVerbose (@" Device Class: %@ " , deviceClass);
509
+ NSLogVerbose (@" build: %@ " , build);
510
+ CFStringRef deviceClassPath_platform;
511
+ CFStringRef deviceClassPath_alt;
512
+ if (CFStringCompare (CFSTR (" AppleTV" ), deviceClass, 0 ) == kCFCompareEqualTo ) {
513
+ deviceClassPath_platform = CFSTR (" Platforms/AppleTVOS.platform/DeviceSupport" );
514
+ deviceClassPath_alt = CFSTR (" tvOS\\ DeviceSupport" );
515
+ } else {
516
+ deviceClassPath_platform = CFSTR (" Platforms/iPhoneOS.platform/DeviceSupport" );
517
+ deviceClassPath_alt = CFSTR (" iOS\\ DeviceSupport" );
518
+ }
519
+ // path = getPathForTVOS(device);
502
520
while (CFArrayGetCount (version_parts) > 0 ) {
503
521
version = CFStringCreateByCombiningStrings (NULL , version_parts, CFSTR (" ." ));
504
- if (path == NULL ) {
505
- path = copy_xcode_path_for (CFSTR (" iOS DeviceSupport" ), CFStringCreateWithFormat (NULL , NULL , CFSTR (" %@ (%@)/DeveloperDiskImage.dmg" ), version, build));
522
+ NSLogVerbose (@" version: %@ " , version);
523
+
524
+ if (path == NULL ) {
525
+ path = copy_xcode_path_for (CFStringCreateWithFormat (NULL , NULL , CFSTR (" %@/%@\\ \\ (%@\\ )" ), deviceClassPath_alt, version, build), CFSTR (" DeveloperDiskImage.dmg" ));
506
526
}
507
527
if (path == NULL ) {
508
- path = copy_xcode_path_for (CFSTR ( " Platforms/iPhoneOS.platform/DeviceSupport " ) , CFStringCreateWithFormat (NULL , NULL , CFSTR (" %@ (%@)/DeveloperDiskImage.dmg" ), version, build));
509
- }
528
+ path = copy_xcode_path_for (deviceClassPath_platform , CFStringCreateWithFormat (NULL , NULL , CFSTR (" %@ (%@)/DeveloperDiskImage.dmg" ), version, build));
529
+ }
510
530
if (path == NULL ) {
511
- path = copy_xcode_path_for (CFSTR ( " Platforms/iPhoneOS.platform/DeviceSupport " ), CFStringCreateWithFormat (NULL , NULL , CFSTR (" * /%@ (*)/DeveloperDiskImage.dmg " ), version));
531
+ path = copy_xcode_path_for (CFStringCreateWithFormat (NULL , NULL , CFSTR (" %@ /%@\\ \\ (* \\ ) " ), deviceClassPath_platform, version), CFSTR ( " DeveloperDiskImage.dmg " ));
512
532
}
513
533
if (path == NULL ) {
514
- path = copy_xcode_path_for (CFSTR ( " Platforms/iPhoneOS.platform/DeviceSupport " ) , CFStringCreateWithFormat (NULL , NULL , CFSTR (" %@/DeveloperDiskImage.dmg" ), version));
534
+ path = copy_xcode_path_for (deviceClassPath_platform , CFStringCreateWithFormat (NULL , NULL , CFSTR (" %@/DeveloperDiskImage.dmg" ), version));
515
535
}
516
536
if (path == NULL ) {
517
- path = copy_xcode_path_for (CFSTR (" Platforms/iPhoneOS.platform/DeviceSupport/ Latest" ), CFSTR (" DeveloperDiskImage.dmg" ));
537
+ path = copy_xcode_path_for (CFStringCreateWithFormat ( NULL , NULL , CFSTR (" %@/ Latest" ), deviceClassPath_platform), CFSTR (" / DeveloperDiskImage.dmg" ));
518
538
}
519
539
CFRelease (version);
520
540
if (path != NULL ) {
@@ -525,6 +545,7 @@ CFStringRef copy_developer_disk_image_path(AMDeviceRef device) {
525
545
526
546
CFRelease (version_parts);
527
547
CFRelease (build);
548
+ CFRelease (deviceClass);
528
549
if (path == NULL )
529
550
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!" );
530
551
@@ -655,7 +676,7 @@ CFStringRef copy_disk_app_identifier(CFURLRef disk_app_url) {
655
676
CFURLRef plist_url = CFURLCreateCopyAppendingPathComponent (NULL , disk_app_url, CFSTR (" Info.plist" ), false );
656
677
CFReadStreamRef plist_stream = CFReadStreamCreateWithFile (NULL , plist_url);
657
678
if (!CFReadStreamOpen (plist_stream)) {
658
- on_error (@" Cannot read Info.plist file: %@ " , plist_url);
679
+ on_error (@" Cannot read Info.plist file: %@ " , plist_url);
659
680
}
660
681
661
682
CFPropertyListRef plist = CFPropertyListCreateWithStream (NULL , plist_stream, 0 , kCFPropertyListImmutable , NULL , NULL );
@@ -1688,7 +1709,7 @@ void device_callback(struct am_device_notification_callback_info *info, void *ar
1688
1709
switch (info->msg ) {
1689
1710
case ADNCI_MSG_CONNECTED:
1690
1711
if (device_id != NULL || !debug || AMDeviceGetInterfaceType (info->dev ) != 2 ) {
1691
- if (no_wifi && AMDeviceGetInterfaceType (info->dev ) == 2 )
1712
+ if (no_wifi && AMDeviceGetInterfaceType (info->dev ) == 2 )
1692
1713
{
1693
1714
NSLogVerbose (@" Skipping wifi device (type: %d )" , AMDeviceGetInterfaceType(info->dev));
1694
1715
}
0 commit comments