a minor debugging version

This commit is contained in:
senthil 2014-09-02 16:18:33 -04:00
parent c85248c88a
commit 6bd90a5133

View File

@ -292,6 +292,8 @@ const CFStringRef get_device_hardware_name(const AMDeviceRef device) {
CFStringRef model = AMDeviceCopyValue(device, 0, CFSTR("HardwareModel")); CFStringRef model = AMDeviceCopyValue(device, 0, CFSTR("HardwareModel"));
const char *hwmodel = CFStringGetCStringPtr(model, CFStringGetSystemEncoding()); const char *hwmodel = CFStringGetCStringPtr(model, CFStringGetSystemEncoding());
printf("-->Hardware model: %s\n", hwmodel);
if (hwmodel && !strcmp("M68AP", hwmodel)) if (hwmodel && !strcmp("M68AP", hwmodel))
return CFSTR("iPhone"); return CFSTR("iPhone");
if (hwmodel && !strcmp("N45AP", hwmodel)) if (hwmodel && !strcmp("N45AP", hwmodel))
@ -358,6 +360,8 @@ const CFStringRef get_device_hardware_name(const AMDeviceRef device) {
return CFSTR("iPad 4 (CDMA)"); return CFSTR("iPad 4 (CDMA)");
if (hwmodel && !strcmp("N78AP", hwmodel)) if (hwmodel && !strcmp("N78AP", hwmodel))
return CFSTR("iPod touch 5G"); return CFSTR("iPod touch 5G");
if (hwmodel && !strcmp("A1509", hwmodel))
return CFSTR("iPod touch 5G");
if (hwmodel && !strcmp("J33AP", hwmodel)) if (hwmodel && !strcmp("J33AP", hwmodel))
return CFSTR("Apple TV 3G"); return CFSTR("Apple TV 3G");
if (hwmodel && !strcmp("J33IAP", hwmodel)) if (hwmodel && !strcmp("J33IAP", hwmodel))
@ -366,21 +370,53 @@ const CFStringRef get_device_hardware_name(const AMDeviceRef device) {
return CFSTR("Unknown Device"); return CFSTR("Unknown Device");
} }
char * MYCFStringCopyUTF8String(CFStringRef aString) {
if (aString == NULL) {
return NULL;
}
CFIndex length = CFStringGetLength(aString);
CFIndex maxSize =
CFStringGetMaximumSizeForEncoding(length,
kCFStringEncodingUTF8);
char *buffer = (char *)malloc(maxSize);
if (CFStringGetCString(aString, buffer, maxSize,
kCFStringEncodingUTF8)) {
return buffer;
}
return NULL;
}
CFStringRef get_device_full_name(const AMDeviceRef device) { CFStringRef get_device_full_name(const AMDeviceRef device) {
CFStringRef full_name = NULL, CFStringRef full_name = NULL,
device_udid = AMDeviceCopyDeviceIdentifier(device), device_udid = AMDeviceCopyDeviceIdentifier(device),
device_name = NULL, device_name = NULL,
model_name = NULL; model_name = NULL;
AMDeviceConnect(device); kern_return_t ret = AMDeviceConnect(device);
printf("-->AMDeviceConnect: %08x\n",ret);
device_name = AMDeviceCopyValue(device, 0, CFSTR("DeviceName")), device_name = AMDeviceCopyValue(device, 0, CFSTR("DeviceName")),
model_name = get_device_hardware_name(device); model_name = get_device_hardware_name(device);
if(device_name != NULL && model_name != NULL) printf("-->[%s] %ld\n",CFStringGetCStringPtr(device_name, CFStringGetSystemEncoding()), CFStringGetLength(device_name));
printf("-->[%s] %ld\n",CFStringGetCStringPtr(device_name, kCFStringEncodingUTF8), CFStringGetLength(device_name));
printf("-->[%s] %ld\n",CFStringGetCStringPtr(model_name, CFStringGetSystemEncoding()), CFStringGetLength(model_name));
printf("-->[%s] %ld\n",CFStringGetCStringPtr(device_udid, CFStringGetSystemEncoding()), CFStringGetLength(device_udid));
CFShowStr(device_name);
printf("-->[%s] bytes\n",MYCFStringCopyUTF8String(device_name));
if((device_name != NULL) && CFStringGetLength(device_name) > 0 && (model_name != NULL) && CFStringGetLength(model_name)>0)
{
printf("In if\n");
full_name = CFStringCreateWithFormat(NULL, NULL, CFSTR("%@ '%@' (%@)"), model_name, device_name, device_udid); full_name = CFStringCreateWithFormat(NULL, NULL, CFSTR("%@ '%@' (%@)"), model_name, device_name, device_udid);
}
else else
full_name = CFStringCreateWithFormat(NULL, NULL, CFSTR("(%@)"), device_udid); {
printf("In else: %s\n",CFStringGetCStringPtr(device_udid, CFStringGetSystemEncoding()));
full_name = CFStringCreateWithFormat(NULL, NULL, CFSTR("(%@ss)"), device_udid);
}
AMDeviceDisconnect(device); AMDeviceDisconnect(device);
@ -391,6 +427,7 @@ CFStringRef get_device_full_name(const AMDeviceRef device) {
if(model_name != NULL) if(model_name != NULL)
CFRelease(model_name); CFRelease(model_name);
printf("-->[%s]\n",CFStringGetCStringPtr(full_name, CFStringGetSystemEncoding()));
return full_name; return full_name;
} }