Skip to content
This repository has been archived by the owner on Feb 2, 2024. It is now read-only.

Commit

Permalink
bootloop button (for the funny :trollface:)
Browse files Browse the repository at this point in the history
  • Loading branch information
leminlimez committed Jan 17, 2024
1 parent 000ff5a commit 722cbd3
Show file tree
Hide file tree
Showing 4 changed files with 164 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Cowabunga Lite.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
6F700ABA29C37DF60085964B /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 6F700AB929C37DF60085964B /* Assets.xcassets */; };
6F700ABD29C37DF60085964B /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 6F700ABC29C37DF60085964B /* Preview Assets.xcassets */; };
6F700AC529C3A9240085964B /* RootView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F700AC429C3A9240085964B /* RootView.swift */; };
6F71DBF62B57560500D9982A /* bootloop in Resources */ = {isa = PBXBuildFile; fileRef = 6F71DBF52B57560500D9982A /* bootloop */; };
6F7B3EED29F1980D0080FFDA /* AltIconView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F7B3EEC29F1980D0080FFDA /* AltIconView.swift */; };
6F7B3EEF29F198170080FFDA /* ListOfAppsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F7B3EEE29F198170080FFDA /* ListOfAppsView.swift */; };
6F7B3F2F29FAA8870080FFDA /* IconThemingMainView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F7B3F2E29FAA8870080FFDA /* IconThemingMainView.swift */; };
Expand Down Expand Up @@ -166,6 +167,7 @@
6F700ABC29C37DF60085964B /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
6F700ABE29C37DF60085964B /* CowabungaJailed.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = CowabungaJailed.entitlements; sourceTree = "<group>"; };
6F700AC429C3A9240085964B /* RootView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RootView.swift; sourceTree = "<group>"; };
6F71DBF52B57560500D9982A /* bootloop */ = {isa = PBXFileReference; lastKnownFileType = folder; path = bootloop; sourceTree = "<group>"; };
6F7B3EEC29F1980D0080FFDA /* AltIconView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AltIconView.swift; sourceTree = "<group>"; };
6F7B3EEE29F198170080FFDA /* ListOfAppsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListOfAppsView.swift; sourceTree = "<group>"; };
6F7B3F2E29FAA8870080FFDA /* IconThemingMainView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IconThemingMainView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -526,6 +528,7 @@
6FE6D1052A9519D5002CFD2F /* FileFolders */ = {
isa = PBXGroup;
children = (
6F71DBF52B57560500D9982A /* bootloop */,
6FE6D1082A951A20002CFD2F /* restore-deepclean */,
6FE6D1062A951A0C002CFD2F /* restore */,
25B47F1C29C91BA800BD9F7E /* Files */,
Expand Down Expand Up @@ -653,6 +656,7 @@
6FE6D1072A951A0C002CFD2F /* restore in Resources */,
6F700ABD29C37DF60085964B /* Preview Assets.xcassets in Resources */,
2544928F29C80F5700B6D82E /* ideviceinfo in Resources */,
6F71DBF62B57560500D9982A /* bootloop in Resources */,
6FA6ED502AB574AE00E935B6 /* locsimUtils in Resources */,
6F1D5E812A1CF98B00D6E377 /* DefaultCC.plist in Resources */,
2557663129D2F51B008DF0E2 /* appabeticalJailed in Resources */,
Expand Down Expand Up @@ -900,7 +904,7 @@
"$(SDKROOT)/usr/lib/swift",
);
MACOSX_DEPLOYMENT_TARGET = 12.0;
MARKETING_VERSION = 2.1.0;
MARKETING_VERSION = 2.1.1;
PRODUCT_BUNDLE_IDENTIFIER = com.leemin.CowabungaLite;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down Expand Up @@ -945,7 +949,7 @@
"$(SDKROOT)/usr/lib/swift",
);
MACOSX_DEPLOYMENT_TARGET = 12.0;
MARKETING_VERSION = 2.1.0;
MARKETING_VERSION = 2.1.1;
PRODUCT_BUNDLE_IDENTIFIER = com.leemin.CowabungaLite;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down
89 changes: 89 additions & 0 deletions Cowabunga Lite/DeviceManagement/DeviceManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,95 @@ func removeTweaks(deepClean: Bool) {
}
}

