[AltServer] Supports sideloading apps to Apple TV

This commit is contained in:
Riley Testut
2020-11-11 17:50:19 -08:00
parent 3b45ab7f62
commit 1ce9731465
2 changed files with 49 additions and 11 deletions

View File

@@ -99,7 +99,7 @@ extension ALTDeviceManager
let anisetteData = try result.get()
session.anisetteData = anisetteData
self.prepareAllProvisioningProfiles(for: application, team: team, session: session) { (result) in
self.prepareAllProvisioningProfiles(for: application, device: device, team: team, session: session) { (result) in
do
{
let profiles = try result.get()
@@ -397,10 +397,10 @@ To prevent this from happening, feel free to try again with another Apple ID.
}
}
func prepareAllProvisioningProfiles(for application: ALTApplication, team: ALTTeam, session: ALTAppleAPISession,
func prepareAllProvisioningProfiles(for application: ALTApplication, device: ALTDevice, team: ALTTeam, session: ALTAppleAPISession,
completion: @escaping (Result<[String: ALTProvisioningProfile], Error>) -> Void)
{
self.prepareProvisioningProfile(for: application, parentApp: nil, team: team, session: session) { (result) in
self.prepareProvisioningProfile(for: application, parentApp: nil, device: device, team: team, session: session) { (result) in
do
{
let profile = try result.get()
@@ -414,7 +414,7 @@ To prevent this from happening, feel free to try again with another Apple ID.
{
dispatchGroup.enter()
self.prepareProvisioningProfile(for: appExtension, parentApp: application, team: team, session: session) { (result) in
self.prepareProvisioningProfile(for: appExtension, parentApp: application, device: device, team: team, session: session) { (result) in
switch result
{
case .failure(let e): error = e
@@ -443,7 +443,7 @@ To prevent this from happening, feel free to try again with another Apple ID.
}
}
func prepareProvisioningProfile(for application: ALTApplication, parentApp: ALTApplication?, team: ALTTeam, session: ALTAppleAPISession, completionHandler: @escaping (Result<ALTProvisioningProfile, Error>) -> Void)
func prepareProvisioningProfile(for application: ALTApplication, parentApp: ALTApplication?, device: ALTDevice, team: ALTTeam, session: ALTAppleAPISession, completionHandler: @escaping (Result<ALTProvisioningProfile, Error>) -> Void)
{
let parentBundleID = parentApp?.bundleIdentifier ?? application.bundleIdentifier
let updatedParentBundleID: String
@@ -486,7 +486,7 @@ To prevent this from happening, feel free to try again with another Apple ID.
{
let appID = try result.get()
self.fetchProvisioningProfile(for: appID, team: team, session: session) { (result) in
self.fetchProvisioningProfile(for: appID, device: device, team: team, session: session) { (result) in
completionHandler(result)
}
}
@@ -666,7 +666,7 @@ To prevent this from happening, feel free to try again with another Apple ID.
func register(_ device: ALTDevice, team: ALTTeam, session: ALTAppleAPISession, completionHandler: @escaping (Result<ALTDevice, Error>) -> Void)
{
ALTAppleAPI.shared.fetchDevices(for: team, session: session) { (devices, error) in
ALTAppleAPI.shared.fetchDevices(for: team, types: device.type, session: session) { (devices, error) in
do
{
let devices = try Result(devices, error).get()
@@ -677,7 +677,7 @@ To prevent this from happening, feel free to try again with another Apple ID.
}
else
{
ALTAppleAPI.shared.registerDevice(name: device.name, identifier: device.identifier, team: team, session: session) { (device, error) in
ALTAppleAPI.shared.registerDevice(name: device.name, identifier: device.identifier, type: device.type, team: team, session: session) { (device, error) in
completionHandler(Result(device, error))
}
}
@@ -689,9 +689,9 @@ To prevent this from happening, feel free to try again with another Apple ID.
}
}
func fetchProvisioningProfile(for appID: ALTAppID, team: ALTTeam, session: ALTAppleAPISession, completionHandler: @escaping (Result<ALTProvisioningProfile, Error>) -> Void)
func fetchProvisioningProfile(for appID: ALTAppID, device: ALTDevice, team: ALTTeam, session: ALTAppleAPISession, completionHandler: @escaping (Result<ALTProvisioningProfile, Error>) -> Void)
{
ALTAppleAPI.shared.fetchProvisioningProfile(for: appID, team: team, session: session) { (profile, error) in
ALTAppleAPI.shared.fetchProvisioningProfile(for: appID, deviceType: device.type, team: team, session: session) { (profile, error) in
completionHandler(Result(profile, error))
}
}

View File

@@ -1113,13 +1113,51 @@ NSNotificationName const ALTDeviceManagerDeviceDidDisconnectNotification = @"ALT
continue;
}
plist_t device_type_plist = NULL;
if (lockdownd_get_value(client, NULL, "ProductType", &device_type_plist) != LOCKDOWN_E_SUCCESS)
{
fprintf(stderr, "ERROR: Could not get device type for %s!\n", device_name);
lockdownd_client_free(client);
idevice_free(device);
continue;
}
ALTDeviceType deviceType = ALTDeviceTypeiPhone;
char *device_type_string = NULL;
plist_get_string_val(device_type_plist, &device_type_string);
if ([@(device_type_string) hasPrefix:@"iPhone"])
{
deviceType = ALTDeviceTypeiPhone;
}
else if ([@(device_type_string) hasPrefix:@"iPad"])
{
deviceType = ALTDeviceTypeiPad;
}
else if ([@(device_type_string) hasPrefix:@"AppleTV"])
{
deviceType = ALTDeviceTypeAppleTV;
}
else
{
fprintf(stderr, "ERROR: Unknown device type %s for %s!\n", device_type_string, device_name);
lockdownd_client_free(client);
idevice_free(device);
continue;
}
lockdownd_client_free(client);
idevice_free(device);
NSString *name = [NSString stringWithCString:device_name encoding:NSUTF8StringEncoding];
NSString *identifier = [NSString stringWithCString:udid encoding:NSUTF8StringEncoding];
ALTDevice *altDevice = [[ALTDevice alloc] initWithName:name identifier:identifier type:ALTDeviceTypeiPhone];
ALTDevice *altDevice = [[ALTDevice alloc] initWithName:name identifier:identifier type:deviceType];
[connectedDevices addObject:altDevice];
if (device_name != NULL)