added support for AppleTV OS ; simplified find_path() to avoid quoting root_path (some paths weren't working)
This commit is contained in:
parent
2ed9a17914
commit
b4b17cc722
@ -185,23 +185,14 @@ Boolean path_exists(CFTypeRef path) {
|
|||||||
|
|
||||||
CFStringRef find_path(CFStringRef rootPath, CFStringRef namePattern, CFStringRef expression) {
|
CFStringRef find_path(CFStringRef rootPath, CFStringRef namePattern, CFStringRef expression) {
|
||||||
FILE *fpipe = NULL;
|
FILE *fpipe = NULL;
|
||||||
CFStringRef quotedRootPath = rootPath;
|
|
||||||
CFStringRef cf_command;
|
CFStringRef cf_command;
|
||||||
CFRange slashLocation;
|
CFRange slashLocation;
|
||||||
|
|
||||||
if (CFStringGetCharacterAtIndex(rootPath, 0) != '`') {
|
|
||||||
quotedRootPath = CFStringCreateWithFormat(NULL, NULL, CFSTR("'%@'"), rootPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
slashLocation = CFStringFind(namePattern, CFSTR("/"), 0);
|
slashLocation = CFStringFind(namePattern, CFSTR("/"), 0);
|
||||||
if (slashLocation.location == kCFNotFound) {
|
if (slashLocation.location == kCFNotFound) {
|
||||||
cf_command = CFStringCreateWithFormat(NULL, NULL, CFSTR("find %@ -name '%@' %@ 2>/dev/null | sort | tail -n 1"), quotedRootPath, namePattern, expression);
|
cf_command = CFStringCreateWithFormat(NULL, NULL, CFSTR("find %@ -name '%@' %@ 2>/dev/null | sort | tail -n 1"), rootPath, namePattern, expression);
|
||||||
} else {
|
} else {
|
||||||
cf_command = CFStringCreateWithFormat(NULL, NULL, CFSTR("find %@ -path '%@' %@ 2>/dev/null | sort | tail -n 1"), quotedRootPath, namePattern, expression);
|
cf_command = CFStringCreateWithFormat(NULL, NULL, CFSTR("find %@ -path '%@' %@ 2>/dev/null | sort | tail -n 1"), rootPath, namePattern, expression);
|
||||||
}
|
|
||||||
|
|
||||||
if (quotedRootPath != rootPath) {
|
|
||||||
CFRelease(quotedRootPath);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
char command[1024] = { '\0' };
|
char command[1024] = { '\0' };
|
||||||
@ -445,25 +436,39 @@ CFMutableArrayRef get_device_product_version_parts(AMDeviceRef device) {
|
|||||||
CFStringRef copy_device_support_path(AMDeviceRef device) {
|
CFStringRef copy_device_support_path(AMDeviceRef device) {
|
||||||
CFStringRef version = NULL;
|
CFStringRef version = NULL;
|
||||||
CFStringRef build = AMDeviceCopyValue(device, 0, CFSTR("BuildVersion"));
|
CFStringRef build = AMDeviceCopyValue(device, 0, CFSTR("BuildVersion"));
|
||||||
|
CFStringRef deviceClass = AMDeviceCopyValue(device, 0, CFSTR("DeviceClass"));
|
||||||
CFStringRef path = NULL;
|
CFStringRef path = NULL;
|
||||||
CFMutableArrayRef version_parts = get_device_product_version_parts(device);
|
CFMutableArrayRef version_parts = get_device_product_version_parts(device);
|
||||||
|
|
||||||
|
NSLogVerbose(@"Device Class: %@", deviceClass);
|
||||||
|
NSLogVerbose(@"build: %@", build);
|
||||||
|
|
||||||
|
CFStringRef deviceClassPath_platform;
|
||||||
|
CFStringRef deviceClassPath_alt;
|
||||||
|
if (CFStringCompare(CFSTR("AppleTV"), deviceClass, 0) == kCFCompareEqualTo) {
|
||||||
|
deviceClassPath_platform = CFSTR("Platforms/AppleTVOS.platform/DeviceSupport");
|
||||||
|
deviceClassPath_alt = CFSTR("tvOS\\ DeviceSupport");
|
||||||
|
} else {
|
||||||
|
deviceClassPath_platform = CFSTR("Platforms/iPhoneOS.platform/DeviceSupport");
|
||||||
|
deviceClassPath_alt = CFSTR("iOS\\ DeviceSupport");
|
||||||
|
}
|
||||||
while (CFArrayGetCount(version_parts) > 0) {
|
while (CFArrayGetCount(version_parts) > 0) {
|
||||||
version = CFStringCreateByCombiningStrings(NULL, version_parts, CFSTR("."));
|
version = CFStringCreateByCombiningStrings(NULL, version_parts, CFSTR("."));
|
||||||
|
NSLogVerbose(@"version: %@", version);
|
||||||
if (path == NULL) {
|
if (path == NULL) {
|
||||||
path = copy_xcode_path_for(CFSTR("iOS DeviceSupport"), CFStringCreateWithFormat(NULL, NULL, CFSTR("%@ (%@)"), version, build));
|
path = copy_xcode_path_for(deviceClassPath_alt, CFStringCreateWithFormat(NULL, NULL, CFSTR("%@\\ \\(%@\\)"), version, build));
|
||||||
}
|
}
|
||||||
if (path == NULL) {
|
if (path == NULL) {
|
||||||
path = copy_xcode_path_for(CFSTR("Platforms/iPhoneOS.platform/DeviceSupport"), CFStringCreateWithFormat(NULL, NULL, CFSTR("%@ (%@)"), version, build));
|
path = copy_xcode_path_for(deviceClassPath_platform, CFStringCreateWithFormat(NULL, NULL, CFSTR("%@\\ \\(%@\\)"), version, build));
|
||||||
}
|
}
|
||||||
if (path == NULL) {
|
if (path == NULL) {
|
||||||
path = copy_xcode_path_for(CFSTR("Platforms/iPhoneOS.platform/DeviceSupport"), CFStringCreateWithFormat(NULL, NULL, CFSTR("%@ (*)"), version));
|
path = copy_xcode_path_for(deviceClassPath_platform, CFStringCreateWithFormat(NULL, NULL, CFSTR("%@\\ \\(*\\)"), version));
|
||||||
}
|
}
|
||||||
if (path == NULL) {
|
if (path == NULL) {
|
||||||
path = copy_xcode_path_for(CFSTR("Platforms/iPhoneOS.platform/DeviceSupport"), version);
|
path = copy_xcode_path_for(deviceClassPath_platform, version);
|
||||||
}
|
}
|
||||||
if (path == NULL) {
|
if (path == NULL) {
|
||||||
path = copy_xcode_path_for(CFSTR("Platforms/iPhoneOS.platform/DeviceSupport/Latest"), CFSTR(""));
|
path = copy_xcode_path_for(CFStringCreateWithFormat(NULL, NULL, CFSTR("%@%@"), deviceClassPath_platform, CFSTR("/Latest")), CFSTR(""));
|
||||||
}
|
}
|
||||||
CFRelease(version);
|
CFRelease(version);
|
||||||
if (path != NULL) {
|
if (path != NULL) {
|
||||||
@ -474,7 +479,7 @@ CFStringRef copy_device_support_path(AMDeviceRef device) {
|
|||||||
|
|
||||||
CFRelease(version_parts);
|
CFRelease(version_parts);
|
||||||
CFRelease(build);
|
CFRelease(build);
|
||||||
|
CFRelease(deviceClass);
|
||||||
if (path == NULL)
|
if (path == NULL)
|
||||||
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!");
|
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!");
|
||||||
|
|
||||||
@ -484,25 +489,40 @@ CFStringRef copy_device_support_path(AMDeviceRef device) {
|
|||||||
CFStringRef copy_developer_disk_image_path(AMDeviceRef device) {
|
CFStringRef copy_developer_disk_image_path(AMDeviceRef device) {
|
||||||
CFStringRef version = NULL;
|
CFStringRef version = NULL;
|
||||||
CFStringRef build = AMDeviceCopyValue(device, 0, CFSTR("BuildVersion"));
|
CFStringRef build = AMDeviceCopyValue(device, 0, CFSTR("BuildVersion"));
|
||||||
|
CFStringRef deviceClass = AMDeviceCopyValue(device, 0, CFSTR("DeviceClass"));
|
||||||
CFStringRef path = NULL;
|
CFStringRef path = NULL;
|
||||||
CFMutableArrayRef version_parts = get_device_product_version_parts(device);
|
CFMutableArrayRef version_parts = get_device_product_version_parts(device);
|
||||||
|
|
||||||
|
NSLogVerbose(@"Device Class: %@", deviceClass);
|
||||||
|
NSLogVerbose(@"build: %@", build);
|
||||||
|
CFStringRef deviceClassPath_platform;
|
||||||
|
CFStringRef deviceClassPath_alt;
|
||||||
|
if (CFStringCompare(CFSTR("AppleTV"), deviceClass, 0) == kCFCompareEqualTo) {
|
||||||
|
deviceClassPath_platform = CFSTR("Platforms/AppleTVOS.platform/DeviceSupport");
|
||||||
|
deviceClassPath_alt = CFSTR("tvOS\\ DeviceSupport");
|
||||||
|
} else {
|
||||||
|
deviceClassPath_platform = CFSTR("Platforms/iPhoneOS.platform/DeviceSupport");
|
||||||
|
deviceClassPath_alt = CFSTR("iOS\\ DeviceSupport");
|
||||||
|
}
|
||||||
|
// path = getPathForTVOS(device);
|
||||||
while (CFArrayGetCount(version_parts) > 0) {
|
while (CFArrayGetCount(version_parts) > 0) {
|
||||||
version = CFStringCreateByCombiningStrings(NULL, version_parts, CFSTR("."));
|
version = CFStringCreateByCombiningStrings(NULL, version_parts, CFSTR("."));
|
||||||
if (path == NULL) {
|
NSLogVerbose(@"version: %@", version);
|
||||||
path = copy_xcode_path_for(CFSTR("iOS DeviceSupport"), CFStringCreateWithFormat(NULL, NULL, CFSTR("%@ (%@)/DeveloperDiskImage.dmg"), version, build));
|
|
||||||
|
if (path == NULL) {
|
||||||
|
path = copy_xcode_path_for(CFStringCreateWithFormat(NULL, NULL, CFSTR("%@/%@\\ \\(%@\\)"), deviceClassPath_alt, version, build), CFSTR("DeveloperDiskImage.dmg"));
|
||||||
}
|
}
|
||||||
if (path == NULL) {
|
if (path == NULL) {
|
||||||
path = copy_xcode_path_for(CFSTR("Platforms/iPhoneOS.platform/DeviceSupport"), CFStringCreateWithFormat(NULL, NULL, CFSTR("%@ (%@)/DeveloperDiskImage.dmg"), version, build));
|
path = copy_xcode_path_for(deviceClassPath_platform, CFStringCreateWithFormat(NULL, NULL, CFSTR("%@ (%@)/DeveloperDiskImage.dmg"), version, build));
|
||||||
}
|
|
||||||
if (path == NULL) {
|
|
||||||
path = copy_xcode_path_for(CFSTR("Platforms/iPhoneOS.platform/DeviceSupport"), CFStringCreateWithFormat(NULL, NULL, CFSTR("*/%@ (*)/DeveloperDiskImage.dmg"), version));
|
|
||||||
}
|
}
|
||||||
if (path == NULL) {
|
if (path == NULL) {
|
||||||
path = copy_xcode_path_for(CFSTR("Platforms/iPhoneOS.platform/DeviceSupport"), CFStringCreateWithFormat(NULL, NULL, CFSTR("%@/DeveloperDiskImage.dmg"), version));
|
path = copy_xcode_path_for(CFStringCreateWithFormat(NULL, NULL, CFSTR("%@/%@\\ \\(*\\)"), deviceClassPath_platform, version), CFSTR("DeveloperDiskImage.dmg"));
|
||||||
}
|
}
|
||||||
if (path == NULL) {
|
if (path == NULL) {
|
||||||
path = copy_xcode_path_for(CFSTR("Platforms/iPhoneOS.platform/DeviceSupport/Latest"), CFSTR("DeveloperDiskImage.dmg"));
|
path = copy_xcode_path_for(deviceClassPath_platform, CFStringCreateWithFormat(NULL, NULL, CFSTR("%@/DeveloperDiskImage.dmg"), version));
|
||||||
|
}
|
||||||
|
if (path == NULL) {
|
||||||
|
path = copy_xcode_path_for(CFStringCreateWithFormat(NULL, NULL, CFSTR("%@/Latest"), deviceClassPath_platform), CFSTR("/DeveloperDiskImage.dmg"));
|
||||||
}
|
}
|
||||||
CFRelease(version);
|
CFRelease(version);
|
||||||
if (path != NULL) {
|
if (path != NULL) {
|
||||||
@ -513,6 +533,7 @@ CFStringRef copy_developer_disk_image_path(AMDeviceRef device) {
|
|||||||
|
|
||||||
CFRelease(version_parts);
|
CFRelease(version_parts);
|
||||||
CFRelease(build);
|
CFRelease(build);
|
||||||
|
CFRelease(deviceClass);
|
||||||
if (path == NULL)
|
if (path == NULL)
|
||||||
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!");
|
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!");
|
||||||
|
|
||||||
@ -643,7 +664,7 @@ CFStringRef copy_disk_app_identifier(CFURLRef disk_app_url) {
|
|||||||
CFURLRef plist_url = CFURLCreateCopyAppendingPathComponent(NULL, disk_app_url, CFSTR("Info.plist"), false);
|
CFURLRef plist_url = CFURLCreateCopyAppendingPathComponent(NULL, disk_app_url, CFSTR("Info.plist"), false);
|
||||||
CFReadStreamRef plist_stream = CFReadStreamCreateWithFile(NULL, plist_url);
|
CFReadStreamRef plist_stream = CFReadStreamCreateWithFile(NULL, plist_url);
|
||||||
if (!CFReadStreamOpen(plist_stream)) {
|
if (!CFReadStreamOpen(plist_stream)) {
|
||||||
on_error(@"Cannot read Info.plist file: %@", plist_url);
|
on_error(@"Cannot read Info.plist file: %@", plist_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
CFPropertyListRef plist = CFPropertyListCreateWithStream(NULL, plist_stream, 0, kCFPropertyListImmutable, NULL, NULL);
|
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
|
|||||||
switch (info->msg) {
|
switch (info->msg) {
|
||||||
case ADNCI_MSG_CONNECTED:
|
case ADNCI_MSG_CONNECTED:
|
||||||
if(device_id != NULL || !debug || AMDeviceGetInterfaceType(info->dev) != 2) {
|
if(device_id != NULL || !debug || AMDeviceGetInterfaceType(info->dev) != 2) {
|
||||||
if (no_wifi && AMDeviceGetInterfaceType(info->dev) == 2)
|
if (no_wifi && AMDeviceGetInterfaceType(info->dev) == 2)
|
||||||
{
|
{
|
||||||
NSLogVerbose(@"Skipping wifi device (type: %d)", AMDeviceGetInterfaceType(info->dev));
|
NSLogVerbose(@"Skipping wifi device (type: %d)", AMDeviceGetInterfaceType(info->dev));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user