Skip to content

Commit 11a0fe7

Browse files
committed
Starting steps to sideload with pairing file
1 parent 5ab925e commit 11a0fe7

File tree

5 files changed

+38
-1
lines changed

5 files changed

+38
-1
lines changed

AltServer/Devices/ALTDeviceManager+Installation.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -835,6 +835,7 @@ private extension ALTDeviceManager
835835
{
836836
additionalValues[Bundle.Info.deviceID] = device.identifier
837837
additionalValues[Bundle.Info.serverID] = UserDefaults.standard.serverID
838+
additionalValues[Bundle.Info.devicePairingString] = ALTDeviceManager.shared.getPairingPlistString(device.identifier)
838839

839840
if
840841
let machineIdentifier = certificate.machineIdentifier,

AltServer/Devices/ALTDeviceManager.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ extern NSNotificationName const ALTDeviceManagerDeviceDidDisconnectNotification
5050
- (void)startWiredConnectionToDevice:(ALTDevice *)device completionHandler:(void (^)(ALTWiredConnection *_Nullable connection, NSError *_Nullable error))completionHandler;
5151
- (void)startNotificationConnectionToDevice:(ALTDevice *)device completionHandler:(void (^)(ALTNotificationConnection *_Nullable connection, NSError *_Nullable error))completionHandler;
5252
- (void)startDebugConnectionToDevice:(ALTDevice *)device completionHandler:(void (^)(ALTDebugConnection *_Nullable connection, NSError * _Nullable error))completionHandler;
53+
- (NSString *)getPairingPlistString:(NSString *)udid;
5354

5455
@end
5556

AltServer/Devices/ALTDeviceManager.mm

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
#include <libimobiledevice/afc.h>
2828
#include <libimobiledevice/misagent.h>
2929
#include <libimobiledevice/mobile_image_mounter.h>
30+
#include <common/userpref.h>
31+
#include <libimobiledevice/service.h>
3032

3133
void ALTDeviceManagerUpdateStatus(plist_t command, plist_t status, void *udid);
3234
void ALTDeviceManagerUpdateAppDeletionStatus(plist_t command, plist_t status, void *uuid);
@@ -386,6 +388,38 @@ - (NSProgress *)installAppAtURL:(NSURL *)fileURL toDeviceWithUDID:(NSString *)ud
386388

387389
return progress;
388390
}
391+
- (NSString *)getPairingPlistString:(NSString*)udid{
392+
plist_t pair_record = NULL;
393+
char *buffer = NULL;
394+
uint32_t length;
395+
char* temp_udid = (char *)udid.UTF8String;
396+
userpref_read_pair_record(temp_udid, &pair_record);
397+
plist_dict_set_item(pair_record, "UDID", plist_new_string(temp_udid));
398+
plist_to_xml(pair_record, &buffer, &length);
399+
return [NSString stringWithUTF8String:(buffer)];
400+
}
401+
402+
static void print_error_message(lockdownd_error_t err, const char *udid)
403+
{
404+
switch (err) {
405+
case LOCKDOWN_E_PASSWORD_PROTECTED:
406+
fprintf(stderr, "ERROR: Could not validate with device %s because a passcode is set. Please enter the passcode on the device and retry.\n", udid);
407+
break;
408+
case LOCKDOWN_E_INVALID_CONF:
409+
case LOCKDOWN_E_INVALID_HOST_ID:
410+
fprintf(stderr, "ERROR: Device %s is not paired with this host\n", udid);
411+
break;
412+
case LOCKDOWN_E_PAIRING_DIALOG_RESPONSE_PENDING:
413+
fprintf(stderr, "ERROR: Please accept the trust dialog on the screen of device %s, then attempt to pair again.\n", udid);
414+
break;
415+
case LOCKDOWN_E_USER_DENIED_PAIRING:
416+
fprintf(stderr, "ERROR: Device %s said that the user denied the trust dialog.\n", udid);
417+
break;
418+
default:
419+
fprintf(stderr, "ERROR: Device %s returned unhandled error code %d\n", udid, err);
420+
break;
421+
}
422+
}
389423

390424
- (BOOL)writeDirectory:(NSURL *)directoryURL toDestinationURL:(NSURL *)destinationURL client:(afc_client_t)afc progress:(NSProgress *)progress error:(NSError **)error
391425
{

Shared/Extensions/ALTApplication+AltStoreApp.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ extension ALTApplication
1313
static let altstoreBundleID = "com.rileytestut.AltStore"
1414

1515
var isAltStoreApp: Bool {
16-
let isAltStoreApp = self.bundleIdentifier.contains(ALTApplication.altstoreBundleID)
16+
let isAltStoreApp = self.bundleIdentifier.contains(ALTApplication.altstoreBundleID) || self.bundleIdentifier.contains("SideStore")
1717
return isAltStoreApp
1818
}
1919
}

Shared/Extensions/Bundle+AltStore.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public extension Bundle
1414
{
1515
public static let deviceID = "ALTDeviceID"
1616
public static let serverID = "ALTServerID"
17+
public static let devicePairingString = "ALTPairingFile"
1718
public static let certificateID = "ALTCertificateID"
1819
public static let appGroups = "ALTAppGroups"
1920
public static let altBundleID = "ALTBundleIdentifier"

0 commit comments

Comments
 (0)