Skip to content

Run a virtual iPhone on an Apple Silicon Mac.

Swift

Read Developer Mode off the device.info path

Lakr2331eb18f0f84af
diff --git a/Research/vphoned_http_api.md b/Research/vphoned_http_api.md
index 6a730c27..12d37194 100644
--- a/Research/vphoned_http_api.md
+++ b/Research/vphoned_http_api.md
@@ -496,7 +496,7 @@ request carries `"force": true`.
| Area | Methods |
| --- | --- |
-| Device | `device.snapshot`, `device.info` (snapshot plus network, screen, rotation, brightness, volume, low power, Developer Mode, agent, `device_name` `{name, own_name}`: the pinned name and the guest's own ComputerName), `device.screen`, `device.network`, `device.displays` (a flat IOService probe of every display-ish object with its small properties — what the display stack bound; built for the foldable display work: `AppleParavirtGPU` `DisplayPortCount`, and each `AppleParavirtDisplay` width/height/`primary`), `device.ioreg {plane}`, `device.environment`, `device.basebin {archive?}` |
+| Device | `device.snapshot`, `device.info` (snapshot plus network, screen, rotation, brightness, volume, low power, Developer Mode (the last answer amfid gave, refreshed in the background every 30 s; `{}` until it answers, and always on the tvOS 26.6 and HomePod 27.0 guests checked, whose amfid does not; `developer_mode.status` asks amfid directly and waits up to 10 s), agent, `device_name` `{name, own_name}`: the pinned name and the guest's own ComputerName), `device.screen`, `device.network`, `device.displays` (a flat IOService probe of every display-ish object with its small properties — what the display stack bound; built for the foldable display work: `AppleParavirtGPU` `DisplayPortCount`, and each `AppleParavirtDisplay` width/height/`primary`), `device.ioreg {plane}`, `device.environment`, `device.basebin {archive?}` |
| Display, audio | `display.pose` (read-only SpringBoard pose snapshot: orientation, device_orientation, hinge, tabletop; reports unavailable for an unsupported ABI), `display.modes` (read-only CoreAnimation display bounds, native size, current/available modes, and virtual-mode selector availability; availability does not prove a mode change is supported), `display.brightness {value?}`, `display.rotation {orientation?}`, `display.posture {hinge, orientation?, tabletop?}` (a foldable guest's pose through SpringBoard's test-automation override, see below; capability `device_pose`), `display.orientation` (`{degrees, source, fold_angle?, screen_off?}`: SpringBoard's interface orientation without a screen capture, for polling; `degrees` is null while SpringBoard has no answer; on a foldable `fold_angle` is the virtual hinge's angle, so a host can follow folds it did not ask for, and `screen_off` whether the panel is dark, so a host can keep the panel's frame from before off its window as it comes on (SpringBoard has the screen off and FoldDisplay saw the panel go off since it was last lit; the always-on Lock Screen keeps the panel on and is not dark); capability `display_orientation`), `display.rotation_lock {locked}`, `display.auto_lock` (`{auto_lock_seconds, never, lock_screen_minimum_seconds}`), `display.auto_lock.set {seconds}` (writes the mobile UserSettings input through cfprefsd, posts profiled's effective-settings notification, and returns an immediate readback; the caller must verify the effective value), `screen.unlock {passcode?, timeout?}` (`{locked, screen_off, was_locked, was_screen_off}`: the display on and the Lock Screen passed, see below; capability `screen_unlock`), `audio.volume {value?, category?}`, `audio.state` |
| Input | `input.touch`, `input.hid {page, usage, down?, long_press?}`, `input.button {name}`, `input.key {name}`, `input.type {text, delay_ms?}`, `input.paste {text}`, `input.tap`, `input.double_tap`, `input.long_press`, `input.swipe`, `input.drag {points}`, `input.touch_sequence {events}` — gesture coordinates are screen points; `input.pointer {x, y, seq?, buttons?}`, `input.scroll {phase, dx?, dy?, x?, y?}` (capabilities `pointer_scroll` and `pointer_buttons`, see below) |
| UI | `ui.tree` (alias `accessibility.tree`), `ui.element_at`, `ui.tap_element`, `ui.wait`, `ui.wait_gone`, `ui.ocr {languages?, min_confidence?}`, `ui.describe`, `screen.screenshot` |
diff --git a/VPhoneDaemon/Daemon/GuestAPI+Device.swift b/VPhoneDaemon/Daemon/GuestAPI+Device.swift
index 2b7f0de4..7fc09750 100644
--- a/VPhoneDaemon/Daemon/GuestAPI+Device.swift
+++ b/VPhoneDaemon/Daemon/GuestAPI+Device.swift
@@ -3,6 +3,57 @@ import IcliKit
import IcliSystem
import VphonedNative
+// MARK: - Developer Mode Snapshot
+
+/// The Developer Mode status `device.info` reports, read off the request path.
+/// amfid answers the status request at once on an iPhone, but not on the tvOS
+/// 26.6 and HomePod 27.0 guests checked (2026-11-03), where each query waits
+/// its full 10 s (`icli_amfi_developer_mode_json`); `device.info` paid that on
+/// every call, 10.03 s instead of 0.03 s.
+/// The status is read once at startup and again in the background when it is
+/// older than ``maximumAge``, one query at a time; `device.info` returns the
+/// last answer, empty until there is one or when amfid never answers.
+/// `developer_mode.status` still asks amfid directly.
+final class GuestDeveloperModeSnapshot: @unchecked Sendable {
+ static let shared = GuestDeveloperModeSnapshot()
+ static let maximumAge: TimeInterval = 30
+
+ private let lock = NSLock()
+ private var status: [String: Any] = [:]
+ private var readAt: Date?
+ private var reading = false
+
+ func startOnStartup() {
+ refreshIfStale()
+ }
+
+ func current() -> [String: Any] {
+ refreshIfStale()
+ lock.lock()
+ defer { lock.unlock() }
+ return status
+ }
+
+ private func refreshIfStale() {
+ lock.lock()
+ let stale = readAt.map { Date().timeIntervalSince($0) > Self.maximumAge } ?? true
+ guard stale, !reading else {
+ lock.unlock()
+ return
+ }
+ reading = true
+ lock.unlock()
+ DispatchQueue.global(qos: .utility).async {
+ let answer = (try? developerModeStatus()) ?? [:]
+ self.lock.lock()
+ self.status = answer
+ self.readAt = Date()
+ self.reading = false
+ self.lock.unlock()
+ }
+ }
+}
+
// MARK: - Device, Display, Audio, Network
extension GuestAPI {
@@ -19,7 +70,7 @@ extension GuestAPI {
info["brightness"] = brightnessState()
info["volume"] = volume()
info["low_power_mode"] = (try? lowPowerMode()) ?? [:]
- info["developer_mode"] = (try? developerModeStatus()) ?? [:]
+ info["developer_mode"] = GuestDeveloperModeSnapshot.shared.current()
info["agent"] = ["binary_hash": binaryHash, "pid": getpid()]
info["device_name"] = deviceNameInfo()
return info
diff --git a/VPhoneDaemon/Daemon/main.swift b/VPhoneDaemon/Daemon/main.swift
index 452655cf..3bbe72ef 100644
--- a/VPhoneDaemon/Daemon/main.swift
+++ b/VPhoneDaemon/Daemon/main.swift
@@ -46,6 +46,7 @@ GuestAPI.restoreUSBSerialOnStartup()
GuestStaticNames.shared.restoreOnStartup()
// locationd can deadlock as it starts; this restarts it.
GuestLocationdWatchdog.shared.startOnStartup()
+GuestDeveloperModeSnapshot.shared.startOnStartup()
let group = MultiThreadedEventLoopGroup(numberOfThreads: 2)
let filePool = NIOThreadPool(numberOfThreads: 2)