Run a virtual iPhone on an Apple Silicon Mac.
Swift
Merge branch 'pr-802-ios16' into merge-pr-802
Jackyfaafe5080ec5
diff --cc Research/0_binary_patch_comparison.mdindex 38ed9775,96427ec2..ca95d711--- a/Research/0_binary_patch_comparison.md+++ b/Research/0_binary_patch_comparison.md@@@ -6086,82 -5994,55 +6086,135 @@@ layout the completion does not produceservice. With primitive restart no longer sent, an OpenGL ES 2 strip that drawsvertex 65535 is cut there.+## Always On display (2026-11-02)++No new patch identifier and no new bytes in an Apple binary.+`preboot-cfw-devicetree_iphone_product` (the iPhone product repair, which `cfw+install` and `cfw update-environment` run) also adds+`/product/vphone-always-on-display = 1` when the board's own tree has+`/arm-io/disp0` `always-on-time`. MobileGestalt reads nothing by that name.+vphoned reads it at startup and answers DeviceSupportsAlwaysOnDisplay+(`2OOJf1VhaM7NxfRok3HbWQ`) and DeviceSupportsAlwaysOnTime+(`j8/Omm6s1lsmTDFsXjsBfA`) yes in the MobileGestalt cache's `CacheExtra`+(`GuestMobileGestaltAnswers`, `GuestMobileGestaltCache.presentAlwaysOnDisplayOnStartup`).+Settings then offers Always On Display and SpringBoard dims the Lock Screen+instead of turning it off. Issue #650.++**Why not the tree.** libMobileGestalt (24A446) answers the three questions from+one node:++| Answer | Source |+| --- | --- |+| DeviceSupportsAlwaysOnTime | `IODeviceTree:/arm-io/disp0` `always-on-time` |+| DeviceSupportsAlwaysOnDisplay | AlwaysOnTime, else `disp0` `always-on-device` |+| DeviceSupportsAlwaysOnDisplayFlipbook | AlwaysOnTime, else `disp0` `always-on-device-flipbook` |++Settings shows the row only with AlwaysOnTime (DisplayAndBrightnessSettings+asks for it; with AlwaysOnDisplay alone there is no row, measured). The board's+`always-on-time` therefore answers the flipbook yes too. CoreBrightness reads it+in backboardd (`-[CBAODState initializeAODSupportConfiguration]`) and drives the+flipbook through the panel controller (DCP), which the paravirtual panel does+not have. An iPhone18,1 27.0.1 guest with an `/arm-io/disp0` stub carrying the+board's `always-on-time` lost backboardd at every boot (`rebooting due to+critical process crashes: backboardd`) and launchd restarted it into the device+recovery environment. A second guest made without the stub booted, and+answering all three yes in its `CacheExtra` crashed it the same way. Without+the flipbook, `-[BLSHBacklightOSInterfaceProvider initWithPlatformProvider:]`+gives SpringBoard BacklightServices' own renderer (`BLSHPseudoFlipbook`), which+works on a guest. Answering the first two in the cache leaves the flipbook+unanswered there and so no. Keeping `always-on-time` in the tree and answering+the flipbook no in the cache would not do: the tree decides whenever the cache+is missing, at a guest's first boot and after every drop, and one boot with the+flipbook is enough to lose backboardd.++A guest that went through that crash loop kept losing backboardd after the+answers and the whole cache were removed; the cause was not found. Do not+test the flipbook answer on a VM you want to keep.++**When the answers land.** libMobileGestalt writes the cache when a process+first asks after it is gone: at a guest's first boot, and after vphoned drops a+cache older than the tree. vphoned waits for it (up to 10 minutes), adds the+answers once, and sets `mobilegestalt_restart_pending`; the cache keeps them+across boots, and a rebuilt cache gets them again at the next start. A new+machine's creation boots more than once, so it is offered from its first use.++**The window.** On a foldable guest the VM window covers the panel while+`display.orientation` says `screen_off`, so a waking panel does not show its+frame from before (`bde6440c`). SpringBoard posts `hasBlankedScreen` for the+always-on Lock Screen too, so the window covered it. FoldDisplay now publishes+whether the panel went off since SpringBoard last lit the screen+(`com.vphone.folddisplay.panel-dark`: 1 stayed on, 2 went off), and+`screen_off` is SpringBoard's blank and that.++**Verified.**+- New machine: iPhone18,1 27.0.1, cloudOS 26.4, bundle from this branch on+ 2.14.2. `cfw install` logged `product/vphone-always-on-display: 'absent' ->+ '01000000'`; with nothing done by hand, the cache had both answers yes and the+ flipbook unanswered, Settings showed Always On Display On, and the locked+ screen stayed dimmed with the clock moving (9:34 to 9:36). No backboardd crash.+- Existing machine: iPhone19,4 27.1 (24A94425), `vm set-bundle+ --update-environment`. The repair added the marker; the next boot dropped the+ cache, the rebuilt one got the answers and the restart was reported pending;+ after the restart the Lock Screen went always-on, the panel state stayed 1,+ `screen_off` false, and the VM window showed it. With Always On Display+ switched off in Settings the panel went off (state 2), `screen_off` was true+ and the window covered it, then uncovered it on wake.++**Not covered.** Other iPhones with the display were not run. Apple Watch:+N227b's tree has `always-on-time` too, but on a Watch7,18 26.4 guest the same two+answers left the screen fully dark after the timeout (Carousel decides; not+investigated), so the repair stays iPhone-only. No iPad board has the property.+The VM keeps rendering while dimmed: there is no low-power display.+++ ## Experimental iOS 16.6.1 desktop bring-up++ Measured pairing: iPhone15,2 (iPhone 14 Pro), iOS 16.6.1/20G81 userland,+ cloudOS 26.1/23B85 vphone600 boot chain. All additions below are manual opt-ins;+ shipped presets and the no-plan path leave them disabled. See+ `Research/Guest/ios16_bringup.md` for procedure, evidence and limitations.++ - `system-launchd-exp-ios16_mach_ports` bridges the old out-of-line self-task+ Mach-port API to the newer fixed-three-port RPCs in the native launch hooks.+ `dyld-exp-ios16_mach_ports_lookup` updates the old libxpc client's pre-constructor+ lookup through a symbol-derived, bounded cache patch with undo capture.+ - `system-backboard-exp-ios16_migration` skips the fresh lab's measured migration+ wait and releases its local shell sentinel/PreBoard re-block. It does not+ migrate existing user data or persist completion. `system-springboard-exp-ios16_desktop`+ avoids unavailable startup media, widget and flashlight services and uses the+ native local setup-state setter. These services remain unavailable.+ - `system-systemhook-exp-ios16_surface` converts capability replies 0x28 ->+ 0x18 and allocation/lookup replies 0xC68 -> 0xA68, including narrowed fields+ and the changed plane stride. Offline metadata derives the framework-private+ transport stub, verifies its instruction pattern and records its Mach-O UUID.+ The runtime detour checks UUID/expected bytes, suspends peer threads, uses+ private COW memory without writable executable pages, and restores protection.+ - `system-systemhook-exp-ios16_framebuffer` translates the measured old 0x46C+ SwapEnd payload into the modern 0x560 layout. It inserts the new event/port+ slots, retaining frame token, surfaces, rectangles and measured flags. Native+ create/lock/write/read/unlock and surface lookup probes pass; submitted color+ bars and the real SpringBoard desktop are visible.+ - `preboot-exp-ios16_ephemeral_storage` changes only the existing chosen/product+ ephemeral-storage fields, preserving their widths and tree size. Native+ `hw.ephemeral_storage` and `os_variant_uses_ephemeral_storage` then report 1;+ PreBoard no longer owns the shell. Restore pre-ephemeral snapshots to undo+ guest data effects; restoring device-tree bits alone is insufficient.+ - `system-vphoned-exp-ios16_touchscreen` registers a built-in HID touchscreen+ only when none exists. With desktop startup selected, native backlight-state+ changes also publish the legacy HID factor. Real mouse swipes and clicks now+ reach the guest rather than being dropped as missing-digitizer/display-off.+ - `system-springboard-exp-ios16_keybagless_ui` is restricted to a fresh ephemeral+ lab. The root daemon requires explicit markers and a strict session/persona+ keybag-directory allowlist before publishing a single-link, root-owned,+ magic-checked lease. Three signature-checked UI getters honor that lease for+ at most three seconds and otherwise forward to native. MKB/AKS and encrypted+ data remain unchanged; this is not working credentials or protected storage.+ - The existing battery helper weak-imports the unavailable newer precise-power+ API and falls back to its existing ByType API. This resolves the measured+ Preferences pre-main dyld crash without synthesizing an IOKit export.++ The real guest displays Home Screen, accepts mouse input and opens Settings >+ General > About (16.6.1, iPhone 14 Pro, 64 GB). Initial About lookup can wait for+ IOKit/SystemConfiguration quiescence; a proposed fallback was never deployed and+ is excluded. Wallpaper preview fails without Metal; its cancelled, unvalidated+ prototype is excluded as well. No general iOS 16/15, Metal, full audio, camera,+ networking or persistent protected-data compatibility is claimed.diff --cc VPhoneExecutable/VPhoneCommand/VPhoneCommand/Firmware/VPhoneCustomFirmwareDyldSharedCacheVerbsCommand.swiftindex 6e6736ff,593d2983..89372a2e--- a/VPhoneExecutable/VPhoneCommand/VPhoneCommand/Firmware/VPhoneCustomFirmwareDyldSharedCacheVerbsCommand.swift+++ b/VPhoneExecutable/VPhoneCommand/VPhoneCommand/Firmware/VPhoneCustomFirmwareDyldSharedCacheVerbsCommand.swift@@@ -90,9 -79,11 +90,12 @@@ enum VPhoneCustomFirmwareDyldSharedCachVPhoneCustomFirmwarePatchArm64eX1BootstrapCacheCommand.self,VPhoneCustomFirmwarePatchArm64eX1CacheCommand.self,VPhoneCustomFirmwareDyldSharedCacheRevertCommand.self,+ VPhoneCustomFirmwareDyldSharedCacheUndoWordsCommand.self,VPhoneCustomFirmwarePatchHypervisorVirtualMachineDyldSharedCacheCommand.self,VPhoneCustomFirmwarePatchIOMFBSwapEndCommand.self,+ VPhoneCustomFirmwarePatchIOS16MachPortsCommand.self,+ VPhoneCustomFirmwarePrepareIOS16SurfaceCommand.self,+ VPhoneCustomFirmwarePrepareIOS16FramebufferCommand.self,VPhoneCustomFirmwarePatchIOMFBForceKernCommand.self,VPhoneCustomFirmwarePatchDyldSharedCacheMaxSlideCommand.self,VPhoneCustomFirmwarePatchLSDEmbeddedRegCommand.self,