[AltServer] Reads devices’ OS version during discovery

This commit is contained in:
Riley Testut
2021-05-20 12:02:55 -07:00
parent 128a3fe2f2
commit 279a290b60
2 changed files with 23 additions and 1 deletions

View File

@@ -1312,14 +1312,24 @@ NSNotificationName const ALTDeviceManagerDeviceDidDisconnectNotification = @"ALT
char *device_name = NULL;
char *device_type_string = NULL;
char *device_version_string = NULL;
plist_t device_type_plist = NULL;
plist_t device_version_plist = NULL;
void (^cleanUp)(void) = ^{
if (device_version_plist) {
plist_free(device_version_plist);
}
if (device_type_plist) {
plist_free(device_type_plist);
}
if (device_version_string) {
free(device_version_string);
}
if (device_type_string) {
free(device_type_string);
}
@@ -1399,10 +1409,22 @@ NSNotificationName const ALTDeviceManagerDeviceDidDisconnectNotification = @"ALT
continue;
}
if (lockdownd_get_value(client, NULL, "ProductVersion", &device_version_plist) != LOCKDOWN_E_SUCCESS)
{
fprintf(stderr, "ERROR: Could not get device type for %s!\n", device_name);
cleanUp();
continue;
}
plist_get_string_val(device_version_plist, &device_version_string);
NSOperatingSystemVersion osVersion = NSOperatingSystemVersionFromString(@(device_version_string));
NSString *name = [NSString stringWithCString:device_name encoding:NSUTF8StringEncoding];
NSString *identifier = [NSString stringWithCString:udid encoding:NSUTF8StringEncoding];
ALTDevice *altDevice = [[ALTDevice alloc] initWithName:name identifier:identifier type:deviceType];
altDevice.osVersion = osVersion;
[connectedDevices addObject:altDevice];
cleanUp();