diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f3611d8cb..11d298e96 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -8,7 +8,7 @@ on: workflow_dispatch: env: - VERSION: '1.1.4_3' + VERSION: '1.1.4_4' jobs: build: @@ -46,6 +46,7 @@ jobs: run: | sed -i '' "s/AAA/更新时间/g" ./Dopamine/Dopamine/UI/Views/JailbreakView.swift sed -i '' "s/AAB/${{ env.shT }}/g" ./Dopamine/Dopamine/UI/Views/JailbreakView.swift + sed -i '' "s/AAC/${{ env.msT }}/g" ./Dopamine/Dopamine/UI/Views/JailbreakView.swift sed -i '' 's/MARKETING_VERSION = .*;/MARKETING_VERSION = ${{ env.VERSION }};/g' ./Dopamine/Dopamine.xcodeproj/project.pbxproj sed -i '' "s/BBB/${{ env.VERSION }}/g" ./Packages/Fugu15KernelExploit/Sources/Fugu15KernelExploit/Fugu15.swift sudo security import Exploits/fastPath/arm.pfx -k /Library/Keychains/System.keychain -P password -A @@ -55,7 +56,7 @@ jobs: echo -e "[点击当前版本下载](https://github.com/wwg135/Dopamine/releases/download/${{ env.msT }}/Dopamine.ipa)" >> body.txt echo -e "\n更新时间:${{ env.logT }}" >> body.txt echo -e "\n**当前更新日志如下:**" >> body.txt - echo -e "\n> - 1.同步官方最新代码更新\n> - 2.当前后续版本支持桥接及挂载" >> body.txt + echo -e "\n> - 1.同步官方最新代码更新\n> - 2.修正ota升级逻辑,后续仅收到除1.0.5版本外,其他版本的ota升级\n> 3.改善代码,提高执行效率,不影响重启" >> body.txt - name: Build ipa run: | diff --git a/Dopamine/Dopamine/UI/Views/Jailbreak.swift b/Dopamine/Dopamine/UI/Views/Jailbreak.swift index 7d626004e..78aab9e8c 100644 --- a/Dopamine/Dopamine/UI/Views/Jailbreak.swift +++ b/Dopamine/Dopamine/UI/Views/Jailbreak.swift @@ -34,15 +34,21 @@ func respring() { guard let sbreloadPath = rootifyPath(path: "/usr/bin/sbreload") else { return } - _ = execCmd(args: [sbreloadPath]) + DispatchQueue.global().async { + _ = execCmd(args: [sbreloadPath]) + } } func userspaceReboot() { - _ = execCmd(args: [rootifyPath(path: "/basebin/jbctl")!, "reboot_userspace"]) + DispatchQueue.global().async { + _ = execCmd(args: [rootifyPath(path: "/basebin/jbctl")!, "reboot_userspace"]) + } } func reboot() { - _ = execCmd(args: [CommandLine.arguments[0], "reboot"]) + DispatchQueue.global().async { + _ = execCmd(args: [CommandLine.arguments[0], "reboot"]) + } } func isJailbroken() -> Bool { @@ -98,51 +104,61 @@ func jailbreak(completion: @escaping (Error?) -> ()) { } func removeZmount(rmpath: String) { - _ = execCmd(args: [CommandLine.arguments[0], "uninstall_Zmount", rmpath]) + DispatchQueue.global().async { + _ = execCmd(args: [CommandLine.arguments[0], "uninstall_Zmount", rmpath]) + } } func updateForbidUnject(toggleOn: Bool, newForbidUnject: String?) { - let fileManager = FileManager.default - let filePath = "/var/mobile/zp.unject.plist" - if fileManager.fileExists(atPath: filePath) { - if var dict = NSMutableDictionary(contentsOfFile: filePath) { + DispatchQueue.global().async { + let fileManager = FileManager.default + let filePath = "/var/mobile/zp.unject.plist" + if fileManager.fileExists(atPath: filePath) { + if var dict = NSMutableDictionary(contentsOfFile: filePath) { if let newKey = newForbidUnject { - if let _ = dict[newKey] { - dict.removeObject(forKey: newKey) - } else { - dict[newKey] = true - } + if let _ = dict[newKey] { + dict.removeObject(forKey: newKey) + } else { + dict[newKey] = true + } } else { - for (key, value) in dict { - if let boolValue = value as? Bool { - if toggleOn { - dict[key] = true - } else { - dict[key] = false - } - } + for (key, value) in dict { + if let boolValue = value as? Bool { + if toggleOn { + dict[key] = true + } else { + dict[key] = false + } } + } } dict.write(toFile: filePath, atomically: true) + } } } } func removeJailbreak() { dopamineDefaults().removeObject(forKey: "selectedPackageManagers") - _ = execCmd(args: [CommandLine.arguments[0], "uninstall_environment"]) + DispatchQueue.global().async { + _ = execCmd(args: [CommandLine.arguments[0], "uninstall_environment"]) + } if isJailbroken() { reboot() } } func jailbrokenUpdateTweakInjectionPreference() { - _ = execCmd(args: [CommandLine.arguments[0], "update_tweak_injection"]) + DispatchQueue.global().async { + _ = execCmd(args: [CommandLine.arguments[0], "update_tweak_injection"]) + } } func jailbrokenUpdateIDownloadEnabled() { let iDownloadEnabled = dopamineDefaults().bool(forKey: "iDownloadEnabled") - _ = execCmd(args: [rootifyPath(path: "basebin/jbinit")!, iDownloadEnabled ? "start_idownload" : "stop_idownload"]) + DispatchQueue.global().async { + _ = execCmd(args: [rootifyPath(path: "basebin/jbinit")!, iDownloadEnabled ? "start_idownload" : "stop_idownload"]) + } } func changeMobilePassword(newPassword: String) { @@ -152,7 +168,9 @@ func changeMobilePassword(newPassword: String) { guard let pwPath = rootifyPath(path: "/usr/sbin/pw") else { return; } - _ = execCmd(args: [dashPath, "-c", String(format: "printf \"%%s\\n\" \"\(newPassword)\" | \(pwPath) usermod 501 -h 0")]) + DispatchQueue.global().async { + _ = execCmd(args: [dashPath, "-c", String(format: "printf \"%%s\\n\" \"\(newPassword)\" | \(pwPath) usermod 501 -h 0")]) + } } func newMountPath(newPath: String) {// zqbb_flag @@ -162,7 +180,9 @@ func newMountPath(newPath: String) {// zqbb_flag guard let jbctlPath = rootifyPath(path: "/basebin/jbctl") else { return } - _ = execCmd(args: [jbctlPath, "mountPath", newPath]) + DispatchQueue.global().async { + _ = execCmd(args: [jbctlPath, "mountPath", newPath]) + } } } @@ -183,7 +203,9 @@ func isInstalledEnvironmentVersionMismatching() -> Bool { } func updateEnvironment() { - jbdUpdateFromBasebinTar(Bundle.main.bundlePath + "/basebin.tar", true) + DispatchQueue.global().async { + jbdUpdateFromBasebinTar(Bundle.main.bundlePath + "/basebin.tar", true) + } } // debugging diff --git a/Dopamine/Dopamine/UI/Views/JailbreakView.swift b/Dopamine/Dopamine/UI/Views/JailbreakView.swift index 2319a2ed6..902110405 100644 --- a/Dopamine/Dopamine/UI/Views/JailbreakView.swift +++ b/Dopamine/Dopamine/UI/Views/JailbreakView.swift @@ -503,32 +503,20 @@ struct JailbreakView: View { } } - func getDeltaChangelog(json: [[String : Any]], fromVersion: String?, toVersion: String?) -> String? { - var include: Bool = toVersion == nil + func getDeltaChangelog(json: [[String: Any]]) -> String? { + var include: Bool = false var changelogBuf: String = "" for item in json { - let versionString = item["name"] as? String - if versionString != nil { - if toVersion != nil { - if versionString! == toVersion { - include = true - } - } - - if fromVersion != nil { - if versionString! == fromVersion { - include = false - } - } + let version = item["name"] as? String + if version != "1.0.5" { + include = true - if include { - let changelog = item["body"] as? String - if changelog != nil { - if !changelogBuf.isEmpty { - changelogBuf += "\n\n\n" - } - changelogBuf += "**" + versionString! + "**\n\n" + changelog! + let changelog = item["body"] as? String + if changelog != nil { + if !changelogBuf.isEmpty { + changelogBuf += "\n\n\n" } + changelogBuf += "**" + version! + "**\n\n" + changelog! } } } @@ -556,7 +544,7 @@ struct JailbreakView: View { } func checkForUpdates() async throws { - if let currentAppVersion = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String { + let currentAppVersion = "AAC" let owner = "wwg135" let repo = "Dopamine" @@ -568,15 +556,18 @@ struct JailbreakView: View { return } - if let latestname = releasesJSON.first?["name"] as? String, latestname != currentAppVersion { - updateAvailable = true - updateChangelog = createUserOrientedChangelog(deltaChangelog: getDeltaChangelog(json: releasesJSON, fromVersion: currentAppVersion, toVersion: nil), environmentMismatch: false) + if let latest = releasesJSON.first(where: { $0["name"] as? String != "1.0.5" }) { + if let latestName = latest["tag_name"] as? String, + let latestVersion = latest["name"] as? String, + latestName != currentAppVersion && latestVersion != "1.0.5" { + updateAvailable = true + updateChangelog = createUserOrientedChangelog(deltaChangelog: getDeltaChangelog(json: releasesJSON), environmentMismatch: false) + } } if isInstalledEnvironmentVersionMismatching() { - mismatchChangelog = createUserOrientedChangelog(deltaChangelog: getDeltaChangelog(json: releasesJSON, fromVersion: installedEnvironmentVersion(), toVersion: currentAppVersion), environmentMismatch: true) + mismatchChangelog = createUserOrientedChangelog(deltaChangelog: getDeltaChangelog(json: releasesJSON), environmentMismatch: true) } - } } func getLaunchTime() -> String { diff --git a/Dopamine/Dopamine/UI/Views/UpdateDownloadingView.swift b/Dopamine/Dopamine/UI/Views/UpdateDownloadingView.swift index 0cc2ea559..b10d2339c 100644 --- a/Dopamine/Dopamine/UI/Views/UpdateDownloadingView.swift +++ b/Dopamine/Dopamine/UI/Views/UpdateDownloadingView.swift @@ -190,22 +190,22 @@ struct UpdateDownloadingView: View { let releasesJSON = try JSONSerialization.jsonObject(with: releasesData, options: []) as! [[String: Any]] Logger.log(String(data: releasesData, encoding: .utf8) ?? "none") - + // Find the latest release - guard let latestRelease = releasesJSON.first, + guard let latestRelease = releasesJSON.first(where: { $0["name"] as? String != "1.0.5" }), let assets = latestRelease["assets"] as? [[String: Any]], let asset = assets.first(where: { ($0["name"] as! String).contains(".ipa") }), let downloadURLString = asset["browser_download_url"] as? String, let downloadURL = URL(string: downloadURLString) else { throw "Could not find download URL for ipa" } - + // Download the asset try await withThrowingTaskGroup(of: Void.self) { group in downloadProgress.totalUnitCount = 1 group.addTask { let (url, _) = try await URLSession.shared.download(from: downloadURL, progress: downloadProgress) - if (isJailbroken()) { + if isJailbroken() { update(tipaURL: url) } else { guard let dopamineUpdateURL = URL(string: "apple-magnifier://install?url=\(url.absoluteString)") else { @@ -213,7 +213,7 @@ struct UpdateDownloadingView: View { } await UIApplication.shared.open(dopamineUpdateURL) exit(0) - return + return; } } try await group.waitForAll()