Run a virtual iPhone on an Apple Silicon Mac.
Swift
Merge branch 'pr-779' into merge-pr-779
Jackye52e757df988
diff --cc Research/0_binary_patch_comparison.mdindex ca95d711,41cb4f10..9f178ffe--- a/Research/0_binary_patch_comparison.md+++ b/Research/0_binary_patch_comparison.md@@@ -5944,277 -5613,22 +5944,297 @@@ The host VM view now derives its input> **Duo display: flicker, capture and rotation (2026-10-29):** in `system-springboard-cfw-fold_display`, the compositor is now a layer at the top of Main's `UIRootSceneWindow` (points) instead of a display-level `CAContext` (pixels), its hosts sync from a main run loop observer before Core Animation's commit and change only when a value changes, and its per-frame damage alternates two clear colors. New SpringBoard hook: `+[CMMagicPoseManager orientationForMagicPose:deviceSurface:]` answers with `+[CMDeviceStateEvent propertyAForConfigType:propertyA:propertyB:propertyC:]` directly, because the guest has no `CMMagicPoseManager` shared manager and every panel read ambiguous, so neither panel rotated. vphoned's `display.rotation` on a foldable sets the pose orientation for the lit panel. Details in `Research/Guest/iphone_duo_bringup.md`.+ > **Local Duo inner-screen corner diagnostic (2026-10-29):** The existing+ > FoldDisplay guest component checks UIScreen corner getter ABIs and, only+ > for its recorded inner display identity, fills a zero radius from the main+ > screen's native metric. Nonzero native radii and other displays pass through.+ > This is a source-level experiment in the existing component, with no new+ > firmware patch or preset. See the expanded Now Playing entry in+ > `Research/Guest/iphone_duo_bringup.md` for evidence and deployment outcome.++ > **Local optional external monitor prototype (2026-10-29):** Existing Duo+ > FoldDisplay injection gains an explicit, off-at-boot 1080p/4K virtual monitor+ > and a named external-display adapter. Existing inner-only policies now match+ > the recorded inner identity. Guest RPC captures the external display itself+ > for a separate host window. No new binary patch, preset or hardware graphics+ > port is introduced. See `Research/Guest/virtual_external_display.md` for+ > implementation boundaries and runtime results.+ > Final implementation prepares two disabled render slots before SpringBoard+ > discovery and refreshes their existing CADisplay objects after configuration.+ > Native Broadcasts output, live 1080p-to-4K switching, and disconnect/reconnect+ > passed on `2.14.0-local.b0297e92`; boot remains disconnected by default.+++> **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 `0x184` (adds `0x100`, drops system audio `0x8`, 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. **2026-10-30:** in `system-springboard-cfw-fold_display` FoldDisplay turns SpringBoard's fold fade to black off for folds made awake (`SBDeviceContinuousFoldInteractionSettings.fadeToBlackEnabled`, via `+[SBDeviceContinuousFoldInteractionDomain rootSettings]`; kept for a fold that starts with the panel off or just lit, where it hides the inner content the effect carries over) and hands the shared panel to the inner display inside the primary-swap callback, so opening out of closed shows a few dark frames instead of 0.12 to 0.2 s of black (`Research/Guest/iphone_duo_bringup.md`, "the fold's fade to black on one panel").++## HomeView shell Metal compiler lookup (2026-10-30)++The existing `system-breadboard-exp-mach_lookup` patch now also appends exactly+`com.apple.MTLCompilerService` to BreadBoard's global Mach lookup exception list.+Campo's shared backboard/frontboard list is unchanged. This retains the native+`temporary-sandbox` profile, every donor entitlement, and the existing executable+backup/deselection path; no kernel or shader binary is changed.++Live HomeView 27.2 / 24V514 on cloudOS 26.4 repeatedly stalled BreadBoard during+app/Home gestures in RenderBox → Metal function specialization → compiler queue+wait. A unique-source public Metal probe, signed with the installed BreadBoard's+exact entitlements and run as mobile501, failed with MTLLibraryErrorDomain3,+lookup error159, `Sandbox restriction`. Earlier identical-source probes hit+cached libraries and concealed this denial. Adding only the compiler lookup to+that probe's entitlements made a fresh unique library compile in 0.05217s and+specialize in 0.001099s. Cache-path sandbox-extension warnings remained nonfatal;+no file permission exceptions were added. Raw evidence and variant entitlements+are in `.build/homeview-distance-runtime/public-metal-*`; native consumer tracing+is in `Research/Firmware/homeview_distance_consumers.md`. Full shell retest after+deployment remains pending at this entry's creation.++Deployment retest: Xcode built `VPhone` successfully (60.743s,+`BuildProject-Log-20261030-211312.txt`); Launchpad installed+`2.15.0-local.0cfd6bd1` with policy/preflight passing and updated HomeView's host+and guest environment bindings. The installed BreadBoard entitlements differ+from b53c29c8 only by the compiler lookup. The formerly hanging bottom Home+gesture now renders the glass app drawer, native environment fetch stays fast,+and Timers visibly launches to its native preset grid. Screenshot evidence is+`0cfd-after-home.jpg` and `0cfd-timers-settled.jpg` under the runtime directory.+The entitlement merge suite passed all7 tests, including the new HomeView+sandbox-preservation/Campo-isolation regression. Native distance ABI checks+also passed. No extra patch selection or boot-chain update was needed.++Final rollout: **2.15.0-local.e2850909** adds the native app-latching explanation+to Controls, preserving the same validated compiler lookup repair. Host and+guest environment bindings updated successfully, vphoned answered in6seconds,+and an acknowledged environment reset plus independent fetch returned+Automatic/detail2/override=false/style0/backlight2. The native clock is visibly+awake. Far/Near/Far actual FrontBoard settings and UIKit scene/view traits were+verified0→2→0 in the temporary observer; the Far reduction flushes when the app+backgrounds, matching Charcuterie's explicit latching policy. No ActivityKit+permission expansion is part of this patch or the installed bundle. All guest+test timers, activities, apps, helpers and overrides were cleaned up.+++## Experimental iPhone 15 / iOS 17.7 desktop bring-up++See `Research/Guest/ios17_bringup.md`. The existing seputil data patch now+accepts a Capstone-decoded ADR reference as well as ADRP+ADD. The measured+21H16 input has ADR x2 at 0x10000B85C referencing the complete format literal+at 0x10001D3B3; no UUID or instruction replacement is hardcoded. The existing+SwapEnd patch resolves size 0x508 and emits the cloudOS 26.1 size 0x560.+Existing thread-guard and paravirtual-user-client gates include 17. The iOS 18+BSD-only skywalk boot argument also covers 17. New opt-in declaration+`system-springboard-exp-ios17_desktop` installs a SpringBoard-only, iOS-17-only+library. It skips synchronous initial widget discovery and unavailable+AVFlashlight construction; no shared-cache code is modified for these hooks.+Selection restores SpringBoard and removes the library on opt-out; a restart+restores native methods.+No native iOS 17 kernel, Metal driver, camera or networking support is claimed.++## OpenGL ES in guests (2026-11-02)++Upstream issue Lakr233/vphone-cli#793: every `-[EAGLContext initWithAPI:]`+returned nil in a guest while Metal worked, so apps that need OpenGL ES refused+to start or aborted (WeChat's `OpenGLContextManager: root_ctx_ != nullptr`).+Three pieces make OpenGL ES render, each needed by the next.++**1. Kernel: the renderer name (JB-36, `kernel-cfw-paravirt_gles_renderer`).**+`gfxInitializeLibrary` (`libGFXShared`) loads+`/System/Library/Extensions/<name>.bundle` from the `IOAcceleratorES` service's+`IOGLESBundleName` / `IOGLESMetalBundleName`; `AppleParavirtGPU` had neither.+AGX personalities carry `IOGLESBundleName = AppleMetalGLRenderer`, and the+patch adds that key after `IOClass` in the `AppleParavirtGPUARM` personality in+`__PRELINK_INFO`. On 23E5207q the record is 609 bytes at file offset+`0x256824C`: the key's two lines, and the next lines' indentation shortened by+the same 76 bytes, so nothing else in the kernelcache moves. The patched XML must+parse to the original plus that key. Contexts are created from here on, but every+draw failed in the next two pieces.++**2. Compiler plugin: GLES modules (no binary patch; `VPhoneGuestComponents/GraphicLoader`).**+AppleMetalGLRenderer hands the backend AIR whose `air.language_version` is+`"OpenGL ES GLSL" 1.0.0`, with no `air.version` and with the argument metadata+the AGX backend reads: a buffer stops after `"air.read"`, most nodes have no+`air.arg_type_name` or `air.arg_name`. `MTLDowngradeAIRModule`,+`MetalModule::materialize` and `air::Reflection::create` index those+operands without checks, so `MTLCompilerService` crashed (`NamedMDNode::getOperand`,+then `MDString::getString`) on every GLES shader. The plugin now completes such a+module before the downgrade: every node gets the fields the Metal front end+writes after its own, in its order (`air.address_space`, `air.arg_type_size`,+`air.arg_type_align_size` for a buffer; `air.arg_type_name`; `air.arg_name`+except on a render target), derived from the entry point's parameter and return+types, and the module gets `!air.version = !{i32 2, i32 7, i32 0}`, the version+the guest's front end (metalfe-32023.921) writes and the plugin's target+(the value MTLCompilerService passes the plugin as `targetTriple` is a packed+version tuple, `0x700000002`). The guest's libLLVM C API cannot replace a+node's operand, so the module is printed, its argument lines extended, and the+text parsed back in the same context. `make -C VPhoneGuestComponents test-gles-air`+runs three guest-captured modules through the plugin on the host (same+GPUCompiler 32023) and into the host's Metal.++The plugin comes from the bundle (`guest-resources`), and an installed guest+used to keep the one it was restored with. `cfw update-environment` (and `cfw+install` without a restore tree) now replaces it when the bundle's differs and+reseals the GPU bundle (`[+] system-extensions-boot-gpu_bundle: compiler plugin+updated from this bundle`); tvOS guests, whose plugin is retargeted, are left alone.++**3. Driver: primitive restart (guest row 30, `system-paravirt_gpu-cfw-primitive_restart`).**+With shaders compiling, the host's `ParavirtualizedGraphicsGPUTask` threw+`NSGenericException: Invalid viewport index` replaying each GL command buffer+(caught with lldb on the task; Debugging Restrictions are off on this host). The+throwing handler is command 0x91, `setPrimitiveRestartEnabled:index:`, which+checks the index against `[device maxViewportCount]`; GL sends the restart index+itself, `0xffffffff`. The guest saw a GPU hang and restart. The serialiser method+now returns at entry: `0x174b4` `7f2303d5` `pacibsp` -> `c0035fd6` `ret`. Patched+alone, 23E5207q hashes to `1992ab68…24d3dc`; with the heap index patch, as the+installer stages both, `870ba415…3996d8`.++**Verified** on `glestest-iphone` (iPhone17,3 iOS 27.0.1, cloudOS 26.4, host+macOS 27.2, bundle built from this branch; plugin and driver delivered by+`vm set-bundle --update-environment`, kernel by the restore): EAGL APIs 1-3 OK,+`GL_RENDERER` "Apple Paravirtual device GPU", `GL_VERSION` "OpenGL ES 3.0 Metal -+105"; as root and as mobile, a shader draw reads back exactly; an ES 2 program+with a 2x2 texture, `mat4`/`float`/`vec4` uniforms and varyings reads back all four+texels; an ES 3 program with a uniform block, a flat `int` varying, `texelFetch`+and a `GL_PRIMITIVE_RESTART_FIXED_INDEX` strip split at `0xFFFF` reads back right+with the gap clear; an app drawing through `CAEAGLLayer` presented 1560 frames+with a rotating triangle on screen. No `MTLCompilerService` crash and no GPU+restart in those runs.++**Not covered.** Real apps (WeChat, the #463 game) were not run. The metadata+completion covers the argument kinds the probes produced (buffers, the vertex+fetch buffer, vertex id, textures, samplers, fragment inputs, position and+vertex outputs, render targets); an argument kind the reflection reads in a+layout the completion does not produce could still crash the compiler+service. With primitive restart no longer sent, an OpenGL ES 2 strip that draws+vertex 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 Research/Guest/iphone_duo_bringup.mdindex 370e1f6c,dccbda48..3ff2b327--- a/Research/Guest/iphone_duo_bringup.md+++ b/Research/Guest/iphone_duo_bringup.md@@@ -4887,591 -4836,33 +4887,621 @@@ Window captures (ScreenCaptureKit) cannis natively 120, measures the same 40-55 changes per second as the innerdisplay, because the host composites the window at its own rate. Use guestdisplay links, or the host's `lastSubmittedTime` poller from the vGPU notes.+ ### Expanded Now Playing corners (local diagnostic, 2026-10-29)++ On iPhone-Duo (27.1 24A94425), the unfolded expanded Now Playing panel+ provided by Broadcasts has a rectangular outer black background while its+ artwork remains rounded. A read-only UIKit probe reports 59 points for the+ cover's `_displayCornerRadius` and `_displayCornerRadiusIgnoringZoom`.+ Constructing a private, unregistered UIScreen from the inner CADisplay's+ FBSDisplayConfiguration reports zero for both getters and `_isEmbeddedScreen`+ false. This daemon-side object does not include SpringBoard's display adapter,+ so it establishes the native virtual-display default, not the exact live+ SpringBoard screen state.++ A local FoldDisplayAdapter experiment intercepts those two getter selectors+ (ABI checked as d16@0:8), matches only the recorded inner display identity,+ and substitutes the main screen's original native value only when the inner+ value is zero. A nonzero native inner value and every other display pass+ through. Limited logging records native/main/effective values in SpringBoard.+ No device-tree, MobileGestalt, firmware or host security setting is changed.+ The original source is saved outside the source tree as+ `.vphone-setup/FoldDisplayAdapter.before-corners.m`; previous environment+ bundle 2.14.0-local.e1ece920 remains available for rollback.+ Validation and visual outcome are recorded below after deployment.++ **Validated:** Release VPhone build passed without warnings/errors. Installed+ local bundle `2.14.0-local.232df3b7`, updated the existing guest environment,+ and cleanly restarted (vphoned connected in four seconds). Actual SpringBoard+ logs now confirm `_displayCornerRadius native=0.00 main=59.00 effective=59.00`+ for the inner screen, so the earlier daemon probe matches the live symptom.+ The user reproduced the Broadcasts panel and confirmed “that's fixed now.”+ Previous bundle retained for rollback; no additional change is pending.++## 2026-10-29 night: folds go through SpringBoard's display tool service++Xcode 27's iPhone Duo simulator has no hinge: CoreSimulator gives it two real+displays (screenID 1 cover, 3 inner), and SpringBoard folds itself through+its display tool service, the one Apple's internal `sbdisplaytool` / `suiatool+swap` drives. The device SpringBoard has the same service+(`com.apple.springboard.sbdisplay` in `BSServiceDomains` under+`com.apple.frontboard`), so `display.posture`'s `position` now uses it instead+of the test-automation override plus a virtual hinge sweep. Measured on a+test VM (iPhone19,4 27.1, 24A94425) with the two-display path:++- `-[SBSDisplayToolService swapDisplayWithSettings:completion:]` takes+ `{q; d duration; q deviceOrientation; q profileOverride; B wait; q+ targetMode; d targetHingePosition; d}` (`v88@0:8{?=qdqqBqdd}16@?80`).+ Target mode 1 sweeps to an absolute position (0 closed, 1 open flat);+ duration < 0 is the per-direction default (0.391 s open, 0.420 s close);+ profile 1 fade, 2 continuous (`.continuousLive`), 0 SpringBoard's own.+ The server checks `com.apple.springboard.sbdisplay.service` (read from+ the simulator SpringBoard's swap handler); without it SpringBoard logs+ "Insufficient authorization" and never answers. The completion block's+ arguments are not objects: the client forwards a raw register, and+ retaining it as an `NSError` PAC-faults.+- SpringBoard takes a 10 s test lock, sweeps its own pose (`absoluteSweeping+ 0.0 -> 180.0 over 0.39s`), resolves `FullyClosed→FoldingDual` (or back) as+ the sweep crosses the boundary, and answers after `completed` / `idle`,+ about 1.2–1.6 s after the request. Book (100°) from closed swaps to the+ inner panel; book from open does not.+- After the lock SpringBoard does not return to the override; it applies the+ next override against its current pose, so a later `hinge` request equal+ to the old override still lands. The override does reach SpringBoard under+ the lock, and it only means 0, 90 or 180°: setting it after a book sweep+ slid the pose from 100° to 90° and started a transition toward the cover,+ so vphoned leaves it alone after a SpringBoard sweep.+- `-[SBSTestAutomationService getDevicePose]` does not follow these sweeps+ (it kept reading open-flat after a sweep to closed); the replayed posture+ takes the hinge state from the completed request.+- Closing with the continuous profile is an interactive transition: it is+ performed while the inner display still holds the primary content and+ swaps it as it finishes. FoldDisplay re-read the panel's owner only when a+ transition was performed, so the panel kept showing the inner display,+ which SpringBoard keeps lit (and black) for 3 s after a swap. Ownership is+ now re-read on `-[SpringBoard displayContentModeCoordinator:+ handleSwapTransitionFromPrimaryWindowScene:toPrimaryWindowScene:+ withContinuationLockProvider:]` too.+- Folding from the lock screen or sleep lights the arriving panel's lock+ screen, which sleeps again after the lock screen's short idle time (about+ 7 s), as on hardware.+- DeviceHub (Xcode 27.1) draws a Duo guest as a 3D V68 model from CoreDevice's+ device motion state, which needed a `CMDeviceStateManager` stand-in in+ `dtdeviceinfod`. Details: `Research/Guest/devicehub_screen_viewing.md`,+ "iPhone Duo: the fold".+- One posture request runs at a time. SpringBoard answers a swap it refuses+ ("rejecting swap request — system is not idle") at once and the same way+ as a finished one, so a reply under 0.3 s for a sweep that had to move+ counts as a refusal and is retried every 0.25 s for 10 s plus the+ duration.++## 2026-10-29 late: the inner display takes the hardware's shape++DeviceHub shows its pose controls only for an integrated inner display with+its own stream, and draws that stream on the inner panel as the panel's+native framebuffer. The landscape 2853×2007 inner render display therefore+came out pillarboxed through the mirror and sideways through a per-display+stream. FoldDisplay now publishes it the way the simulator's inner+`CADisplay` is: a portrait 2007×2853 framebuffer at 3×, with+`DisplayRotation` 270, `DeviceSurfaceType` 2, chrome `phone14` and corner+radius 55 in its extended properties. SpringBoard lays the inner UI out at+interface orientation 90 and rotates it into the framebuffer, the+compositor draws the inner display's frames onto the panel without a turn,+and the 120 Hz timing is 2007×2853. The digitizer needs no turn either. The+clone redirect from the first DeviceHub fix is gone.++`display.rotation`'s inner map (0 landscape-left, 90 portrait, 180+landscape-right, from pose orientations 3, 1, 4) still holds on the portrait+framebuffer: measured on sbdisplay-duo, pose orientation 1 gives interface+90, 3 gives 0 and 4 gives 180.++The host window follows folds it did not ask for (DeviceHub's, another+client's): `display.orientation` carries `fold_angle`, the virtual hinge's+settled angle, and the window's once-a-second orientation poll moves its+fold chrome to the nearest of closed, book and open while none of its own+fold requests is in flight.++## 2026-10-30: CoreMotion, MobileGestalt displays and the book angle, against Apple's simulator++Apple's iPhone Duo simulator (Xcode 27.1, iOS 27.1 24A94425, device type+`iPhone-Duo`, two integrated displays: `LCD` 1398×2034 surface type 1 and+`LCD-1` 2007×2853 rotation 270 surface type 2) was probed over lldb in every+posture, through SpringBoard's own display-swap coordinator (the internal+suiatool path), and the same calls were run on a two-display guest+(`duobase-01`) through the guest's debugserver. The harness and the table are+in `Research/Guest/Evidence/duo-sim-baseline/` (`BASELINE.md`). The+simulator's fold tuning settings and MobileGestalt answers are in+`iphone_duo_simulator_reference.md`. Three of the differences had one cause each:++- **MobileGestalt saw one display.** libMobileGestalt computes+ `MGGetLogicalDeviceDisplayCount` and `DisplayExtendedProperties` live from+ the children of `IODeviceTree:/product` that carry `surface-type`+ (`display0`, `display1` in DeviceTree.v68ap); vphone600's tree has none, so+ the count fell back to 1 and the answer to nil (its fallback needs+ `MainScreenScale`, also nil). `preboot-cfw-devicetree_foldable_displays`+ copies the board's two nodes. QuartzCore gives a hardware display its entry+ when it builds it; the inner virtual display gets its own from FoldDisplay,+ with a physical size (`kCAVirtualDisplayPhysicalWidth/Height`, 460 ppi) so+ `pixelsPerInch` is no longer 0.+- **CoreMotion had no pose managers.** CoreMotion picks its motion+ capabilities from the product-id token (`MGIsDeviceOfType` in+ `CLPlatformInfo::queryEmbeddedSystemHardware`; V68 → hardware 0xC6, angle+ bit 38 and device-state bit 13). vphone600's token is no known product, and+ with `IsVirtualDevice` the guest became hardware 1 with no capabilities.+ SpringBoard's `SBFDevicePoseProvider` creates `_cmAngleManager` and+ `_cmMagicPoseManager` only when both report available and FrontBoard has+ two always-connected displays — the second condition the two-display path+ already met. The product-id patch, kept off since the single-display crash+ loop, is now on.+- **Book read 90°.** The test-automation override derives the angle from the+ hinge state. With the token, locationd starts `CLDeviceStateRelay`, Apple's+ VM path: it subscribes to host controls (primary usage `0xFF61/0x5B`) and+ turns `hinge-slider-control` / `orientation-picker-control` dictionaries+ (vendor-defined events, `IOCFUnserializeWithSize`, at most 256 bytes) into+ `CoreMotion_DeviceStateRelay_Crane` angle events (phase 2, private-data+ progress) and `_DeviceState` reports. libvphonehinge now publishes those+ host controls instead of its own `0xFF0C/0x21` service (whose phase-0 events+ CoreMotion drops), and vphoned stops setting the override when CoreMotion+ has the capability. SpringBoard then reads book at 99.444° (position+ 0.552; the simulator's synthetic 100° is 0.556).++One trap on the way: after the cover had gone dark in closed, a closed→book+sweep left the pose provider at 0° although CoreMotion delivered every angle+(breakpoints: `CLAngleNotifier::onIoHidEvent` 21 hits, `_handleAngle:` 19).+The provider commits a pose in motion only on ticks of its `UIUpdateLink`,+bound to `SB-main`, and a dark display produces none. On hardware the hinge+sensor's wake flag lights the screen on an unfold; the relay always sends 0+there. vphoned lights the screen before a sweep out of closed+(`SBSUndimScreen`, the side button when SpringBoard refuses it), 3/3 after.++Limits: the host controls' orientation picker has no upside-down, so the+cover's 180 and the inner panel's 270 are refused through CoreMotion. The+cover's corner radii are Apple's tree value [5, 5, 59, 59]; the simulator's+device type says [8, 8, 59, 59].++Reveal and validation on a new guest: `device.input_devices` lists+`VPhone Host Controls` and both `CoreMotion_DeviceStateRelay_*` services;+`display.posture` replies `source: coremotion`; in SpringBoard,+`MGGetLogicalDeviceDisplayCount()` is 2, `+[CMAngleManager isAvailable]` is+YES and `SBFDevicePoseProvider`'s description reads `.partiallyOpen` at+~99.4° six seconds after `{"hinge":"partially-open","position":"book"}`.++## 2026-10-30: the panel hosts the inner display's own pages++Open, the guest lagged badly. A spindump of backboardd on an idle Home Screen+(iOS 27.1, M5 Pro host, no DeviceHub viewer) had the render server thread in+`_XRenderDisplaySurface → VirtualServer::render_surface → ShadowNode::apply →+blur_surface → … -[MTLCommandBuffer waitUntilCompleted]` in 116 of 125+samples, SpringBoard's inner-panel queue inside `CARenderServerRenderDisplay`+in 118 of 126, and the inner display's own `VirtualServer` thread waiting on+the render server's lock. The compositor above re-rendered the whole inner+display, blurs included, for every panel frame, while the inner display was+rendering itself as well: `VirtualDisplay::begin_update` /+`finish_update_` draw only damage, into three pages in turn+(`displayed_surface` returns the last finished one).++Ruled out as a "did the inner display change" signal:+`CARenderServerGetDirtyFrameCountByIndex` and `GetFrameCounterByIndex` count+only the LCD (index 0); every other display, the inner one included, reads 0,+so gating the copy on it froze the panel on its first frame.+`updateRequestCallback` is a bare `ret` for non-IOMFB displays,+`frameInfoCallback` is IOMFB-only, `CADisplay.seed` is configuration, and+`-acquireFrozenSurface` is `Display::acquire_frozen_surface`, which returns+NULL unless an `IOMFBDisplay` overrides it.++**The fix** (`FoldDisplayInnerPages.m`): backboardd shows the inner display's+last finished page in a layer of a context of its own (`remoteContextWithOptions:`+with `displayable` NO and `ignoresHitTest` YES) and publishes the context id+as the state of the Darwin notification `com.vphone.folddisplay.inner-pages`;+SpringBoard's compositor layer is a `CALayerHost` of that context. A 120 Hz+timer on a backboardd queue reads the shown page under the two mutexes+`acquireFrozenSurface` takes and commits only when it changed. Nothing in+QuartzCore hands out the pages, so the path is read from QuartzCore itself and+checked at each step: the `_impl` type encoding (Server after the 64-byte+mutex); the instructions of `-acquireFrozenSurface` (server lock at +0x18,+C++ display at +0x60 on 27.1); the one vtable function with+`displayed_surface`'s body (slot 63); and the one pair of+`CA::WindowServer::IOSurface` getters for an object and the 32-bit value after+it (`iosurface()` +0x128 and `id()` +0x130, slots 21 and 24), checked against+`IOSurfaceGetID` before first use. The page is 2853×2007 BGRA. If a step does+not match, backboardd publishes 0 and SpringBoard keeps the+`CARenderServerRenderDisplay` path; it switches when the state changes while+the panel is shown (tested both ways with vphoned `notify.post`).++Measured on a clone of duospike-inner (duopanel-perf), the same session, CPU+from `processes.list` over 8–10 s, panel rate from+`CARenderServerGetFrameCounterByIndex(0, 0)` every 2 s:++| | upstream compositor | hosted pages |+|---|---|---|+| idle Home Screen: backboardd / SpringBoard | 60–77% / 10–18% | 5–8% / 2–3% |+| idle Home Screen: panel frames per second | 37–46 (nothing changed) | 10 (what changed) |+| Home Screen page swipes: panel fps | 7.5–13.5 | 34–44 |+| scrolling Settings: panel fps, backboardd | 45–79, 91% | 111–117, 51% |+| folded closed: backboardd / SpringBoard | | 3% / 1% |++Without SpringBoard's 120 Hz display link the panel still reaches the inner+display's rate: the render server composites the LCD on each commit of the+hosted context. Checked on the same VM: Settings launch and taps, Home,+unlock, fold closed (cover shows natively) and open again, backboardd+restarts (a new context id each time, SpringBoard restarts with it); no+backboardd or SpringBoard crash reports.++Trap seen while probing: the CA `IOSurface` object in a page is a C++ object,+not an `IOSurfaceRef`; `CFRetain` on it is a PAC failure that crash-loops+backboardd.++## 2026-10-30: the fold's fade to black on one panel++Opening out of closed showed 7 to 13 frames of black (about 0.12 to 0.2 s)+on the shared panel, measured on sbdisplay-duo (iPhone19,4 27.1, CoreMotion+relay path) from a ScreenCaptureKit stream of the VM window at 60 fps+(`screencapture -l` manages about 8 fps, and a screen-region recording misses+a covered window). The frames show SpringBoard's continuous fold effect: the+cover blurs, then fades to black, and after the swap the inner display fades+in from black. On hardware those are two screens. The panel itself never goes+off: the inner display is lit, then takes the panel, then the cover is turned+off. It is the same with SpringBoard drawing the inner display itself+(`com.vphone.folddisplay.inner-pages` state 0), so the pages path is not the+cause.++The effect is tuned by `SBDeviceContinuousFoldInteractionSettings`+(SpringBoard.framework, `+[SBDeviceContinuousFoldInteractionDomain+rootSettings]`): `fadeToBlackEnabled` with `outerFadeToBlackStart/End` and+`innerFadeToBlackStart/End`, `dimmingEnabled`, cone, cylinder and seam dims,+blur radii. FoldDisplay turns `fadeToBlackEnabled` off in SpringBoard, so the+cover dims and blurs but does not go black. The panel also changes hands+inside SpringBoard's primary-swap callback, with the inner display's layer+added in the same transaction, instead of two main-queue hops later, when+SpringBoard had already hidden the cover's content. Opening now shows 0 to 9+dark frames, usually 2 to 6; closing shows none, as before.++Tried and dropped: handing the panel to the inner display when a fold toward+it starts (`SBFDisplayContentModeTransitionContext`'s+`initial/finalContentModeOfDisplayForWindowScene:`), lighting it early: it+then showed its own fade in from black, 0.2 s; holding the inner layer back+until backboardd shows a new page: no change.++Two related host-window effects: the window follows a fold it did not ask for+(DeviceHub, a guest-side request) from `display.orientation`'s `fold_angle`,+which it now reads four times a second on a foldable guest (once before),+taking a fold once two reads agree: through the relay the hinge follows+DeviceHub's slider as it animates, and taking every read reshaped the window+at each step of a sweep. The cover drawn in the window's open shape,+sideways, now lasts a fraction of the half second it did. A fold while the screen sleeps lights it, and the+panel's first 0.2 s are its last frame from before sleep.++The fade to black stays for a fold that starts with the panel off or lit+less than a second ago. A fold made while the screen sleeps (DeviceHub, a+guest-side request) runs only as the screen comes on, since SpringBoard's+pose provider commits on display frames; without the fade, the effect's+carried-over inner content (its Home Screen, sideways on the cover) showed+for about half a second after the wake. And coming on, the panel first shows+its last frame from before it went off (the unlocked Home Screen on a plain+wake), which nothing in the guest replaces: SpringBoard stops compositing+before it turns the panel off, and neither `-[CAWindowServerDisplay+presentSurface:withOptions:]` nor `acquireFrozenSurface` reached the shown+surface (`willUnblank` never runs: the panel goes off by display state). So+`display.orientation` reports `screen_off`, and the VM window covers the+panel with black while it is off and for 0.3 s after it comes on. Both wakes+now go from black to the lock screen (60 fps capture).++## 2026-10-31: the inner display's point scale, for every process++Issue #784: WebDriverAgent saw the inner display at scale 2 (logical+1426.5×1003.5) and captured it at 1x in a corner, and vphoned's+`display.modes` said `pointScale` 1. Only SpringBoard saw 3, through the+adapter's `-[CADisplay pointScale]` answer; applications took 3 from+SpringBoard's display configuration. Every other process (XCTest's, vphoned)+read the render display itself, which a virtual display creates at 1. The+raw scale also showed in SpringBoard's own mode:+`FBSDisplayMode 669x951@3x (2007x2853/2(3.0))`.++Where the value lives (iOS 27.1 QuartzCore, 24A94425):++- A client's `-[CADisplay pointScale]` is the published display info's field+ 0x310 (`CA::Display::Display::update`), which+ `CA::WindowServer::Display::build_display_info_data` copies from the server+ display's field 0x94. `Display`'s constructor sets 1, `AppleDisplay`'s takes+ the panel's; `kCAVirtualDisplay*` options have no scale.+- The only other writer is `Server::set_display_properties`, reached by+ `-[CADisplay setDisplayProperties:]` with `-[CADisplayProperties+ setPointScale:]` (update mask 0x20, 1 to 4), which republishes the info.+ `_CASSetDisplayProperties` clears mask bits 0x10 and 0x20 unless the+ caller's audit flags have bit 1, `com.apple.QuartzCore.displayable-context`+ in `entitlements_for_audit_token`'s table. Sent from SpringBoard it changed+ nothing; from backboardd it took.+- A client keeps the scale it first read: a running Settings and vphoned+ still said 1 after the change, a relaunched Settings 3.++So backboardd sends `pointScale` 3 for the inner display as soon as its+render server answers (`vpSetInnerDisplayPointScale`, on the main queue after+`_detectDisplays`, since a CADisplay call from inside that never returns), a+second after the display is added and before applications start. SpringBoard+is already running by then (its adapter logs a second before the display is+added) and reads the inner display at 1, so the adapter's answer stays. A+build without it came up after a cold boot on the Trust alert over a bare+backdrop with the status column on its side and no Home Screen, twice; the+same machine on the previous bundle reached the Home Screen (seen on+duoscale-784).++Measured on sbdisplay-duo after a backboardd restart and after a cold boot+with the new bundle: vphoned's `display.modes` gives the inner display+`pointScale` 3 (display type still 3, virtual: no property sets it); a fresh+Settings has `CADisplay.pointScale` 3, `UIScreen` 951×669 at scale 3 and+`FBSDisplayMode 669x951@3x (2007x2853/3)`, and the inner `CADisplayMode`'s+`preferredScale` is 3 (the empty `Wireless` displays' is 2). testmanagerd+reports that value as `XCUIScreen.scale` (found on duoscale-784). The Home+Screen on both panels draws as before and taps open apps on both. An+application started while the device is closed lists only the cover's+`UIScreen`, and one started while open lists both, in the same boot. Not+run: WebDriverAgent itself, and #784's secondary points (`hingeAngle` POST,+and the empty `Wireless` displays, type 2 at 0×0, that WDA lists at+1408×2048 @2).++## 2026-11-02: the inner display's type, and XCTest's screenshot of it++After #788, WebDriverAgent's screenshot of the inner display (display 7,+`currentDisplayId=7`) still came back 2006×2852 portrait with the landscape+Home Screen upright in the top 2006 pixels and the rest black (PR #788+comment, WDA 16.17.6). The cover's screenshot was right.++What Apple's devices return for the same XCTest request (`XCUIScreen+screenshot` → testmanagerd's `ScreenshotProvider`, a small UI test that+captures every `XCUIScreen` with 2007×2853 pixel bounds):++| inner display, landscape | stored pixels | `UIImage.imageOrientation` (EXIF) |+| --- | --- | --- |+| real iPhone Duo, iOS 27.2 24B91020, held landscape | 2006×2852 portrait, UI turned, fills it | 3 (6) |+| Xcode 27.2 iPhone Duo simulator, open | 2006×2852 portrait, UI turned, fills it | 3 (6) |+| this guest (sbdisplay-duo), before | **2852×2006 landscape**, UI turned in the left 2006 columns, rest black | 3 (6) |++WDA applies the tag, so hardware gives 2852×2006 and the guest gave+isaac's cropped portrait image. The odd-to-even size is testmanagerd's own+(its buffer callback rounds 2007×2853 down). On the real Duo, display 2 is+the inner panel; set from XCTest, `XCUIDevice.orientation` never turns the+inner panel (it stays portrait-shaped face up), so only a phone held+landscape shows the case.++How testmanagerd renders a screen (Xcode 27.2 DDI, iOS 27.1 UIKit):++- `ScreenshotProvider` calls `_UIRenderDisplay` with `src-screen` =+ `+[UIScreen _screenWithIntegerDisplayID:]`, `dst-scale` = its `scale`,+ `src-rect` = its `bounds`, no `src-orientation`. The destination is+ `src-rect` × scale; `_UISnapshotContainerTransform` turns only by the+ angle between `src-orientation` (1 when absent) and portrait, so it is the+ identity here, and the render is `CARenderServerSnapshot` of the display+ with a 3× scale.+- The tag is `-[XCAXManager_iOS systemUIOrientation]`: AX attribute 1503 of+ the system app (attribute 1001 of the system-wide element), 3 → EXIF 8,+ 4 → 6, anything else 1. It was right on the guest.+- `CARenderServerSnapshot` of the inner display from SpringBoard with those+ options gave the hardware picture on the guest too, so the render path was+ fine; the difference was the screen's bounds.++Inside testmanagerd on the guest (lldb during a held XCTest session),+`_screenWithIntegerDisplayID:7` had bounds and `_referenceBounds` 951×669,+and its configuration `Unknown[7-1]; mode: "951x669@3x 120Hz"` with+`FBSDisplayMode 951x669@3x (2007x2853/3r270)`. SpringBoard's configuration+of the same display has no rotation (the simulator's never rotates). The+rotation comes from FrontBoardServices (27.1):++- `-[FBSDisplayConfiguration _initWithImmutableDisplay:originalDisplay:+ isMainDisplay:assertIfInvalid:]` sets the mode's rotation to+ `FBSDisplayRotationFromCADisplayRotation(nativeOrientation)`, and when the+ identity is not `isAlwaysConnected`, minus that of `currentOrientation`+ (mod 4). The inner display is native rot0 and current rot90 in landscape,+ so a not-always-connected identity gets r270 and landscape bounds.+- `_FBSCADisplayToDisplayTypes` derives always-connected from+ `-[CADisplay displayType]`: 0 → always connected, UIKit-main-like,+ connection 0; 1 → always connected only if main; 2 and 3 → not always+ connected, connection type 2 or 3; 4 → always connected, connection 0. The+ identity type comes from the tag (65536 → 7, `Unknown`).++The guest's inner display is a `CAWindowServerVirtualDisplay`, so every+client reads `displayType` 3; the simulator's and the real Duo's inner+panel is type 0. SpringBoard was right only because its adapter answers 0+(4 while FrontBoard classifies the display). testmanagerd builds its own+configuration from `CADisplay`, and so did vphoned's `display.modes`, which+reported type 3 (#784).++Where the type lives (iOS 27.1 QuartzCore, 24A94425):++- `-[CAWindowServerVirtualDisplay initWithOptions:]` sets bits 10–12 of the+ C++ display's halfword at +0x2c0 to 3 (`and #0xffffefff; orr #0xc00`),+ unconditionally; no `kCAVirtualDisplay*` option sets a type.+- `-[CAWindowServerDisplay displayType]` is `ldr x8, [x0, #8]` (`_impl`);+ `cbz`; `ldr x8, [x8, #0x40]` (server); `ldr x8, [x8, #0x60]` (display);+ `ldrh w8, [x8, #0x2c0]`; `ubfx w8, w8, #10, #3`.+- `Display::build_display_info_data` copies the raw bits to the info's+ +0x358; `Display::publish_display_info_state` copies the info into the+ display's shared memory (+0x360, a sequence counter then the data) that+ clients map. It runs from `post_display_changed`, `set_all_modes`,+ `set_display_properties` and `set_clone_master`, all inside QuartzCore,+ so the published copy cannot be corrected after each publish.+- The server itself reads the field: `Server`'s constructor (callbacks for+ type 0 or not), `Display::allocate_surface` (surface flags for type 0),+ `Renderer::render` and `MetalContext::begin_rendering` (type-0 branches),+ `VirtualServer::copy_display_timings` (of a source server that is not+ virtual), `render_for_time` and `supports_throttle` (type 1), and+ `update_clones` (type 2).++So backboardd clears the field once the render server runs, just before it+sends the inner display's point scale (`vpMarkInnerDisplayBuiltIn`); that+`setDisplayProperties:` publishes the type with the scale. The Server was+built for type 3 and stays so. The offsets and the bit range are read from+`-[CAWindowServerDisplay displayType]`'s instructions, the field is cleared+with a compare-and-swap (other flags share the halfword), and the getter+must answer 3 before and answers 0 after; if the getter's shape differs,+the display stays virtual. A running client keeps the type it read, as+with the scale.++Tried live first, on sbdisplay-duo over lldb in backboardd (field 0xd01 →+0x101, then a point-scale publish): the panel kept drawing, a fresh+testmanagerd captured the inner display as 2006×2852 portrait with the UI+turned and filling it, tagged EXIF 6, as on hardware, and the running+vphoned still said type 3.++Measured on sbdisplay-duo (iPhone19,4, iOS 27.1) with the new bundle,+after `vm set-bundle --update-environment` and a cold boot: backboardd logs+`inner display: type 0 (display +0x2c0 bits 10-12)` just before `point+scale 3 sent`; vphoned's `display.modes` gives the inner display+`displayType` 0 and `pointScale` 3, mode 2007×2853 at 120 Hz; the inner+pages context is published as before. XCTest's capture of display 7 open+and landscape is 2006×2852 portrait with the UI turned and filling it,+`imageOrientation` 3 (EXIF 6), and with the inner panel portrait-shaped+(`display.rotation` 0) 2006×2852 upright, `imageOrientation` 0: both as the+real Duo. Taps open apps on the inner panel and on the cover after a close,+and SpringBoard and backboardd kept their boot pids with no new crash+report.++WebDriverAgent 16.17.7 (appium-ios, the same native code as 16.17.6) on the+same guest: `/wda/screens` lists display 7 (2007×2853 @3) and display 1+(1398×2034 @3), both `traits` 1 (the inner display was 0 before), and+`isMain` is the lit panel; `/wda/screen` for display 7 is 951×669 @3. Its+screenshot with `currentDisplayId` 7, open and landscape, is 2852×2006 with+the whole UI; forcing `screenshotOrientation` keeps that canvas (WDA sizes+the canvas from the image's own orientation and only redraws). Closed,+display 1 is 1398×2034 (the cover's Home Screen is portrait-only).++With two integrated displays, testmanagerd now follows the active one, as+on the real Duo: when `hasMultipleIntegratedDisplays`, it watches the+default main display's `FBSDisplayLayoutMonitor` and takes the layout's+display `hardwareIdentifier` as active, and a capture of the other display+fails with "Cannot screenshot inactive display" (XCTDaemon+ScreenshotProvider error 9). The real Duo refuses the dark cover the same+way. Before, with one integrated display, the guest captured both panels+in either posture.++A process running across a backboardd restart keeps the displays it read,+and the restarted backboardd creates the inner display under a new unique+id: vphoned, dtdeviceinfod and a running testmanagerd still named the old+id, so testmanagerd held the cover active while open and refused the inner+display. Restarting testmanagerd (and dtdeviceinfod) cleared it; after the+backboardd restart itself, backboardd logged `type 0` again and a fresh+vphoned read type 0. A SpringBoard restart changes nothing here.++Also measured: DeviceHub streams the inner display; `devicectl device info+displays` lists both as `integrated`, the inner one `active` while open,+and `devicectl device capture screenshot` of it gives the 2007×2853 native+buffer (dtscreencaptured rotates by current and native orientation, not by+type); backboardd idles at 1.5% of a core on a still Settings screen;+Settings' inner `UIScreen` is 951×669 @3, 120 fps, mode `669x951@3x+(2007x2853/3)`, as before.++Not changed: WDA's `POST /wda/device/hingeAngle` still returns null with+the angle unchanged. WDA builds DeviceHub's hinge-slider payload (vendor+page 0xFF61, usage 0x5B, provider `com.apple.Virtualization.VirtualMachines`)+and dispatches it from its runner with `IOHIDEventSystemClientDispatchEvent`;+the guest's hinge relay follows the events DeviceHub's controls arrive in,+from dtuhidd's HID service, and nothing takes a client-dispatched one. Its+GET reads CMAngleManager and reports the guest's hinge (180 open). Taken+since; see "2026-11-02: WebDriverAgent's hinge POST".++## 2026-11-02: WebDriverAgent's hinge POST++WDA's `POST /wda/device/hingeAngle` (appium-ios 16.17.x,+`XCUIDevice+FBHinge.m`) builds DeviceHub's slider dictionary+`{provider: com.apple.Virtualization.VirtualMachines, source:+hinge-slider-control, type: range, value: <angle>}`, IOKit+binary-serializes it, wraps it in `IOHIDEventCreateVendorDefinedEvent`+(page `0xFF61`, usage `0x5B`) and sends it from the runner with+`IOHIDEventSystemClientCreate` + `IOHIDEventSystemClientDispatchEvent`.+The dispatch returns nothing, so the endpoint answers WDA's success+(`FBResponseWithOK`, `value: null`) whatever happened; `null` is success+here, and a refused argument comes back as an error object.++**Where it went.** backboardd's HID server refused it, every time:++ Error: the client with pid 1211 is missing the+ 'com.apple.private.hid.client.event-dispatch' entitlement.++The MIG stub `_Xio_hideventsystem_dispatch_event` calls+`_io_hideventsystem_dispatch_event(port, data, length)` (IOKit, exported).+That function turns the out-of-line buffer into a CFData+(`_IOHIDUnserializeAndVMDeallocWithTypeID`, freeing the buffer), finds the+connection, and for any connection type but 0 requires bit 3 of+`IOHIDEventSystemConnectionGetEntitlements` before+`IOHIDEventCreateWithDataInternal` and `_IOHIDEventSystemDispatchEvent`.+WDA's connection is "Rate Controlled" with entitlements `0x0`. Even+dispatched, the event would have had no service, and locationd's relay+reads the host controls from services matching `0xFF61/0x5B`. A runner+signed by a developer team cannot carry a private entitlement.++**The buffer's formats** (iOS 27.1 IOKit, 24A94425), all needed to read it:++- the buffer is a CFData in a **binary property list**+ (`_IOHIDCreateBinaryData`: `CFPropertyListWrite`, format 200), not an+ IOKit serialization; `IOCFUnserializeBinary` returns nil on it;+- the CFData is the event in `IOHIDEventCreateDataInternal`'s form, read by+ `IOHIDEventCreateWithDataInternal`; the public pair passes format flag 1,+ the internal one 0;+- the vendor payload inside is IOKit binary (WDA serializes with option 1,+ as dtuhidd's DeviceHub events are), read with `IOCFUnserializeBinary`.++**What changed.** `libvphonehinge` (backboardd, iPhone19,4 only) detours+`_io_hideventsystem_dispatch_event` from its constructor, before backboardd+serves clients. The detour decodes the buffer; an event that is a+host-control vendor event whose dictionary names the VM provider,+`hinge-slider-control`, `range` and a value of 0–180 is the hinge's: the+detour frees the buffer as the server would, answers `KERN_SUCCESS`, and+the hinge dispatches the event unchanged on its own `0xFF61/0x5B` virtual+service from its queue. The server never sees it, so it neither refuses nor+logs the missing entitlement. Anything else, including the orientation+picker, goes to the server unchanged. From the hinge's service the event takes DeviceHub's path:+locationd's relay moves the hinge, and vphoned's unmatched monitor sees the+provider and follows it as a DeviceHub value (`vp_hinge_note`: stored+quietly, the screen lit when opening from closed). The hinge status+(`VPhoneHingeStatus`) gains `client_dispatch` (`installed` or why not) and+`client_controls` (values taken).++Ways not taken:++- Granting the entitlement bit to unentitled connections would let any app+ dispatch any event (touches, buttons).+- Swapping the routine in `_iohideventsystem_subsystem` (found by the stub+ whose `BL` targets the exported function; `blraaz`, so a plain function+ pointer fits): the table is in the cache's `__AUTH_CONST`, and+ `vm_protect(VM_PROT_COPY | READ | WRITE)` there returns+ `KERN_PROTECTION_FAILURE`. Text pages take the copy, as libmisfix's+ detour measured.+- libmisfix's detour (`MISFix/MISFixDetour.c`, now built into the hinge too)+ relocates the target's first four instructions. In an X1 cache the+ prologue is `pacibsppc`, which signs LR with its own address; moved, it+ signs for the trampoline and the function's `retabsppc` fails. The guest+ runs the X1-lowered cache on hosts without PAuth_LR (this M5 Pro has+ none), where the prologue is `pacibsp`. The detour now refuses+ `PACIASPPC`, `PACIBSPPC`, `PACNBIASPPC` and `PACNBIBSPPC` instead of+ copying them, so on an unlowered cache the hinge reports `HID server+ dispatch not detoured: a displaced instruction is PC-relative` and WDA's+ POST stays a no-op.++**Measured** on sbdisplay-duo (iPhone19,4, iOS 27.1 24A94425, product-id+patch on), the hinge library pushed with `environment.install` and+backboardd restarted, WDA 16.17.x from appium-ios:++| request | WDA GET | `display.orientation` `fold_angle` | `screen_off` |+| --- | --- | --- | --- |+| before the change, POST 120 | 180 | 180 | |+| POST 120 | 120 | 120 | |+| POST 0 | 0 | 0 | false |+| POST 180 | 180 | 180 | false (lit on opening) |+| POST 120, 12 s later (past the 5 s resend) | 120 | 120 | |++vphoned stored each value quietly (`VPhoneHingeAngle` `quiet: true`, angle+as posted) and `client_controls` counted one per POST. DeviceHub (restarted+after the backboardd restart) still folds the guest from its own buttons:+Closed 0, Open 180, Partially Open 130, with `client_controls` unchanged,+since its values come through dtuhidd's virtual service, not a client+dispatch. After DeviceHub's, WDA's POST 0 and 180 turned DeviceHub's model+to the cover face and to the open inner panel. `display.pose` is the+test-automation snapshot and is not current on a relay guest; its hinge+field is not evidence here.++With the server bypassed for these events, a POST leaves only the+connection's `Connection added` and `Connection removed` lines in+backboardd's log, with no entitlement error; POST 120, 0 and 180 and+DeviceHub's Closed and Open were repeated with the same results. Checked+off-guest in `make test-hinge`: WDA's payload in the internal form inside a+binary plist is taken, and another usage page, no provider, the orientation+picker and values of -1, 181, a Boolean or a string are not.diff --cc VPhoneDaemon/Native/Include/VphonedNative.hindex 5608b1e4,9ef1720b..03d67568--- a/VPhoneDaemon/Native/Include/VphonedNative.h+++ b/VPhoneDaemon/Native/Include/VphonedNative.h@@@ -247,15 -205,12 +247,19 @@@ bool vp_device_tree_has_property(constNSArray * _Nonnull vp_display_probe(void);/// Read-only CoreAnimation display modes and capability surface.NSDictionary<NSString *, id> * _Nonnull vp_display_modes(void);+ NSDictionary<NSString *, id> * _Nonnull vp_external_display_status(void);+ NSDictionary<NSString *, id> * _Nonnull vp_external_display_diagnostics(void);+ NSDictionary<NSString *, id> * _Nonnull vp_external_display_configure(BOOL enabled, NSInteger width, NSInteger height);+ NSData * _Nullable vp_external_display_frame(NSString * _Nullable * _Nullable error);NSDictionary<NSString *, id> * _Nonnull vp_device_pose_get(void);-BOOL vp_hinge_set(double angleDegrees);+/// Set the hinge to `angleDegrees` at once. `orientation` is CoreMotion's+/// device orientation for the host controls (1 portrait … 6 face down), or 0+/// to keep the stored one.+BOOL vp_hinge_set(double angleDegrees, int orientation);+/// Store `angleDegrees` as the hinge's angle, keeping its orientation, without+/// a host-control event or waiting for the provider: the relay already has the+/// angle, and the hinge keeps it for its periodic resend.+bool vp_hinge_note(double angleDegrees);/// Sweep the hinge to `targetDegrees` the way Apple's Duo tooling does: over/// a profiled transition (0 continuous fold, 1 fade-in-out), `durationMs` < 0/// the per-direction default (opening faster than closing), 0 an instantdiff --cc VPhoneExecutable/VPhoneVirtualization/Resources/Info.plistindex 322d030d,433b0ec3..fb5fbaae--- a/VPhoneExecutable/VPhoneVirtualization/Resources/Info.plist+++ b/VPhoneExecutable/VPhoneVirtualization/Resources/Info.plist@@@ -9,10 -9,14 +9,14 @@@<key>CFBundlePackageType</key><string>BNDL</string><key>CFBundleVersion</key>- <string>57</string>+ <string>59</string><key>CFBundleShortVersionString</key>- <string>2.14.0</string>+ <string>2.15.0</string><key>NSMicrophoneUsageDescription</key><string>Shares this Mac's microphone with the virtual iPhone so apps running inside it can record.</string>+ <key>NSCameraUsageDescription</key>+ <string>Shares this Mac's camera with the virtual iPhone while System Camera streaming is enabled.</string>+ <key>NSCameraUseContinuityCameraDeviceType</key>+ <true/></dict></plist>diff --cc VPhoneExecutable/VPhoneVirtualization/UI/VirtualMachine/VPhoneVirtualMachineView.swiftindex ef120a67,f2588212..06bad27b--- a/VPhoneExecutable/VPhoneVirtualization/UI/VirtualMachine/VPhoneVirtualMachineView.swift+++ b/VPhoneExecutable/VPhoneVirtualization/UI/VirtualMachine/VPhoneVirtualMachineView.swift@@@ -1208,32 -1270,13 +1270,16 @@@ var panel = normalizeCoordinate(localPo/// outer or inner viewport. Input must be measured against that clipped/// rectangle; using the full backing bounds makes outer-screen touches/// land in the hidden part of the framebuffer.+ /// Use the panel's fraction of the backing framebuffer in view coordinates- /// to account for window scaling.- private var touchViewportSize: CGSize {- if let active = activePanelPixels,- let backing = recordingGraphicsDisplay?.sizeInPixels,- active.width > 0, active.height > 0,- backing.width > 0, backing.height > 0 {- return CGSize(- width: bounds.width * active.width / backing.width,- height: bounds.height * active.height / backing.height,- )- }- return bounds.size- }++ /// (clamped to the view itself) to account for window scaling; the shared++ /// geometry helper owns the math and its tests.+ private var touchViewportSize: CGSize { touchViewportBounds.size }private var touchViewportBounds: CGRect {- let size = touchViewportSize- guard size.width > 0, size.height > 0 else { return bounds }- // VPhoneDisplayContainerView bottom-aligns the full backing view inside- // the clipped viewport, so the active surface occupies the bottom-left- // portion of the VM view's local coordinates.- return CGRect(- x: 0,- y: max(0, bounds.height - size.height),- width: min(bounds.width, size.width),- height: min(bounds.height, size.height),+ guard let active = activePanelPixels,+ let backing = recordingGraphicsDisplay?.sizeInPixels else { return bounds }+ return VPhoneDisplayGeometry.activeViewportBounds(+ viewBounds: bounds, activePixels: active, backingPixels: backing)}diff --cc VPhoneGuestComponents/FoldDisplay/FoldDisplayBackboard.mindex 1ad3eec6,7ff2b3e8..0118f69b--- a/VPhoneGuestComponents/FoldDisplay/FoldDisplayBackboard.m+++ b/VPhoneGuestComponents/FoldDisplay/FoldDisplayBackboard.m@@@ -182,12 -81,9 +182,13 @@@ static BOOL vpAddInnerRenderDisplayToSeMethod enable = class_getInstanceMethod(object_getClass(display), setEnabled);if (enable && strcmp(method_getTypeEncoding(enable), "v20@0:8B16") == 0)((void (*)(id, SEL, BOOL))objc_msgSend)(display, setEnabled, YES);- vpTagUnknownDisplay(display);+ vpTagRenderDisplay(display, @"unknown");vpInnerRenderDisplay = display;+ dispatch_async(dispatch_get_main_queue(), ^{+ vpSetInnerDisplayPointScale(0);+ vpShareInnerDisplayPages(display);+ });+ vpPrepareExternalRenderDisplays(server);vpFoldDisplayLog([NSString stringWithFormat:@"inner display: render display added %@ uniqueId=%@", display,[display respondsToSelector:sel_registerName("uniqueId")] ? [display valueForKey:@"uniqueId"] : @"-"]);return YES;diff --cc VPhoneGuestComponents/FoldDisplay/FoldDisplayPrivate.hindex 43199c03,568ea752..f7060c53--- a/VPhoneGuestComponents/FoldDisplay/FoldDisplayPrivate.h+++ b/VPhoneGuestComponents/FoldDisplay/FoldDisplayPrivate.h@@@ -35,11 -30,8 +35,12 @@@ id vpReadObjectIvar(id object, const ch// MARK: - FoldDisplayBackboard.mvoid vpInstallInnerRenderDisplay(void);+ void vpTagRenderDisplay(id display, NSString *tagName);+// MARK: - FoldDisplayInnerPages.m++void vpShareInnerDisplayPages(id display);+// MARK: - FoldDisplayAdapter.mBOOL vpIsInnerDisplay(id display);diff --cc VPhoneGuestComponents/MISFix/MISFixDetour.cindex cb8937c1,625264b9..a1684521--- a/VPhoneGuestComponents/MISFix/MISFixDetour.c+++ b/VPhoneGuestComponents/MISFix/MISFixDetour.c@@@ -129,18 -142,6 +142,19 @@@ static unsigned vpRelocate(uint32_t insreturn 0;}+ // An X1 prologue signs LR with its own address, and the function's+ // `retaasppc`/`retabsppc <label>` checks it against the original's: moved,- // it signs for the trampoline and the return faults. The X1-lowered cache- // a guest without PAuth_LR runs has the SP-only forms here instead.++ // it signs for the trampoline and the return faults. The SP-only PACIBSPPC++ // form is re-signed correctly by the expansion above instead; the X1-lowered++ // cache a guest without PAuth_LR runs has that form, and installd's++ // prologue needs it hooked. These PC-only forms have no expansion yet.+ if (insn == 0xDAC1A3FEu // PACIASPPC+ || insn == 0xDAC183FEu // PACNBIASPPC- || insn == 0xDAC1A7FEu // PACIBSPPC+ || insn == 0xDAC187FEu) // PACNBIBSPPC+ {+ return 0;+ }+out[0] = insn;return 1;}