Run a virtual iPhone on an Apple Silicon Mac.
Swift
Research: DeviceHub on the CoreMotion relay path, and the open's dark frame
Jacky374a7ed388b0
diff --git a/Research/0_binary_patch_comparison.md b/Research/0_binary_patch_comparison.mdindex ff47226f..39a7d0ea 100644--- a/Research/0_binary_patch_comparison.md+++ b/Research/0_binary_patch_comparison.md@@ -5676,4 +5676,4 @@ The host VM view now derives its input geometry from the active Duo viewport (`a> **Duo: folds through SpringBoard, and DeviceHub follows them (2026-10-29 night, PR Lakr233/vphone-cli#774):** no binary change. vphoned's `display.posture` `position` asks SpringBoard to fold itself through `SBSDisplayToolService` (entitlement `com.apple.springboard.sbdisplay.service`) and then sets only the virtual hinge (`Research/vphoned_http_api.md`, "Device pose"). In `system-springboard-cfw-fold_display`, `libvphonefolddisplay.dylib` (1) re-reads the shared panel's owner on `-[SpringBoard displayContentModeCoordinator:handleSwapTransitionFromPrimaryWindowScene:toPrimaryWindowScene:withContinuationLockProvider:]` as well, because a continuous close swaps the primary content as it finishes and the panel kept showing the (black) inner display for 3 s; and (2) in backboardd keeps every clone on the panel: `-[CAWindowServerDisplay addClone:options:]` on the inner render display attaches the clone to display 1 instead, and `removeClone:` removes a clone from its real `cloneMaster` (CoreAnimation aborts otherwise). backboardd moves a mirror (DeviceHub's capture display, AirPlay, recording) to the display with the primary content, so open it carried the inner display upright, while DeviceHub draws an open Duo's stream as the inner panel's native portrait framebuffer and turned it a quarter more; the panel is that framebuffer. Row 26's `libdevicehubfix` gains a `CMDeviceStateManager` stand-in in dtdeviceinfod (`VPCMAngleManager.m`: `isAvailable`, `startUpdatesToQueue:withHandler:`, `stopUpdates`, real `CMDeviceStateEvent`s with A device orientation 1, B the hinge state from `VPhoneHingeLatest`, C 0, delivered at start and on change): Xcode 27.1's DeviceHub (CoreDevicePop plugins) draws a foldable from CoreDevice's device motion state (`streamdevicemotionstate`), which a guest's CoreMotion could not answer ("Pose monitoring failed … 1001"), so the device was always drawn closed. **Validated on iPhone19,4 27.1 (24A94425):** closed shows the folded device with the cover screen, open the opened device with the inner screen upright and filling the panel, following live folds; the VM window is unchanged. **Open:** at book DeviceHub draws the cover (it names the inner panel only from DisplayInfo's `active` integrated display, and reporting the inner display as integrated makes DeviceHub want a per-display stream the guest cannot supply); DeviceHub's own pose controls (vendor-defined HID) are not wired to the guest.-> **Duo: a hardware-shaped inner display, and DeviceHub's controls (2026-10-29 late, PR Lakr233/vphone-cli#774):** supersedes the clone redirect above and closes both of its open items. In `system-springboard-cfw-fold_display`, backboardd's inner `CAWindowServerVirtualDisplay` is now a portrait 2007×2853 framebuffer at 3× (the simulator's inner `CADisplay`), its `extendedProperties` adding `DisplayRotation` 270, `DisplayScale` 3, `ChromeIdentifier` `com.apple.dt.devicekit.chrome.phone14` and `DeviceCornerRadius` 55 beside `DeviceSurfaceType` 2; its one 120 Hz timing is 2007×2853; the digitizer's 270° position turn and both clone hooks (`addClone:options:`, `removeClone:`) are removed; SpringBoard's compositor draws the inner display's frames onto the panel without a turn. SpringBoard lays the inner UI out at interface orientation 90 into that framebuffer. Row 26's `libdevicehubfix`: `dtremotedisplayd` answers `0x18c` (adds `0x100`, video output by display ID: DeviceHub draws each integrated panel from its own stream and shows its pose controls only then); in `dtdeviceinfod`, `CADisplay` `displayType` answers 0 (integrated) and `pointScale` 3 for the display named `VPhone Duo Inner`; the `CMAngleManager` stand-in skips `-[CMAngleManagerInternal stopAngleUpdatesPrivate]` (reached from `-[CMAngleManager dealloc]`, it asserts the real hinge notifier is available and aborted `dtdeviceinfod` whenever DeviceHub reconnected), its `minAngleDegrees`/`maxAngleDegrees` return floats, and its `angleDegrees`, `mechanicalAngleDegrees` and `velocityDegreesPerSeconds` return floats, as `dtdeviceinfod`'s `CMAngle_Bridge` declares them (`Tf`, read from `s0`): doubles read as 0° for every whole angle, which in book (where DeviceHub takes the angle from this stream) drew the device nearly shut and focused the cover; `CMDeviceStateManager`'s A is the device orientation vphoned publishes (`VPhoneDeviceOrientation`). vphoned (no binary change) decodes DeviceHub's vendor-defined HID controls (usage page `0xFF61`, usage `0x5B`, an IOKit binary-serialized dictionary from the DDI's `dtuhidd`) and folds or turns through `display.posture`'s paths. **Validated on iPhone19,4 27.1 (24A94425), sbdisplay-duo:** open and closed from DeviceHub's buttons follow and settle; book at 130° (DeviceHub's preset) draws the inner face upright with a vertical crease, as DeviceHub draws a simulator Duo; open and book fill the panel without black bars; 48 scripted folds over every path came back in the expected orientation; `display.rotation` 0/90/180/270 on the open inner panel turns it and DeviceHub's model with it. **Open:** DeviceHub's orientation picker and its book button were not pressed since the float fix (both run the paths measured above). **With the foldable product-id** (on in standard since Lakr233/vphone-cli#778) both `dtdeviceinfod` stand-ins (`CMAngleManager`, `CMDeviceStateManager`) step aside for CoreMotion's own managers, and vphoned sets the virtual hinge from DeviceHub's controls instead of folding through SpringBoard; not measured with DeviceHub.+> **Duo: a hardware-shaped inner display, and DeviceHub's controls (2026-10-29 late, PR Lakr233/vphone-cli#774):** supersedes the clone redirect above and closes both of its open items. In `system-springboard-cfw-fold_display`, backboardd's inner `CAWindowServerVirtualDisplay` is now a portrait 2007×2853 framebuffer at 3× (the simulator's inner `CADisplay`), its `extendedProperties` adding `DisplayRotation` 270, `DisplayScale` 3, `ChromeIdentifier` `com.apple.dt.devicekit.chrome.phone14` and `DeviceCornerRadius` 55 beside `DeviceSurfaceType` 2; its one 120 Hz timing is 2007×2853; the digitizer's 270° position turn and both clone hooks (`addClone:options:`, `removeClone:`) are removed; SpringBoard's compositor draws the inner display's frames onto the panel without a turn. SpringBoard lays the inner UI out at interface orientation 90 into that framebuffer. Row 26's `libdevicehubfix`: `dtremotedisplayd` answers `0x18c` (adds `0x100`, video output by display ID: DeviceHub draws each integrated panel from its own stream and shows its pose controls only then); in `dtdeviceinfod`, `CADisplay` `displayType` answers 0 (integrated) and `pointScale` 3 for the display named `VPhone Duo Inner`; the `CMAngleManager` stand-in skips `-[CMAngleManagerInternal stopAngleUpdatesPrivate]` (reached from `-[CMAngleManager dealloc]`, it asserts the real hinge notifier is available and aborted `dtdeviceinfod` whenever DeviceHub reconnected), its `minAngleDegrees`/`maxAngleDegrees` return floats, and its `angleDegrees`, `mechanicalAngleDegrees` and `velocityDegreesPerSeconds` return floats, as `dtdeviceinfod`'s `CMAngle_Bridge` declares them (`Tf`, read from `s0`): doubles read as 0° for every whole angle, which in book (where DeviceHub takes the angle from this stream) drew the device nearly shut and focused the cover; `CMDeviceStateManager`'s A is the device orientation vphoned publishes (`VPhoneDeviceOrientation`). vphoned (no binary change) decodes DeviceHub's vendor-defined HID controls (usage page `0xFF61`, usage `0x5B`, an IOKit binary-serialized dictionary from the DDI's `dtuhidd`) and folds or turns through `display.posture`'s paths. **Validated on iPhone19,4 27.1 (24A94425), sbdisplay-duo:** open and closed from DeviceHub's buttons follow and settle; book at 130° (DeviceHub's preset) draws the inner face upright with a vertical crease, as DeviceHub draws a simulator Duo; open and book fill the panel without black bars; 48 scripted folds over every path came back in the expected orientation; `display.rotation` 0/90/180/270 on the open inner panel turns it and DeviceHub's model with it. **Open:** DeviceHub's orientation picker and its book button were not pressed since the float fix (both run the paths measured above). **With the foldable product-id** (on in standard since Lakr233/vphone-cli#778) both `dtdeviceinfod` stand-ins (`CMAngleManager`, `CMDeviceStateManager`) step aside for CoreMotion's own managers, and locationd's relay takes DeviceHub's controls itself (dtuhidd's avpCustom service has the host controls' usage) while vphoned keeps the virtual hinge on each slider value and lights a sleeping cover before an opening run; measured on sbdisplay-duo, one guest fold per DeviceHub click.diff --git a/Research/Guest/devicehub_screen_viewing.md b/Research/Guest/devicehub_screen_viewing.mdindex da4bcf73..ccc44d09 100644--- a/Research/Guest/devicehub_screen_viewing.md+++ b/Research/Guest/devicehub_screen_viewing.md@@ -667,19 +667,32 @@ scripted folds over every path, and the guest's device orientation had beenleft non-portrait by rotation experiments just before, which the swap keeps.With the foldable's product-id (`preboot-cfw-devicetree_foldable_product_id`,-on in standard since Lakr233/vphone-cli#778) CoreMotion has its own angle and device-state-managers, and locationd's device-state relay reads the virtual hinge's host-controls, the same `0xFF61/0x5B` dictionaries DeviceHub sends. Both-`dtdeviceinfod` stand-ins then step aside, and DeviceHub reads the real-managers. vphoned's handling splits the same way: on such a guest a DeviceHub-slider run sets the virtual hinge to where it ended at once (keeping its-orientation) and the picker sets the hinge's orientation, so the hinge,-which resends its stored values every 5 s, agrees with DeviceHub and-SpringBoard folds from the hinge; the SpringBoard display-swap path above is-for guests without the relay. The provider check keeps vphoned from-following the hinge's own dictionaries, which carry none. The relay path was-not measured with DeviceHub: the test VM above predates the product-id-patch.+on in standard since Lakr233/vphone-cli#778) CoreMotion has its own angle and+device-state managers, and locationd's device-state relay reads the host+controls (`0xFF61/0x5B`). Both `dtdeviceinfod` stand-ins then step aside, and+DeviceHub reads the real managers. dtuhidd's "CoreDevice avpCustom" service+carries the same usage, so the relay takes DeviceHub's controls itself, as on+Apple's VM host, and the guest follows the slider as it moves. The virtual+hinge, which resends its stored values every 5 s for a restarted locationd,+takes each slider value too: while it kept the old angle until a debounced+fold, a resend landing inside a run sent the fold back. An opening run from+closed lights the screen first, as `display.posture` does; with a sleeping+cover SpringBoard's pose provider commits no moving pose and the inner+display stayed black. The picker sets the hinge's orientation. The provider+check keeps vphoned from following the hinge's own dictionaries, which carry+none. The SpringBoard display-swap path above is for guests without the+relay; there vphoned also writes each slider value as the hinge sample the+stand-ins read, without moving the hinge, because a reading left at the old+pose until the fold pulled DeviceHub's model back there (closed, open,+closed).++Measured on sbdisplay-duo after the product-id patch (2026-10-30): every+DeviceHub click folds the guest once, following the slider. Opening out of+closed shows about 0.12 s of black on the shared panel: SpringBoard fades+the cover out to black and the inner display in from black, two screens on+hardware. Handing the panel to the inner display at the start of the fold+only showed its black longer (0.2 s); waiting for a fresh page of the inner+display did not shorten it.## Other open itemsdiff --git a/Research/vphoned_http_api.md b/Research/vphoned_http_api.mdindex 2c0586d7..7483bcfd 100644--- a/Research/vphoned_http_api.md+++ b/Research/vphoned_http_api.md@@ -1293,7 +1293,7 @@ fold does not run: Xcode's DeviceHub reads it and, with the old anglelingering through the sweep, sent its slider back there. DeviceHub's own foldand orientation controls arrive in the guest as vendor-defined HID events,and vphoned runs them through this request on an iPhone Duo; with the relay-a DeviceHub fold sets the hinge at once and keeps its orientation (see+locationd takes them itself and the virtual hinge follows each slider value (see`Guest/devicehub_screen_viewing.md`, "iPhone Duo: the fold").| Param | Values |