Run a virtual iPhone on an Apple Silicon Mac.
Swift
refactor: remove redundant state and forwarding helpers
Lakr7c69548ec1a4
diff --git a/scripts/vphoned/Daemon/GuestHTTPHandler.swift b/scripts/vphoned/Daemon/GuestHTTPHandler.swiftindex 5f81c641..0d1cd33b 100644--- a/scripts/vphoned/Daemon/GuestHTTPHandler.swift+++ b/scripts/vphoned/Daemon/GuestHTTPHandler.swift@@ -15,7 +15,6 @@ final class GuestHTTPHandler: ChannelInboundHandler, RemovableChannelHandler, @uprivate var exceededLimit = falseprivate var upload: GuestFileUpload?private var uploadError: (any Error)?- private var isBinaryUpload = falseprivate let maximumJSONBody = 1 << 20init(hub: APIEventHub, fileIO: NonBlockingFileIO) {@@ -32,8 +31,7 @@ final class GuestHTTPHandler: ChannelInboundHandler, RemovableChannelHandler, @uupload = niluploadError = nillet requestPath = request.uri.split(separator: "?", maxSplits: 1).first- isBinaryUpload = request.method == .PUT && (requestPath == "/v1/files/content" || requestPath == "/v1/clipboard/image")- if isBinaryUpload {+ if request.method == .PUT && (requestPath == "/v1/files/content" || requestPath == "/v1/clipboard/image") {do {upload = try GuestFileUpload(destination: requestPath == "/v1/clipboard/image"@@ -49,7 +47,8 @@ final class GuestHTTPHandler: ChannelInboundHandler, RemovableChannelHandler, @u} catch { uploadError = error }}case .body(var buffer):- if isBinaryUpload {+ let requestPath = head?.uri.split(separator: "?", maxSplits: 1).first+ if head?.method == .PUT && (requestPath == "/v1/files/content" || requestPath == "/v1/clipboard/image") {upload?.append(buffer, channel: context.channel)return}diff --git a/sources/FirmwarePatcher/CustomFirmware/CustomFirmwarePostRestoreDeviceTree.swift b/sources/FirmwarePatcher/CustomFirmware/CustomFirmwarePostRestoreDeviceTree.swiftindex 3a863179..0906c66b 100644--- a/sources/FirmwarePatcher/CustomFirmware/CustomFirmwarePostRestoreDeviceTree.swift+++ b/sources/FirmwarePatcher/CustomFirmware/CustomFirmwarePostRestoreDeviceTree.swift@@ -269,7 +269,6 @@ public enum CustomFirmwarePostRestoreDeviceTree {}node.properties.append(DeviceTreePatcher.DTProperty(name: name,- length: length,flags: flags,value: slice(blob, valueOffset, length),valueOffset: valueOffset,diff --git a/sources/FirmwarePatcher/DeviceTree/DeviceTreePatcher.swift b/sources/FirmwarePatcher/DeviceTree/DeviceTreePatcher.swiftindex 51e3bd67..4daf2d13 100644--- a/sources/FirmwarePatcher/DeviceTree/DeviceTreePatcher.swift+++ b/sources/FirmwarePatcher/DeviceTree/DeviceTreePatcher.swift@@ -30,15 +30,14 @@ public final class DeviceTreePatcher: Patcher {/// A single property in a device tree node.final class DTProperty {var name: String- var length: Int+ var length: Int { value.count }var flags: UInt16var value: Data/// File offset of the property value within the flat binary.let valueOffset: Int- init(name: String, length: Int, flags: UInt16, value: Data, valueOffset: Int) {+ init(name: String, flags: UInt16, value: Data, valueOffset: Int) {self.name = name- self.length = lengthself.flags = flagsself.value = valueself.valueOffset = valueOffset@@ -66,7 +65,7 @@ public final class DeviceTreePatcher: Patcher {rebuiltData = nillet root = try parsePayload(buffer.data)try applyPatches(root: root)- rebuiltData = serializePayload(root)+ rebuiltData = serializeNode(root)return patches}@@ -141,7 +140,6 @@ public final class DeviceTreePatcher: Patcher {node.properties.append(DTProperty(name: name,- length: length,flags: flags,value: value,valueOffset: valueOffset,@@ -197,10 +195,6 @@ public final class DeviceTreePatcher: Patcher {return out}- private func serializePayload(_ root: DTNode) -> Data {- serializeNode(root)- }-// MARK: - Node Navigation/// Get the "name" property value from a node.@@ -318,7 +312,6 @@ public final class DeviceTreePatcher: Patcher {Self.encodeFixedBytes(d, length: patch.length)}- prop.length = patch.lengthprop.flags = patch.flagsprop.value = newValue@@ -377,7 +370,6 @@ public final class DeviceTreePatcher: Patcher {let nameValue = Self.encodeFixedString(patch.nodeName, length: patch.nodeName.utf8.count + 1)newNode.properties.append(DTProperty(name: "name",- length: nameValue.count,flags: 0,value: nameValue,valueOffset: 0,@@ -394,7 +386,6 @@ public final class DeviceTreePatcher: Patcher {}newNode.properties.append(DTProperty(name: spec.name,- length: spec.length,flags: spec.flags,value: value,valueOffset: 0,diff --git a/sources/FirmwarePatcher/Manifest/FirmwareManifest.swift b/sources/FirmwarePatcher/Manifest/FirmwareManifest.swiftindex 43283616..9ed3cf79 100644--- a/sources/FirmwarePatcher/Manifest/FirmwareManifest.swift+++ b/sources/FirmwarePatcher/Manifest/FirmwareManifest.swift@@ -43,22 +43,6 @@ public enum FirmwareManifest {}}- // MARK: - Identity indices-- /// Discovered identity indices from cloudOS and iPhone manifests.- struct IdentityIndices {- /// vresearch101ap release identity (boot chain — matches DFU hardware).- let prod: Int- /// vresearch101ap research identity (research iBoot, TXM).- let res: Int- /// vphone600ap release identity (device tree, SEP, restore kernel).- let vp: Int- /// vphone600ap research identity (kernel cache).- let vpr: Int- /// iPhone erase identity (OS images).- let iPhoneErase: Int- }-// MARK: - Public API/// Generate hybrid BuildManifest.plist and Restore.plist.diff --git a/sources/VPhoneVirtualMachineKit/HostDevices/VPhoneCameraServer.swift b/sources/VPhoneVirtualMachineKit/HostDevices/VPhoneCameraServer.swiftindex dd5f8390..d2904aa4 100644--- a/sources/VPhoneVirtualMachineKit/HostDevices/VPhoneCameraServer.swift+++ b/sources/VPhoneVirtualMachineKit/HostDevices/VPhoneCameraServer.swift@@ -43,10 +43,6 @@ final class VPhoneCameraServer {private var connectionAttemptToken: UInt64 = 0private var framePending = false- private let sendQueue = DispatchQueue(- label: "com.vphone.camera.send",- qos: .userInteractive- )private let producerQueue = DispatchQueue(label: "com.vphone.camera.producer",qos: .userInteractivediff --git a/sources/VPhoneVirtualMachineKit/UserInterface/Browsers/VPhoneAppWindowController.swift b/sources/VPhoneVirtualMachineKit/UserInterface/Browsers/VPhoneAppWindowController.swiftindex 8347896d..3ea349a1 100644--- a/sources/VPhoneVirtualMachineKit/UserInterface/Browsers/VPhoneAppWindowController.swift+++ b/sources/VPhoneVirtualMachineKit/UserInterface/Browsers/VPhoneAppWindowController.swift@@ -4,7 +4,6 @@ import SwiftUI@MainActorclass VPhoneAppWindowController {private var window: NSWindow?- private var model: VPhoneAppBrowserModel?func showWindow(control: VPhoneGuestControl) {if let window {@@ -13,8 +12,6 @@ class VPhoneAppWindowController {}let model = VPhoneAppBrowserModel(control: control)- self.model = model-let view = VPhoneAppBrowserView(model: model)let hostingView = NSHostingView(rootView: view)@@ -46,7 +43,6 @@ class VPhoneAppWindowController {) { [weak self] _ inTask { @MainActor inself?.window = nil- self?.model = nil}}}diff --git a/sources/VPhoneVirtualMachineKit/UserInterface/Browsers/VPhoneKeychainWindowController.swift b/sources/VPhoneVirtualMachineKit/UserInterface/Browsers/VPhoneKeychainWindowController.swiftindex a303f4e0..38247c51 100644--- a/sources/VPhoneVirtualMachineKit/UserInterface/Browsers/VPhoneKeychainWindowController.swift+++ b/sources/VPhoneVirtualMachineKit/UserInterface/Browsers/VPhoneKeychainWindowController.swift@@ -4,7 +4,6 @@ import SwiftUI@MainActorclass VPhoneKeychainWindowController {private var window: NSWindow?- private var model: VPhoneKeychainBrowserModel?func showWindow(control: VPhoneGuestControl) {if let window {@@ -13,8 +12,6 @@ class VPhoneKeychainWindowController {}let model = VPhoneKeychainBrowserModel(control: control)- self.model = model-let view = VPhoneKeychainBrowserView(model: model)let hostingView = NSHostingView(rootView: view)@@ -46,7 +43,6 @@ class VPhoneKeychainWindowController {) { [weak self] _ inTask { @MainActor inself?.window = nil- self?.model = nil}}}diff --git a/sources/VPhoneVirtualMachineKit/UserInterface/VPhoneVirtualMachineWindowController.swift b/sources/VPhoneVirtualMachineKit/UserInterface/VPhoneVirtualMachineWindowController.swiftindex 839c1608..41da159c 100644--- a/sources/VPhoneVirtualMachineKit/UserInterface/VPhoneVirtualMachineWindowController.swift+++ b/sources/VPhoneVirtualMachineKit/UserInterface/VPhoneVirtualMachineWindowController.swift@@ -5,7 +5,6 @@ import Virtualization@MainActorclass VPhoneVirtualMachineWindowController: NSObject, NSToolbarDelegate {private var windowController: NSWindowController?- private var statusTimer: Timer?private weak var control: VPhoneGuestControl?private weak var virtualMachineView: VPhoneVirtualMachineView?private(set) var touchIDMonitor: VPhoneTouchIDMonitor?@@ -84,7 +83,7 @@ class VPhoneVirtualMachineWindowController: NSObject, NSToolbarDelegate {touchIDMonitor = monitor// Poll vphoned status for title indicator- statusTimer = Timer.scheduledTimer(withTimeInterval: 2, repeats: true) {+ _ = Timer.scheduledTimer(withTimeInterval: 2, repeats: true) {[weak self, weak window] _ inTask { @MainActor inguard let self, let window, let control = self.control else { return }