diff --git a/AltStore/Managing Apps/AppManager.swift b/AltStore/Managing Apps/AppManager.swift index 92293f39..89b38848 100644 --- a/AltStore/Managing Apps/AppManager.swift +++ b/AltStore/Managing Apps/AppManager.swift @@ -997,6 +997,7 @@ extension AppManager case .failure(let error): completionHandler(.failure(error)) case .success(let installedApp): completionHandler(.success(installedApp)) } + //UIApplication.shared.open(shortcutURLon, options: [:], completionHandler: nil) } installOperation.addDependency(sendAppOperation) diff --git a/AltStore/Operations/InstallAppOperation.swift b/AltStore/Operations/InstallAppOperation.swift index 0f1e47bd..9e94206c 100644 --- a/AltStore/Operations/InstallAppOperation.swift +++ b/AltStore/Operations/InstallAppOperation.swift @@ -11,6 +11,8 @@ import AltStoreCore import AltSign import Roxas +let shortcutURLonDelay = URL(string: "shortcuts://run-shortcut?name=TurnOnDataDelay")! + @objc(InstallAppOperation) final class InstallAppOperation: ResultOperation { @@ -211,6 +213,10 @@ final class InstallAppOperation: ResultOperation let alert = UIAlertController(title: "Finish Refresh", message: "Please reopen SideStore after the process is finished.To finish refreshing, SideStore must be moved to the background. To do this, you can either go to the Home Screen manually or by hitting Continue. Please reopen SideStore after doing this.", preferredStyle: .alert) alert.addAction(UIAlertAction(title: NSLocalizedString("Continue", comment: ""), style: .default, handler: { _ in print("Going home") + // Cell Shortcut + UIApplication.shared.open(shortcutURLonDelay, options: [:]) { _ in + print("Cell OFF Shortcut finished execution.")} + UIApplication.shared.perform(#selector(NSXPCConnection.suspend)) })) @@ -227,6 +233,8 @@ final class InstallAppOperation: ResultOperation } } } + // Cell Shortcut + UIApplication.shared.open(shortcutURLonDelay, options: [:]) { _ in print("Cell OFF Shortcut finished execution.")} UIApplication.shared.perform(#selector(NSXPCConnection.suspend)) } } diff --git a/AltStore/Operations/Patch App/PatchAppOperation.swift b/AltStore/Operations/Patch App/PatchAppOperation.swift index cdb6f678..21d636ba 100644 --- a/AltStore/Operations/Patch App/PatchAppOperation.swift +++ b/AltStore/Operations/Patch App/PatchAppOperation.swift @@ -211,7 +211,6 @@ private extension PatchAppOperation #if targetEnvironment(simulator) throw PatchAppError.unsupportedOperatingSystemVersion(ProcessInfo.processInfo.operatingSystemVersion) #else - let spotlightPath = "Applications/Spotlight.app/Spotlight" let spotlightFileURL = self.patchDirectory.appendingPathComponent(spotlightPath) diff --git a/AltStore/Operations/SendAppOperation.swift b/AltStore/Operations/SendAppOperation.swift index d852630a..737f92df 100644 --- a/AltStore/Operations/SendAppOperation.swift +++ b/AltStore/Operations/SendAppOperation.swift @@ -25,39 +25,48 @@ final class SendAppOperation: ResultOperation<()> self.progress.totalUnitCount = 1 } - override func main() - { + override func main() { super.main() - - if let error = self.context.error - { + + if let error = self.context.error { return self.finish(.failure(error)) } - + guard let resignedApp = self.context.resignedApp else { return self.finish(.failure(OperationError.invalidParameters("SendAppOperation.main: self.resignedApp is nil"))) } - - // self.context.resignedApp.fileURL points to the app bundle, but we want the .ipa. + + let shortcutURLoff = URL(string: "shortcuts://run-shortcut?name=TurnOffData")! + let app = AnyApp(name: resignedApp.name, bundleIdentifier: self.context.bundleIdentifier, url: resignedApp.fileURL, storeApp: nil) let fileURL = InstalledApp.refreshedIPAURL(for: app) - print("AFC App `fileURL`: \(fileURL.absoluteString)") - - if let data = NSData(contentsOf: fileURL) { - do { + + // Wait for Shortcut to Finish Before Proceeding + UIApplication.shared.open(shortcutURLoff, options: [:]) { _ in + print("Shortcut finished execution. Proceeding with file transfer.") + + DispatchQueue.global().async { + self.processFile(at: fileURL, for: app.bundleIdentifier) + } + } + } + + private func processFile(at fileURL: URL, for bundleIdentifier: String) { + guard let data = NSData(contentsOf: fileURL) else { + print("IPA doesn't exist????") + return self.finish(.failure(OperationError(.appNotFound(name: bundleIdentifier)))) + } + + do { let bytes = Data(data) try yeetAppAFC(app.bundleIdentifier, bytes) - self.progress.completedUnitCount += 1 - self.finish(.success(())) - } catch { - self.finish(.failure(MinimuxerError.RwAfc)) - self.progress.completedUnitCount += 1 - self.finish(.success(())) - } - } else { - print("IPA doesn't exist????") - self.finish(.failure(OperationError(.appNotFound(name: resignedApp.name)))) + self.progress.completedUnitCount += 1 + self.finish(.success(())) + } catch { + self.finish(.failure(MinimuxerError.RwAfc)) + self.progress.completedUnitCount += 1 + self.finish(.success(())) } } }