Skip to content

Run a virtual iPhone on an Apple Silicon Mac.

Swift

Give iPhone guests D47AP's product description

muratkurte678a9096ea8
diff --git a/Research/0_binary_patch_comparison.md b/Research/0_binary_patch_comparison.md
index 365d0917..144c78c9 100644
--- a/Research/0_binary_patch_comparison.md
+++ b/Research/0_binary_patch_comparison.md
@@ -2641,3 +2641,43 @@ removed. There is no migration.
**Opting out.** `vphone-cli fw set-patches <vm> --block
kernel-cfw-paravirt_user_clients`, then re-patch.
+
+## An iPhone guest's product description from D47AP (2026-10-04)
+
+An iPhone17,3 guest had no Siri page, no Camera Control, no Action Button and no
+Model Name, whatever its identity patches. Most of vphone600's `/product` is
+`syscfg/xxxx` placeholders (flag `0x8000`) that no syscfg fills on a VM, and
+MobileGestalt reads a placeholder as absent. An iPad guest already takes these
+from its board tree (`devicetree-cfw-ipad_*`); an iPhone guest did not, although
+its IPSW carries the iPhone's own tree, `Firmware/all_flash/DeviceTree.d47ap.im4p`.
+
+| Patch | Component | Effect |
+| --- | --- | --- |
+| `preboot-cfw-devicetree_iphone_product` (new) | Restored Preboot `devicetree.img4`, `cfw install` and `cfw update-environment`, iPhone guests | `DeviceTreePatcher.presentPhoneProduct` (`vphone-cli cfw patch-dt-iphone-product <dt> <board>`): fills the `iPhoneProductProperties` placeholders in `/product` from D47AP, adds `iPhoneAddedProductProperties`, and fills `/buttons/function-button_ringeren`. Only a placeholder is overwritten, only with a real board value. The board tree comes from `FirmwareOriginals`, or is recovered there from the VM's IPSW in `~/.vphone/ipsws` (`VPhoneBoardDeviceTree.need` now answers for iPhones too). |
+
+What is copied, and why:
+
+| Group | Properties | What it turns on |
+| --- | --- | --- |
+| Name | `product-name`, `product-description` | About › Model Name |
+| Siri | `assistant`, `siri-gesture`, `dictation`, `offline-dictation`, `builtin-mics` | Settings › Siri, side-button Siri, dictation |
+| Buttons | `side-button-location`, `volume-up-button-location`, `volume-down-button-location`; added `ringer-button-location`, `camera-button-location`, `supports-camera-button`; `/buttons/function-button_ringeren` | Settings › Action Button and Camera Control (with Accessibility pages) |
+| Display, UI | `artwork-scale-factor`, `chrome-identifier`, `compatible-device-fallback`, `display-corner-radius`, `display-mirroring`, `oled-display`, `thin-bezel`, `large-format-phone`, `ui-pip`, `ui-reachability`, `ui-background-quality`, `ui-weather-quality`, `hme-in-arkit`, `carplay-2`, `location-reminders`, `watch-companion` | the rest of D47AP's description |
+
+Deliberately left as vphone600 has them: anything that promises hardware the VM
+does not have — `bluetooth-*`, `baseband-chipset`, `nfc-express`, `exclaves-enabled`,
+`has-*`, `graphics-featureset-*`, `framebuffer-identifier`, `wifi-chipset`, the
+display calibration placeholders — and the vphone600-only placeholders
+(`gestalt-variant-id`, `variant-name`, `thinning-product-type`,
+`jetsam-properties-product-type`, `vm-supports-generative-models`).
+`/buttons` keeps no `compatible`, so no button driver binds to it and the
+board's function reference in `function-button_ringeren` is never followed.
+
+Measured on iOS 26.6.2 (23G90) + cloudOS 26.4 (23E5207q), preset `standard` plus
+the nine identity patches, by applying the same edit to the installed tree by
+hand: Settings shows Siri, Camera Control (Camera and Accessibility pages) and
+the Action Button; Siri opens from a long side-button press (HID 0x0C/0x30); the
+Action Button's long press (HID 0x0B/0x2D) runs Flashlight and Camera with the
+Dynamic Island, with no tweak; the search field gains dictation. The guest boots
+normally. Not yet measured: the change on a VM without the identity patches, on
+iOS 18.x, and a Camera Control press.
diff --git a/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/CustomFirmware/CustomFirmwarePostRestoreDeviceTree.swift b/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/CustomFirmware/CustomFirmwarePostRestoreDeviceTree.swift
index bd5bbf22..43cc03b4 100644
--- a/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/CustomFirmware/CustomFirmwarePostRestoreDeviceTree.swift
+++ b/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/CustomFirmware/CustomFirmwarePostRestoreDeviceTree.swift
@@ -103,6 +103,29 @@ public enum CustomFirmwarePostRestoreDeviceTree {
}
}
+ /// Give an iPhone guest's `devicetree.img4` (or bare `.im4p`) the product
+ /// description of the iPhone's own tree at `boardURL`, in place. See
+ /// `DeviceTreePatcher.presentPhoneProduct`.
+ @discardableResult
+ public static func presentPhoneProduct(
+ at url: URL,
+ board boardURL: URL,
+ dryRun: Bool = false,
+ verbose: Bool = true,
+ ) throws -> Outcome {
+ let boardData: Data
+ do {
+ boardData = try Data(contentsOf: boardURL)
+ } catch {
+ throw PatcherError.fileNotFound(boardURL.path)
+ }
+ let board = try openDeviceTree(boardData, path: boardURL.path).blob
+ return try rewrite(at: url, dryRun: dryRun, verbose: verbose) { blob in
+ let (newBlob, changes, delta) = try withPhoneProduct(blob, board: board)
+ return (newBlob, changes, blob.count + delta)
+ }
+ }
+
/// Remove `/product/haptics` from a guest's `devicetree.img4` (or bare
/// `.im4p`), in place. See `DeviceTreePatcher.removeHaptics(from:)`.
@discardableResult
@@ -318,6 +341,34 @@ public enum CustomFirmwarePostRestoreDeviceTree {
return (serializeNode(root), [record], change.after.count - change.before.count)
}
+ /// `blob` with the product description of the iPhone's own flat tree
+ /// `board`, through `DeviceTreePatcher.presentPhoneProduct`. Returns the
+ /// size change with the changes: a filled placeholder trades its value's
+ /// padded length for the board's, an added property brings its 36-byte
+ /// header too. A tree that already has them comes back unchanged.
+ public static func withPhoneProduct(_ blob: Data, board: Data) throws -> (Data, [Change], Int) {
+ func describe(_ value: Data) -> String {
+ let text = value.prefix(while: { $0 != 0 })
+ if !text.isEmpty, text.count == value.count - 1 || text.count == value.count,
+ let string = String(data: text, encoding: .utf8), string.allSatisfy({ $0.isASCII && !$0.isNewline })
+ {
+ return string
+ }
+ return value.hex
+ }
+ let root = try parseTree(blob, label: "DT")
+ let source = try parseTree(board, label: "board DT")
+ let changes = DeviceTreePatcher.presentPhoneProduct(in: root, from: source)
+ guard !changes.isEmpty else { return (blob, [], 0) }
+ let records = changes.map {
+ Change(property: $0.path, before: $0.before.map(describe) ?? "absent", after: describe($0.after))
+ }
+ let delta = changes.reduce(0) { sum, change in
+ sum + align4(change.after.count) - (change.before.map { align4($0.count) } ?? -36)
+ }
+ return (serializeNode(root), records, delta)
+ }
+
/// `blob` without `/product/haptics`, through
/// `DeviceTreePatcher.removeHaptics(from:)`, which fw patch uses for every
/// new guest. Returns the size change with the changes, as `withBoardAudio`
diff --git a/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/DeviceTree/DeviceTreeGuestDevicePatches.swift b/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/DeviceTree/DeviceTreeGuestDevicePatches.swift
index 7ba86934..80c34a4f 100644
--- a/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/DeviceTree/DeviceTreeGuestDevicePatches.swift
+++ b/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/DeviceTree/DeviceTreeGuestDevicePatches.swift
@@ -326,6 +326,96 @@ extension DeviceTreePatcher {
return removed
}
+ // MARK: - iPhone Product
+
+ /// `/product` properties an iPhone guest takes from its board's tree when
+ /// its own holds a `syscfg/` placeholder for them.
+ ///
+ /// On vphone600 these are placeholders no syscfg fills, and MobileGestalt
+ /// reads a placeholder as absent. Settings then has no Siri page (`assistant`),
+ /// no Model Name (`product-name`), no dictation (`dictation`), and the
+ /// button geometry SpringBoard lays out against is missing. Measured on a
+ /// 26.6.2 iPhone17,3 guest: with these from D47AP, Siri opens from the side
+ /// button, dictation appears, and Camera Control and the Action Button are
+ /// in Settings (with `iPhoneAddedProductProperties` and
+ /// `iPhoneButtonProperties`).
+ ///
+ /// Only what describes the product to userland is listed. Properties that
+ /// promise hardware the VM does not have — Bluetooth, baseband, NFC,
+ /// exclaves, `has-*`, the graphics feature set, `framebuffer-identifier`,
+ /// display calibration — stay as vphone600 has them.
+ static let iPhoneProductProperties = [
+ // What Settings and MobileGestalt name the device.
+ "product-name", "product-description",
+ // Siri and dictation.
+ "assistant", "siri-gesture", "dictation", "offline-dictation", "builtin-mics",
+ // Buttons SpringBoard and Settings lay out against.
+ "side-button-location", "volume-up-button-location", "volume-down-button-location",
+ // Display and chrome.
+ "artwork-scale-factor", "chrome-identifier", "compatible-device-fallback",
+ "display-corner-radius", "display-mirroring", "oled-display", "thin-bezel", "large-format-phone",
+ // UI and feature switches.
+ "ui-pip", "ui-reachability", "ui-background-quality", "ui-weather-quality",
+ "hme-in-arkit", "carplay-2", "location-reminders", "watch-companion",
+ ]
+
+ /// `/product` properties vphone600 lacks altogether, added from the board:
+ /// the Action Button's and Camera Control's geometry, and Camera Control
+ /// itself, without which Settings has no Camera Control page.
+ static let iPhoneAddedProductProperties = [
+ "ringer-button-location", "camera-button-location", "supports-camera-button",
+ ]
+
+ /// `/buttons` properties taken from the board when they are placeholders.
+ /// `function-button_ringeren` is what MobileGestalt reads for the Action
+ /// Button. vphone600's `/buttons` has no `compatible`, so no button driver
+ /// binds to the node and the board's function reference is never followed.
+ static let iPhoneButtonProperties = ["function-button_ringeren"]
+
+ /// One property `presentPhoneProduct` set: where, and its value before
+ /// (nil when it was added).
+ struct PhoneProductChange {
+ let path: String
+ let before: Data?
+ let after: Data
+ }
+
+ /// Give an iPhone guest's `/product` and `/buttons` the board's values for
+ /// `iPhoneProductProperties`, `iPhoneAddedProductProperties` and
+ /// `iPhoneButtonProperties`.
+ ///
+ /// A listed property is copied only when the guest's is a placeholder (or,
+ /// for the added ones, missing) and the board's is a real value, so a tree
+ /// that already has them, or a board that lacks one, is left as it is.
+ /// Returns what changed, empty when nothing did.
+ static func presentPhoneProduct(in root: DTNode, from source: DTNode) -> [PhoneProductChange] {
+ var changes: [PhoneProductChange] = []
+ func fill(_ names: [String], node: String, add: Bool) {
+ guard
+ let target = optionalChild(of: root, named: node),
+ let board = optionalChild(of: source, named: node)
+ else { return }
+ for name in names {
+ guard let value = board.properties.first(where: { $0.name == name }),
+ value.flags & placeholderFlag == 0
+ else { continue }
+ if let existing = target.properties.first(where: { $0.name == name }) {
+ guard existing.flags & placeholderFlag != 0 else { continue }
+ changes.append(PhoneProductChange(path: "\(node)/\(name)", before: existing.value, after: value.value))
+ existing.flags = 0
+ existing.value = value.value
+ } else if add {
+ target.properties.append(DTProperty(name: name, flags: 0, value: value.value, valueOffset: 0))
+ changes.append(PhoneProductChange(path: "\(node)/\(name)", before: nil, after: value.value))
+ }
+ }
+ }
+ fill(iPhoneProductProperties, node: "product", add: false)
+ fill(iPhoneAddedProductProperties, node: "product", add: true)
+ fill(iPhoneButtonProperties, node: "buttons", add: false)
+ return changes
+ }
+
/// The flat encoding of one node and its children, for the patch record.
private static func serialize(_ node: DTNode) -> Data {
var out = Data()
diff --git a/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/PatchSets/FirmwareGuestSystemPatchSet.swift b/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/PatchSets/FirmwareGuestSystemPatchSet.swift
index 451a76b8..366e2187 100644
--- a/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/PatchSets/FirmwareGuestSystemPatchSet.swift
+++ b/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/PatchSets/FirmwareGuestSystemPatchSet.swift
@@ -288,6 +288,20 @@ public enum FirmwareGuestSystemPatchSet {
""",
target: .prebootDeviceTree,
),
+ VPhonePatchDeclaration(
+ identifier: prebootIPhoneProduct,
+ title: "iPhone product description",
+ summary: """
+ Gives an iPhone guest's restored Preboot device tree the product description of the \
+ iPhone's own tree: model name, Siri and dictation, button and display geometry, \
+ Camera Control and the Action Button. vphone600 leaves them as syscfg placeholders, \
+ which MobileGestalt reads as absent, so Settings has no Siri, Camera Control or Action \
+ Button and About no Model Name. Hardware the VM does not have is left out. Takes the \
+ iPhone's device tree from the VM's FirmwareOriginals, and recovers it there from the \
+ VM's IPSW in ~/.vphone/ipsws when it is missing.
+ """,
+ target: .prebootDeviceTree,
+ ),
VPhonePatchDeclaration(
identifier: prebootHaptics,
title: "Haptics node",
@@ -368,6 +382,10 @@ public enum FirmwareGuestSystemPatchSet {
/// iPad VM patched before `fw patch` copied the board's node.
public static let prebootBoardAudio = "preboot-cfw-devicetree_board_audio"
+ /// The iPhone product description in the restored Preboot device tree,
+ /// taken from the iPhone's own tree: see `DeviceTreePatcher.presentPhoneProduct`.
+ public static let prebootIPhoneProduct = "preboot-cfw-devicetree_iphone_product"
+
/// The haptics node removal in the restored Preboot device tree, for any
/// VM patched before `fw patch` removed it from every guest's tree.
public static let prebootHaptics = "preboot-cfw-devicetree_haptics"
diff --git a/VPhoneExecutable/VPhoneCommand/FirmwarePatcherTests/CustomFirmware/CustomFirmwareIPhoneProductTests.swift b/VPhoneExecutable/VPhoneCommand/FirmwarePatcherTests/CustomFirmware/CustomFirmwareIPhoneProductTests.swift
new file mode 100644
index 00000000..e971efe7
--- /dev/null
+++ b/VPhoneExecutable/VPhoneCommand/FirmwarePatcherTests/CustomFirmware/CustomFirmwareIPhoneProductTests.swift
@@ -0,0 +1,110 @@
+// CustomFirmwareIPhoneProductTests.swift — an iPhone guest takes D47AP's product description.
+//
+// `withPhoneProduct` (the Preboot repair) fills vphone600's `/product`
+// placeholders from the board tree, adds the Camera Control and Action Button
+// properties vphone600 lacks, and fills `/buttons/function-button_ringeren`.
+// The trees here are built in the flat format the restored tree uses, so the
+// parse, the edit and the serialization all run.
+
+@testable import FirmwarePatcher
+import Foundation
+import Testing
+
+@Suite("iPhone product description from the board tree")
+struct CustomFirmwareIPhoneProductTests {
+ private typealias Node = FlatDeviceTreeNode
+
+ private static let placeholder: UInt16 = 0x8000
+
+ private static func tree(product: Node, buttons: Node) -> Data {
+ Node("device-tree", [("model", Data("iPhone17,3\0\0".utf8))], children: [
+ Node("chosen"),
+ product,
+ buttons,
+ ]).serialized
+ }
+
+ /// vphone600's, trimmed: placeholders, a real value, and a VM-only property.
+ private static let guestProduct = Node("product", [
+ ("product-name", Data("syscfg/prde\0".utf8)),
+ ("assistant", Data("syscfg/assi\0".utf8)),
+ ("framebuffer-identifier", Data("syscfg/fbid\0".utf8)),
+ ("graphics-featureset-class", Data("APPLE7\0".utf8)),
+ ], flags: ["product-name": placeholder, "assistant": placeholder, "framebuffer-identifier": placeholder])
+
+ private static let guestButtons = Node("buttons", [
+ ("function-button_ringeren", Data("syscfg/rgen\0".utf8)),
+ ("home-button-type", Node.uint32(2)),
+ ], flags: ["function-button_ringeren": placeholder])
+
+ /// D47AP's, trimmed: real values, hardware the VM lacks, and its phandle.
+ private static let boardProduct = Node("product", [
+ ("AAPL,phandle", Node.uint32(363)),
+ ("product-name", Data("iPhone 16\0".utf8)),
+ ("assistant", Node.uint32(1)),
+ ("framebuffer-identifier", Data("A6AC96E7\0".utf8)),
+ ("graphics-featureset-class", Data("APPLE9\0".utf8)),
+ ("supports-camera-button", Node.uint32(1)),
+ ("ringer-button-location", Data(repeating: 7, count: 20)),
+ ("nfc-express", Node.uint32(1)),
+ ])
+
+ private static let boardButtons = Node("buttons", [
+ ("function-button_ringeren", Data("w\0\0\0RntbNIRb".utf8)),
+ ("compatible", Data("buttons\0".utf8)),
+ ("home-button-type", Node.uint32(2)),
+ ])
+
+ /// What the guest's nodes should become.
+ private static let presentedProduct = Node("product", [
+ ("product-name", Data("iPhone 16\0".utf8)),
+ ("assistant", Node.uint32(1)),
+ ("framebuffer-identifier", Data("syscfg/fbid\0".utf8)),
+ ("graphics-featureset-class", Data("APPLE7\0".utf8)),
+ ("ringer-button-location", Data(repeating: 7, count: 20)),
+ ("supports-camera-button", Node.uint32(1)),
+ ], flags: ["framebuffer-identifier": placeholder])
+
+ private static let presentedButtons = Node("buttons", [
+ ("function-button_ringeren", Data("w\0\0\0RntbNIRb".utf8)),
+ ("home-button-type", Node.uint32(2)),
+ ])
+
+ // MARK: - Tests
+
+ @Test func `fills the placeholders and adds the missing button properties`() throws {
+ let original = Self.tree(product: Self.guestProduct, buttons: Self.guestButtons)
+ let board = Self.tree(product: Self.boardProduct, buttons: Self.boardButtons)
+ let (patched, changes, delta) = try CustomFirmwarePostRestoreDeviceTree.withPhoneProduct(original, board: board)
+ #expect(changes.map(\.property) == [
+ "product/product-name", "product/assistant",
+ "product/ringer-button-location", "product/supports-camera-button",
+ "buttons/function-button_ringeren",
+ ])
+ #expect(changes.first?.before == "syscfg/prde")
+ #expect(changes.first?.after == "iPhone 16")
+ #expect(changes[2].before == "absent")
+ #expect(patched.count == original.count + delta)
+ #expect(patched == Self.tree(product: Self.presentedProduct, buttons: Self.presentedButtons))
+ }
+
+ @Test func `leaves hardware the VM lacks and the board's phandle alone`() throws {
+ let original = Self.tree(product: Self.guestProduct, buttons: Self.guestButtons)
+ let board = Self.tree(product: Self.boardProduct, buttons: Self.boardButtons)
+ let (patched, _, _) = try CustomFirmwarePostRestoreDeviceTree.withPhoneProduct(original, board: board)
+ let text = String(decoding: patched, as: UTF8.self)
+ #expect(!text.contains("nfc-express"))
+ #expect(!text.contains("A6AC96E7"))
+ #expect(!text.contains("APPLE9"))
+ #expect(!text.contains("compatible"))
+ }
+
+ @Test func `a tree that already has them is unchanged`() throws {
+ let presented = Self.tree(product: Self.presentedProduct, buttons: Self.presentedButtons)
+ let board = Self.tree(product: Self.boardProduct, buttons: Self.boardButtons)
+ let (patched, changes, delta) = try CustomFirmwarePostRestoreDeviceTree.withPhoneProduct(presented, board: board)
+ #expect(changes.isEmpty)
+ #expect(delta == 0)
+ #expect(patched == presented)
+ }
+}
diff --git a/VPhoneExecutable/VPhoneCommand/VPhoneCommand/Firmware/VPhoneCustomFirmwareInstaller.swift b/VPhoneExecutable/VPhoneCommand/VPhoneCommand/Firmware/VPhoneCustomFirmwareInstaller.swift
index 39a99571..fb48cd3a 100644
--- a/VPhoneExecutable/VPhoneCommand/VPhoneCommand/Firmware/VPhoneCustomFirmwareInstaller.swift
+++ b/VPhoneExecutable/VPhoneCommand/VPhoneCommand/Firmware/VPhoneCustomFirmwareInstaller.swift
@@ -807,6 +807,7 @@ struct VPhoneCustomFirmwareInstaller {
private static let lateGuestPatches = [
FirmwareGuestSystemPatchSet.virtioSoundDriver,
FirmwareGuestSystemPatchSet.prebootBoardAudio,
+ FirmwareGuestSystemPatchSet.prebootIPhoneProduct,
FirmwareGuestSystemPatchSet.prebootHaptics,
FirmwareGuestSystemPatchSet.prebootMicrophoneArray,
FirmwareGuestSystemPatchSet.virtualAudioSpeakerRouteThrows,
@@ -1190,11 +1191,11 @@ struct VPhoneCustomFirmwareInstaller {
}
/// `includeIdentity` is false for an environment update, which carries
- /// only the device tree repairs: the board audio repair, which needs
- /// `boardDeviceTree`, and the haptics removal, which every guest gets.
- /// `boardDeviceTree` is the iPad's own device tree, staged from the VM's
- /// `FirmwareOriginals`, or nil for an iPhone guest or a VM patched before
- /// `fw patch` kept it.
+ /// only the device tree repairs: the board repairs, which need
+ /// `boardDeviceTree` (an iPad's audio node, an iPhone's product
+ /// description), and the haptics removal, which every guest gets.
+ /// `boardDeviceTree` is the guest's own board tree (`DeviceTree.<board>.im4p`),
+ /// staged from the VM's `FirmwareOriginals`, or nil when none is kept there.
private func patchPreboot(
volumes: [[String: Any]],
work: WorkDirectory,
@@ -1225,8 +1226,14 @@ struct VPhoneCustomFirmwareInstaller {
}
let spoofBuild = includeIdentity ? spoofBuild : nil
var repairs: [(verb: String, arguments: [String])] = []
- if let boardDeviceTree, on(FirmwareGuestSystemPatchSet.prebootBoardAudio) {
- repairs.append(("patch-dt-board-audio", [boardDeviceTree.path]))
+ if let boardDeviceTree {
+ if guestDevice.isPad {
+ if on(FirmwareGuestSystemPatchSet.prebootBoardAudio) {
+ repairs.append(("patch-dt-board-audio", [boardDeviceTree.path]))
+ }
+ } else if on(FirmwareGuestSystemPatchSet.prebootIPhoneProduct) {
+ repairs.append(("patch-dt-iphone-product", [boardDeviceTree.path]))
+ }
}
if on(FirmwareGuestSystemPatchSet.prebootHaptics) {
repairs.append(("patch-dt-haptics", []))
@@ -1299,11 +1306,14 @@ struct VPhoneCustomFirmwareInstaller {
return work.file(board.name)
}
- /// Make sure an iPad VM's `FirmwareOriginals` holds the board tree that
+ /// Make sure a VM's `FirmwareOriginals` holds the board tree that
/// `stageBoardDeviceTree` stages, recovering it from the IPSW the VM was
- /// made from when a VM patched before `fw patch` kept it has none. Without
- /// it the board audio repair cannot run, VirtualAudio looks for the
- /// iPhone's tunings, and the guest has no sound.
+ /// made from when it has none. An iPad VM patched before `fw patch` kept it
+ /// needs it for the board audio repair, without which VirtualAudio looks
+ /// for the iPhone's tunings and the guest has no sound. An iPhone VM needs
+ /// it for the product description repair, without which MobileGestalt
+ /// reads Siri, Camera Control, the Action Button and the model name as
+ /// absent; `fw patch` does not keep an iPhone's, so it always comes from here.
///
/// The IPSW cache and the VM folder are the caller's, so the search and
/// the write run with the caller's credentials, as `cfw install` records
@@ -1320,11 +1330,14 @@ struct VPhoneCustomFirmwareInstaller {
plan: VPhoneVirtualMachinePatchPlan?,
invokingUser: VPhoneInvokingUser?,
) {
- guard plan?.isEnabled(FirmwareGuestSystemPatchSet.prebootBoardAudio) ?? true else { return }
let device = configuredGuestDevice(in: bundleDirectory) ?? guestDevice(of: restore)
+ let repair = device.isPad ? FirmwareGuestSystemPatchSet.prebootBoardAudio : FirmwareGuestSystemPatchSet.prebootIPhoneProduct
+ guard plan?.isEnabled(repair) ?? true else { return }
let tree = (device.boardDeviceTreePath as NSString).lastPathComponent
let originals = VPhoneBundleOperations.firmwareOriginalsDirectoryName
- let skipped = "[!] Board audio repair skipped, so this \(device.productType) guest will have no sound:"
+ let skipped = device.isPad
+ ? "[!] Board audio repair skipped, so this \(device.productType) guest will have no sound:"
+ : "[!] iPhone product repair skipped, so this \(device.productType) guest will have no Siri, Camera Control, Action Button or Model Name:"
do {
let need = try VPhoneBoardDeviceTree.need(
device: device,
diff --git a/VPhoneExecutable/VPhoneCommand/VPhoneCommand/Firmware/VPhoneCustomFirmwarePatchCommand.swift b/VPhoneExecutable/VPhoneCommand/VPhoneCommand/Firmware/VPhoneCustomFirmwarePatchCommand.swift
index f5537521..73fcf8cf 100644
--- a/VPhoneExecutable/VPhoneCommand/VPhoneCommand/Firmware/VPhoneCustomFirmwarePatchCommand.swift
+++ b/VPhoneExecutable/VPhoneCommand/VPhoneCommand/Firmware/VPhoneCustomFirmwarePatchCommand.swift
@@ -449,6 +449,46 @@ struct VPhoneCustomFirmwarePatchBoardAudioCommand: ParsableCommand {
}
}
+// MARK: - patch-dt-iphone-product
+
+struct VPhoneCustomFirmwarePatchIPhoneProductCommand: ParsableCommand {
+ static let configuration = CommandConfiguration(
+ commandName: "patch-dt-iphone-product",
+ abstract: "Give an iPhone guest's device tree the iPhone's own product description",
+ discussion: """
+ Fills the /product placeholders vphone600 carries (model name, Siri and
+ dictation, button and display geometry), adds Camera Control and the
+ Action Button's geometry, and fills /buttons/function-button_ringeren,
+ all from the iPhone's own tree (DeviceTree.<board>.im4p from its IPSW),
+ in place, preserving the container's compression, manifest and restore
+ info. MobileGestalt reads a placeholder as absent, so without this
+ Settings has no Siri, Camera Control or Action Button. A tree that
+ already has them is left as it is.
+
+ Takes a devicetree.img4 (preferred) or a bare .im4p, and the board's
+ DeviceTree .im4p.
+ """,
+ )
+
+ @Argument(help: "Path to devicetree.img4 or devicetree.im4p", transform: URL.init(fileURLWithPath:))
+ var deviceTree: URL
+
+ @Argument(help: "Path to the iPhone's DeviceTree.<board>.im4p", transform: URL.init(fileURLWithPath:))
+ var board: URL
+
+ @Flag(name: .customLong("dry-run"), help: "Report what would change and exit")
+ var dryRun = false
+
+ func run() throws {
+ try CustomFirmwarePostRestoreDeviceTree.presentPhoneProduct(
+ at: deviceTree,
+ board: board,
+ dryRun: dryRun,
+ verbose: true,
+ )
+ }
+}
+
// MARK: - patch-dt-haptics
struct VPhoneCustomFirmwarePatchHapticsCommand: ParsableCommand {
diff --git a/VPhoneExecutable/VPhoneCommand/VPhoneCommand/Restore/VPhoneRestoreCommand.swift b/VPhoneExecutable/VPhoneCommand/VPhoneCommand/Restore/VPhoneRestoreCommand.swift
index 117d5ff7..da15a4e5 100644
--- a/VPhoneExecutable/VPhoneCommand/VPhoneCommand/Restore/VPhoneRestoreCommand.swift
+++ b/VPhoneExecutable/VPhoneCommand/VPhoneCommand/Restore/VPhoneRestoreCommand.swift
@@ -188,6 +188,7 @@ struct VPhoneCustomFirmwareCommand: ParsableCommand {
VPhoneCustomFirmwarePatchCampoEntitlementsCommand.self,
VPhoneCustomFirmwarePatchPostRestoreDeviceTreeCommand.self,
VPhoneCustomFirmwarePatchBoardAudioCommand.self,
+ VPhoneCustomFirmwarePatchIPhoneProductCommand.self,
VPhoneCustomFirmwarePatchHapticsCommand.self,
VPhoneCustomFirmwarePatchMicrophoneArrayCommand.self,
] + VPhoneCustomFirmwareMachOVerbs.all + VPhoneCustomFirmwareDyldSharedCacheVerbs.all,
diff --git a/VPhoneKit/VPhoneArchiveKit/Transfer/VPhoneBoardDeviceTree.swift b/VPhoneKit/VPhoneArchiveKit/Transfer/VPhoneBoardDeviceTree.swift
index 4ece5eaf..fc321b7c 100644
--- a/VPhoneKit/VPhoneArchiveKit/Transfer/VPhoneBoardDeviceTree.swift
+++ b/VPhoneKit/VPhoneArchiveKit/Transfer/VPhoneBoardDeviceTree.swift
@@ -2,8 +2,9 @@ import Darwin
import Foundation
import VPhoneCoreKit
-/// An iPad guest's own device tree, `DeviceTree.<board>.im4p`, as a VM folder
-/// keeps it and as the IPSW the VM was made from carries it.
+/// A guest's own device tree, `DeviceTree.<board>.im4p`, as a VM folder
+/// keeps it and as the IPSW the VM was made from carries it: an iPad's for its
+/// audio node, an iPhone's (`DeviceTree.d47ap.im4p`) for its product description.
///
/// `fw patch` keeps the tree in the VM's `FirmwareOriginals`, mirrored under
/// the restore tree's name, and the board audio repair that `cfw install` and
@@ -98,7 +99,9 @@ public enum VPhoneBoardDeviceTree {
/// What a run has to do about a VM's board tree.
public enum Need: Equatable {
- /// An iPhone guest, which has no board tree.
+ /// Nothing to do. Every guest has a board tree now — an iPad's carries
+ /// its audio node, an iPhone's its product description — so `need`
+ /// does not answer this; it stays for callers that switch over `Need`.
case none
/// `FirmwareOriginals` already holds one, or several, which staging
/// refuses to choose between.
@@ -118,7 +121,6 @@ public enum VPhoneBoardDeviceTree {
in vm: VPhoneConfinedDirectory,
recorded: VPhoneRestoreInfo.OSVersion?,
) throws -> Need {
- guard device.isPad else { return .none }
guard try kept(in: vm).isEmpty else { return .kept }
var trees: [String] = []
if try vm.isDirectory(originalsName) {
diff --git a/VPhoneKit/VPhoneArchiveKitTests/BoardDeviceTreeTests.swift b/VPhoneKit/VPhoneArchiveKitTests/BoardDeviceTreeTests.swift
index c212c93e..bae8405a 100644
--- a/VPhoneKit/VPhoneArchiveKitTests/BoardDeviceTreeTests.swift
+++ b/VPhoneKit/VPhoneArchiveKitTests/BoardDeviceTreeTests.swift
@@ -93,11 +93,15 @@ struct BoardDeviceTreeTests {
// MARK: - Need
- @Test func `an iPhone guest needs no board tree`() throws {
+ @Test func `an iPhone VM recovers D47AP's tree for its product description`() throws {
let root = try makeRoot()
defer { try? FileManager.default.removeItem(at: root) }
+ // makeVM leaves only the vphone600 trees, which are not a board tree.
let vm = try VPhoneConfinedDirectory(root: makeVM(in: root, trees: ["iPhone17,3_26.6.2_23G90_Restore"]).path)
- #expect(try VPhoneBoardDeviceTree.need(device: .iPhone17_3, in: vm, recorded: nil) == .none)
+ #expect(try VPhoneBoardDeviceTree.need(device: .iPhone17_3, in: vm, recorded: nil)
+ == .recover(.init(device: .iPhone17_3, version: "26.6.2", build: "23G90")))
+ #expect(VPhoneBoardDeviceTree.Firmware(device: .iPhone17_3, version: "26.6.2", build: "23G90").keptPath
+ == "FirmwareOriginals/iPhone17,3_26.6.2_23G90_Restore/Firmware/all_flash/DeviceTree.d47ap.im4p")
}
@Test func `an iPad VM that kept its board tree needs nothing more`() throws {