From 1ba51e161e7e30ecc42589eb154d2fc8b1029320 Mon Sep 17 00:00:00 2001 From: Joseph Mattello Date: Wed, 4 Jan 2023 12:20:08 -0500 Subject: [PATCH] Add placeholder for minimux retries Signed-off-by: Joseph Mattello --- AltStore/LaunchViewController.swift | 10 ++++++++++ minimuxer/minimuxer.swift | 30 +++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/AltStore/LaunchViewController.swift b/AltStore/LaunchViewController.swift index 4bbc1811..25692f06 100644 --- a/AltStore/LaunchViewController.swift +++ b/AltStore/LaunchViewController.swift @@ -149,7 +149,17 @@ final class LaunchViewController: RSTLaunchViewController, UIDocumentPickerDeleg func start_minimuxer_threads(_ pairing_file: String) { set_usbmuxd_socket() + #if false // Retries + var res = start_minimuxer(pairing_file: pairing_file) + var attempts = 10 + while (attempts != 0 && res != 0) { + print("start_minimuxer `res` != 0, retry #\(attempts)") + res = start_minimuxer(pairing_file: pairing_file) + attempts -= 1 + } + #else let res = start_minimuxer(pairing_file: pairing_file) + #endif if res != 0 { displayError("minimuxer failed to start. Incorrect arguments were passed.") } diff --git a/minimuxer/minimuxer.swift b/minimuxer/minimuxer.swift index d1afe1d8..fb024f63 100644 --- a/minimuxer/minimuxer.swift +++ b/minimuxer/minimuxer.swift @@ -27,7 +27,17 @@ public func set_usbmuxd_socket() { public func debug_app(app_id: String) throws -> Uhoh { let ai = NSString(string: app_id) let ai_pointer = UnsafeMutablePointer(mutating: ai.utf8String) + #if false // Retries + var res = minimuxer_debug_app(ai_pointer) + var attempts = 10 + while (attempts != 0 && res != 0) { + print("(JIT) ATTEMPTS: \(attempts)") + res = minimuxer_debug_app(ai_pointer) + attempts -= 1 + } + #else let res = minimuxer_debug_app(ai_pointer) + #endif if res != 0 { throw Uhoh.Bad(code: res) } @@ -38,7 +48,17 @@ public func install_provisioning_profile(plist: Data) throws -> Uhoh { let pls = String(decoding: plist, as: UTF8.self) print(pls) print(plist) + #if false // Retries + var res = minimuxer_install_provisioning_profile(x, UInt32(plist.count)) + var attempts = 10 + while (attempts != 0 && res != 0) { + print("(INSTALL) ATTEMPTS: \(attempts)") + res = minimuxer_install_provisioning_profile(x, UInt32(plist.count)) + attempts -= 1 + } + #else let x = plist.withUnsafeBytes { buf in UnsafeMutableRawPointer(mutating: buf) } + #endif let res = minimuxer_install_provisioning_profile(x, UInt32(plist.count)) if res != 0 { throw Uhoh.Bad(code: res) @@ -49,7 +69,17 @@ public func install_provisioning_profile(plist: Data) throws -> Uhoh { public func remove_provisioning_profile(id: String) throws -> Uhoh { let id_ns = NSString(string: id) let id_pointer = UnsafeMutablePointer(mutating: id_ns.utf8String) + #if false // Retries + var res = minimuxer_remove_provisioning_profile(id_pointer) + var attempts = 10 + while (attempts != 0 && res != 0) { + print("(REMOVE PROFILE) ATTEMPTS: \(attempts)") + res = minimuxer_remove_provisioning_profile(id_pointer) + attempts -= 1 + } + #else let res = minimuxer_remove_provisioning_profile(id_pointer) + #endif if res != 0 { throw Uhoh.Bad(code: res) }