[AltServer] Ignores incompatible cached developer disks

Fixes issue where AltServer would always use cached developer disk, even if it isn’t compatible with the device’s operating system version.
This commit is contained in:
Riley Testut
2022-03-01 16:03:03 -08:00
parent 23516d0466
commit 37b00d670b
6 changed files with 124 additions and 25 deletions

View File

@@ -17,6 +17,8 @@ extern NSErrorUserInfoKey const ALTUnderlyingErrorCodeErrorKey;
extern NSErrorUserInfoKey const ALTProvisioningProfileBundleIDErrorKey;
extern NSErrorUserInfoKey const ALTAppNameErrorKey;
extern NSErrorUserInfoKey const ALTDeviceNameErrorKey;
extern NSErrorUserInfoKey const ALTOperatingSystemNameErrorKey;
extern NSErrorUserInfoKey const ALTOperatingSystemVersionErrorKey;
typedef NS_ERROR_ENUM(AltServerErrorDomain, ALTServerError)
{
@@ -48,6 +50,7 @@ typedef NS_ERROR_ENUM(AltServerErrorDomain, ALTServerError)
ALTServerErrorAppDeletionFailed = 16,
ALTServerErrorRequestedAppNotRunning = 100,
ALTServerErrorIncompatibleDeveloperDisk = 101
};
typedef NS_ERROR_ENUM(AltServerConnectionErrorDomain, ALTServerConnectionError)

View File

@@ -17,6 +17,8 @@ NSErrorUserInfoKey const ALTUnderlyingErrorCodeErrorKey = @"underlyingErrorCode"
NSErrorUserInfoKey const ALTProvisioningProfileBundleIDErrorKey = @"bundleIdentifier";
NSErrorUserInfoKey const ALTAppNameErrorKey = @"appName";
NSErrorUserInfoKey const ALTDeviceNameErrorKey = @"deviceName";
NSErrorUserInfoKey const ALTOperatingSystemNameErrorKey = @"ALTOperatingSystemName";
NSErrorUserInfoKey const ALTOperatingSystemVersionErrorKey = @"ALTOperatingSystemVersion";
@implementation NSError (ALTServerError)
@@ -131,6 +133,13 @@ NSErrorUserInfoKey const ALTDeviceNameErrorKey = @"deviceName";
NSString *deviceName = self.userInfo[ALTDeviceNameErrorKey] ?: NSLocalizedString(@"the device", @"");
return [NSString stringWithFormat:NSLocalizedString(@"%@ is not currently running on %@.", ""), appName, deviceName];
}
case ALTServerErrorIncompatibleDeveloperDisk:
{
NSString *osVersion = [self altserver_osVersion] ?: NSLocalizedString(@"this device's OS version", @"");
NSString *failureReason = [NSString stringWithFormat:NSLocalizedString(@"The disk is incompatible with %@.", @""), osVersion];
return failureReason;
}
}
}
@@ -180,6 +189,19 @@ NSErrorUserInfoKey const ALTDeviceNameErrorKey = @"deviceName";
return localizedDescription;
}
- (nullable NSString *)altserver_osVersion
{
NSString *osName = self.userInfo[ALTOperatingSystemNameErrorKey];
NSString *versionString = self.userInfo[ALTOperatingSystemVersionErrorKey];
if (osName == nil || versionString == nil)
{
return nil;
}
NSString *osVersion = [NSString stringWithFormat:@"%@ %@", osName, versionString];
return osVersion;
}
#pragma mark - AltServerConnectionErrorDomain -
- (nullable NSString *)altserver_connection_localizedDescription