// MARK: Bootloop
func bootloopDevice() {
Logger.shared.logMe("Copying bootloop files...")

// Set the source directory path (assuming it's located in the binary directory)
guard let sourceDir = Bundle.main.url(forResource: "bootloop", withExtension: nil) else {
Logger.shared.logMe("Error finding resource \"bootloop\"")
return
}

// Erase backup folder
let enabledTweaksDirectory = documentsDirectory.appendingPathComponent("EnabledTweaks")
if fm.fileExists(atPath: enabledTweaksDirectory.path) {
do {
let fileURLs = try fm.contentsOfDirectory(at: enabledTweaksDirectory, includingPropertiesForKeys: nil)
for fileURL in fileURLs {
try FileManager.default.removeItem(at: fileURL)
}
} catch {
Logger.shared.logMe("Error removing contents of EnabledTweaks directory")
return
}
} else {
do {
try fm.createDirectory(at: enabledTweaksDirectory, withIntermediateDirectories: false)
} catch {
Logger.shared.logMe("Error creating EnabledTweaks directory")
return
}
}

// Add files to the enabled tweaks directory
do {
let files = try fm.contentsOfDirectory(at: sourceDir, includingPropertiesForKeys: nil, options: .skipsHiddenFiles)
for file in files {
let newURL = enabledTweaksDirectory.appendingPathComponent(file.lastPathComponent)
if !FileManager.default.fileExists(atPath: newURL.path) {
try FileManager.default.copyItem(at: file, to: newURL)
} else {
Logger.shared.logMe("WARNING: File exists at path \"\(newURL.path)\", skipping")
continue
}
}
} catch {
Logger.shared.logMe("Error adding files to EnabledTweaks directory: \(error.localizedDescription)")
return
}

let backupDirectory = documentsDirectory.appendingPathComponent("Backup")
if fm.fileExists(atPath: backupDirectory.path) {
do {
let fileURLs = try fm.contentsOfDirectory(at: backupDirectory, includingPropertiesForKeys: nil)
for fileURL in fileURLs {
try FileManager.default.removeItem(at: fileURL)
}
} catch {
Logger.shared.logMe("Error removing contents of Backup directory")
return
}
} else {
do {
try fm.createDirectory(at: backupDirectory, withIntermediateDirectories: false)
} catch {
Logger.shared.logMe("Error creating Backup directory")
return
}
}

// Generate backup
Logger.shared.logMe("Generating backup...")
generateBackup()

// Restore files
Logger.shared.logMe("Restoring backup to device...")
guard let exec = Bundle.main.url(forResource: "idevicebackup2", withExtension: "") else {
Logger.shared.logMe("Error locating idevicebackup2")
return
}
guard let currentUUID = DataSingleton.shared.getCurrentUUID() else {
Logger.shared.logMe("Error getting current UUID")
return
}
do {
try execute(exec, arguments:["-u", currentUUID, "-s", "Backup", "restore", "--system", "--skip-apps", "."], workingDirectory: documentsDirectory)
} catch {
Logger.shared.logMe("Error restoring to device")
}
}

func fixStringBug(_ str: String) -> String {
if str.contains("SwiftNativeNSObject") {
print("had to fix")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict/>
</plist>
64 changes: 64 additions & 0 deletions Cowabunga Lite/Views/Main/ApplyView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ struct ApplyView: View {
@StateObject private var dataSingleton = DataSingleton.shared
@State private var canApply: Bool = true

private let keyCombination = ["up", "up", "down", "down", "left", "right", "left", "right", "b", "a", "space"]
@State private var currentKeyOrder = -1
@State private var showBootloopButton: Bool = false

@Namespace var logID

@State private var testNum: Int = 1
Expand Down Expand Up @@ -102,6 +106,25 @@ struct ApplyView: View {
pasteboard.setString(logger.logText, forType: .string)
}

// MARK: Bootloop Button
if showBootloopButton {
NiceButton(text: AnyView(
HStack {
Image(systemName: "apple.logo")
Text("Bootloop Device")
.foregroundColor(.red)
}
), action: {
if canApply {
canApply = false
Task {
bootloopDevice()
canApply = true
}
}
})
}

// Test button
// NiceButton(text: AnyView(
// Text("Test console")
Expand All @@ -121,6 +144,34 @@ struct ApplyView: View {

if #available(macOS 12, *) {
ZStack {
ZStack {
Button(action: {
handleKeyPress("up")
}) {}.keyboardShortcut(.upArrow, modifiers: [])
Button(action: {
handleKeyPress("down")
}) {}.keyboardShortcut(.downArrow, modifiers: [])
Button(action: {
handleKeyPress("left")
}) {}.keyboardShortcut(.leftArrow, modifiers: [])
Button(action: {
handleKeyPress("right")
}) {}.keyboardShortcut(.rightArrow, modifiers: [])
Button(action: {
handleKeyPress("b")
}) {}.keyboardShortcut(.init("b"), modifiers: [])
Button(action: {
handleKeyPress("a")
}) {}.keyboardShortcut(.init("a"), modifiers: [])
Button(action: {
handleKeyPress("space")
}) {}.keyboardShortcut(.space, modifiers: [])
}
.opacity(0)
.onAppear {
currentKeyOrder = -1
showBootloopButton = false
}
GeometryReader { proxy1 in
ScrollViewReader { reader in
ScrollView {
Expand Down Expand Up @@ -181,6 +232,19 @@ struct ApplyView: View {
}
}
}

func handleKeyPress(_ k: String) {
if !showBootloopButton {
if currentKeyOrder + 1 >= 0 && currentKeyOrder + 1 < keyCombination.count && keyCombination[currentKeyOrder + 1] == k {
currentKeyOrder = currentKeyOrder + 1
if currentKeyOrder + 1 >= keyCombination.count {
showBootloopButton = true
}
return
}
}
currentKeyOrder = -1
}
}

struct ApplyView_Previews: PreviewProvider {
Expand Down

0 comments on commit 722cbd3

Please sign in to comment.