# Reference Moved out of the README. Commands use the current binary name, `phonedriver`. ## Install One line gets you the prebuilt binary. Each artifact has the Android agent inside. The shortest route is `npx`. The `phonedriver` npm package is a small launcher: on first run it downloads the binary for your platform from GitHub Releases, checks its SHA-256, caches it and runs it. It contacts GitHub only for that download and sends no telemetry. ```sh npx -y phonedriver init # add it to every agent on this machine, then check the devices npx -y phonedriver --version # try it claude mcp add phonedriver -- npx -y phonedriver mcp # or add it to Claude Code by hand ``` ### One command: `start` `phonedriver start` takes a machine from nothing to a phone that answers, or stops at the one thing you must do. It runs the existing commands in order and prints one line each, a mark and the fact: `✓` done, `·` noted, `!` a warning, `✗` a failure with `fix:` under it, `?` a question. 1. The device list. With a device connected, the next step is 4. 2. `doctor`'s checks of adb and Xcode, and its offer to download adb when none is installed (asked only where there is no Xcode: on a Mac only Android needs adb). 3. `boot` of the first device that can be started: a Simulator on a Mac, an Android virtual device elsewhere. `--device ` starts that one. The Simulator start was run on a Mac with nothing connected; on Android a virtual device named with `--device` was run from its saved state, and a start with nothing named or from a cold boot was not proven. 4. `init`'s agents: each agent found gets the server, as `init --register-only` does. 5. One snapshot. When it fails, `doctor`'s checks of that device follow with their fixes. ```console $ phonedriver start phonedriver 0.2.0 ✓ Xcode 27.0 · no phone connected, starting iPhone 17 (Simulator)… 22 s ✓ Claude Code knows phonedriver; restart it (added, for every project) ✓ iPhone 17 · iOS 26.5 · SpringBoard · 13 elements · 5.0 s try phonedriver snapshot phonedriver tap "Maps" phonedriver live ``` With a device connected and every agent already set up, `start` says so in three lines, the last with the time it took. Anything that downloads, pairs, signs or changes a setting is asked first, `[y/N]`, one question at a time; anything but yes does nothing. Without a terminal (an agent running it) nothing is asked: `start` stops at the first question with exit code 3 and names the command that answers it, for example `phonedriver doctor --install-adb` after the person accepts Google's terms. `--yes` answers only the questions listed as safe below, and none is: it never answers a download, and never a question that changes how a phone is reached or set up. Decision D521. Exit codes are the other commands': 0 ready, 3 a person must act, 4 no device connected or none to start. Decisions D232 and D233. The questions `start` asks: | Question | When | `--yes` | Without a terminal | |---|---|---|---| | Install adb (Google's Platform-Tools, D146) | no adb and no working Xcode | never | stops, exit 3, names `phonedriver doctor --install-adb` | | Keep an iPhone on Wi-Fi (`wifi on`, D47) | an iPhone on the cable, the first time `start` sees it | never: not asked either, a `·` line names the command (D521) | a `·` line names the command; `start` goes on | | Keep an Android phone on Wi-Fi (`wifi pair`) | an Android 11 or later phone on USB, the first time | never: a person scans the QR code | a `·` line names the command; `start` goes on | The Wi-Fi offer is a convenience, not a step to a phone that answers, so without a terminal it does not stop `start`. A person's answer to it is kept per phone in `/start-wifi` (one ` yes|no` line each) and not asked again; delete the line to be asked again. `wifi off` takes an iPhone off Wi-Fi. `start` keeps the id of the device it ended on in `/default-device` (`` is `PHONEDRIVER_HOME`, else `~/.phonedriver`). With several devices connected, a command that names none takes that device when it is one of them; `--device` and `PHONEDRIVER_DEVICE` always win. `devices` marks that device `(default)`, or says that the saved one is not connected. `phonedriver devices --clear-default` forgets it; the next `start` writes it again. Decisions D234, D1013. `init` looks for five agents and prints one line for each: ```console $ npx -y phonedriver init Claude Code added, for every project Codex already there Cursor added to /Users/you/.cursor/mcp.json VS Code not found Gemini CLI not found Restart your agent so that it loads phonedriver, then ask it: Open Settings and turn on dark mode. ``` The doctor checks follow (`--register-only` leaves them out, `--dry-run` changes nothing). Claude Code and Codex are asked through their own `mcp add` (Claude Code with `--scope user`). Cursor (`~/.cursor/mcp.json`), VS Code (the user profile's `mcp.json`) and Gemini CLI (`~/.gemini/settings.json`) get the entry in their file; the file's other keys are kept, and its keys come back in alphabetical order. A file that is not plain JSON, or that already has another `phonedriver` entry, is not touched: the line says why and prints the entry to paste. Started through `npx`, the entry is `npx -y phonedriver mcp` (`cmd /c npx ...` on Windows); started as an installed binary, it is `phonedriver mcp`, or the binary's full path when that name is not on `PATH`. `init --skill` also puts [`SKILL.md`](../SKILL.md) where each agent it found reads a person's own skills: `~/.claude/skills/phonedriver/` for Claude Code, `~/.copilot/skills/phonedriver/` for VS Code, and `~/.agents/skills/phonedriver/` for Codex, Cursor and Gemini CLI, which share that folder. Each line then ends with what became of it: ```console $ npx -y phonedriver init --skill Claude Code added, for every project · skill written to /Users/you/.claude/skills/phonedriver/SKILL.md Codex already there · skill written to /Users/you/.agents/skills/phonedriver/SKILL.md Cursor added to /Users/you/.cursor/mcp.json · skill already at /Users/you/.agents/skills/phonedriver/SKILL.md ``` A `SKILL.md` that is already there with other text is left as it is, and the line says to delete it first. Plain `init` installs no skill, because beside the MCP server it costs more than it saves: the server already sends its instructions to every agent, and in our runs an installed skill was opened in 2 of 6 and used about 8% more tokens. It is for an agent that drives the `phonedriver` command line with no MCP server, which has no other guide, and for anyone who wants it. The installers below put a permanent `phonedriver` on your `PATH` instead. ```sh # macOS and Linux curl --proto '=https' --tlsv1.2 -LsSf https://github.com/hridaya423/phonedriver/releases/latest/download/phonedriver-installer.sh | sh # Homebrew (macOS and Linux) brew install hridaya423/tap/phonedriver ``` ```powershell # Windows powershell -ExecutionPolicy Bypass -c "irm https://github.com/hridaya423/phonedriver/releases/latest/download/phonedriver-installer.ps1 | iex" ``` The shell and PowerShell installers put `phonedriver` in `$CARGO_HOME/bin` (`~/.cargo/bin`) and add it to your `PATH`. The iOS Simulator runner needs no download: its sources are inside the binary, and the first command that needs it builds it on your Mac with Xcode. To build from source instead, use Rust 1.99 or later. ```sh cargo build --release ``` The build packs the Android agent, so it needs the Android SDK with build-tools **37.0.0** and platform **android-37.0** (`ANDROID_HOME`, falling back to `ANDROID_SDK_ROOT`, then `/opt/homebrew/share/android-commandlinetools`), `d8` and JDK 17. Override the versions with `ANDROID_BUILD_TOOLS` and `ANDROID_PLATFORM`. If anything is missing the build says exactly what and how to get it. To skip that step, set `PHONEDRIVER_AGENT_JAR` to a built `phonedriver-agent.jar` (`bash android-agent/build.sh` makes one; none is published yet). **iOS only, no Android toolchain:** ```sh cargo build --release -p phonedriver --no-default-features ``` That binary has no Android support (`phonedriver doctor` skips the Android checks). Run the tests with the default features. The binary is `target/release/phonedriver`. ```console $ target/release/phonedriver version phonedriver 0.2.0 ``` To use a binary you built instead of the npm package, register it with your client by its full path: `claude mcp add phonedriver -- "$PWD/target/release/phonedriver" mcp`. Run `phonedriver doctor`. It checks adb, each Android device, the agent, UiAutomation, the video stream, Xcode, the simulators, and the permissions of the daemon socket. Each line says `ok`, `warn` or `fail`, and a fix follows every line that is not `ok`. Android allows one UiAutomation client, so while phonedriver's agent runs, `adb shell uiautomator dump` and other UiAutomation tools are killed (exit 137); the `uiautomation` line says so, and `phonedriver daemon stop` frees it. Without `--device` it checks the host and lists every device, and it probes (starts the agent or the runner on) only emulators and Simulators that no live session holds; a physical phone or tablet, and any device another live session holds, is listed with one `not probed` line that says why and gives `phonedriver doctor --device `. `--all-devices` probes physical devices too, still skipping devices another live session holds. `--device ` probes that device and nothing else, even if a session holds it. Android draws no frame while nothing on the screen changes, so the `video` line is `ok` on a still screen that is on, once the stream has drawn and is current (D978). On each Simulator it probes, the `touch` line checks that a touch arrives: from the home screen it swipes down, which opens Spotlight, then brings back the app that was in front. When nothing opens, the line fails with `touches are not reaching this Simulator` and says to shut the Simulator down and boot it; in a terminal `doctor` offers to do that, `[y/N]` (D246). Devices the [device list](#devices-an-agent-must-not-touch) hides are not shown. `--device` takes what every other command takes, a Simulator's name in any case included: a name nothing has is refused with exit code 4, and a Simulator that is off is said to be off. `--json` prints `{"ok", "checks": [{"status", "name", "detail", "fix"}]}` and asks nothing; with `--install-adb` it is refused (D963). `phonedriver init` runs the default form. With no adb installed (none on the `PATH`, in the SDK `ANDROID_HOME` names or in Android Studio's), `doctor` and `init` in a terminal offer to download Google's Android Platform-Tools 37.0.3 (16.6 MB on macOS) into `/platform-tools`, after you accept Google's [Android SDK License Agreement](https://developer.android.com/studio/terms). The file is checked against a pinned SHA-256, and an adb installed elsewhere always wins. An agent has no terminal to ask in: `doctor` then prints `adb not installed`, and the agent asks you before it runs `phonedriver doctor --install-adb`. Decision D146. ```console $ phonedriver doctor ok adb server 0029 at 127.0.0.1:5037 warn android devices none connected fix: Connect a phone with USB debugging on, or start an emulator; `adb devices` lists what adb sees. ok xcode Xcode 27.0, Build version 27A266a warn simulators none booted fix: `phonedriver boot` lists the ones that can be started; `phonedriver boot ` starts one. ok daemon socket /Users/you/.phonedriver/run/daemon.sock mode 600 in a directory of mode 700 ``` On a machine with a phone attached, the phone's line is `warn agent android:R5CT123 not probed: a physical device, which doctor leaves alone unless asked`, followed by `fix: Run `phonedriver doctor --device android:R5CT123` to probe it.` The CLI runs the same loop. `phonedriver skill` prints [`SKILL.md`](../SKILL.md), the instructions an agent reads before it uses the tools. ```sh phonedriver devices phonedriver snapshot phonedriver tap "Dark theme" phonedriver wait settled ``` ### Start a simulator or an emulator With nothing running, phonedriver starts an iOS simulator (Xcode installed) or an Android virtual device (one made in Android Studio): ```console $ phonedriver boot ID MODEL OS sim:E02FE8A6-5F1E-405E-A263-2E828218BE5F iPhone 17 iOS 26.5 $ phonedriver boot "iphone 17" booted sim:E02FE8A6-5F1E-405E-A263-2E828218BE5F · iPhone 17 · iOS 26.5 ``` The name is the model in any case, or the id; when several simulators have the name, the one with the newest system starts. It boots without a window (`open -a Simulator` shows it). A Simulator that is shut down while phonedriver holds it answers the next call `disconnected` at once with the hint to `boot` it, and stays off (decisions D797, D844, D846). Over MCP it is `devices` with `boot: "iPhone 17"`. An iOS 27 Simulator read in the first seconds after a boot names no app in front until phonedriver restarts its `CoreSimulatorBridge`, which it does by itself: that first read takes about 10 to 20 s. Status bar overrides made before the restart stay on screen, though `simctl status_bar list` no longer shows them (decision D850). When nothing is connected, every command's error names what can be started (`no device is connected; can be started: iPhone 17 (iOS 26.5)`), so an agent can start one and go on. Decision D77. Android virtual devices are in the same list, and start the same way: ```console $ phonedriver boot ID MODEL OS avd:Pixel_API_37 Pixel_API_37 Android API 37 avd:Pixel_Tablet_API_37 Pixel_Tablet_API_37 Android API 37 avd:Pixel_API_31 Pixel_API_31 Android API 31 avd:Pixel_API_26 Pixel_API_26 Android API 26 $ phonedriver boot pixel_api_37 booted android:emulator-5554 · Pixel_API_37 · Android API 37 ``` phonedriver runs the SDK's `emulator` program (from `ANDROID_HOME`, `ANDROID_SDK_ROOT`, the folder Android Studio installs to, or the `PATH`) and returns when Android says it has booted. The emulator keeps running after phonedriver's daemon stops; `adb -s emulator-5554 emu kill` stops it. A first boot can take minutes, and on a slow or busy machine the first command after it may still fail while Android settles; a later boot resumes from the emulator's saved state in seconds. With `ADB_SERVER_SOCKET` set (adb on another machine), no virtual device is listed. Decision D79. ### Copy a Simulator or an emulator `fork` makes copies of an iOS Simulator that holds an app with its state, so many agents can start from it: ```console $ phonedriver fork "iPhone 17" -n 2 ok forked iPhone 17 into 2 · 36.3 s sim:F1A2… iPhone 17 (fork 1) booted sim:9C0D… iPhone 17 (fork 2) booted $ phonedriver fork list sim:F1A2… iPhone 17 (fork 1) of sim:E02F… booted held by agent1 $ phonedriver fork rm --all ok removed 2 forks ``` Each copy is a device of its own: `devices` lists it, a session leases it, and an app's data in one copy is not the source's or another copy's. A copy carries what is on the source's disk (apps, their data, `UserDefaults`, settings, keychain files) and boots cold, so nothing that was running comes with it. The source has to be shut down; for one that is on, `fork --stop` shuts it down for the copy and starts it again, and refuses while a session holds it. Copies are named ` (fork N)`, kept in their own device set (`sims` under the phonedriver home), so Xcode's and `simctl`'s device lists do not show them, and recorded in `forks.json`; `fork rm` deletes only those, and refuses one a session holds. On a quiet Mac mini (iPhone 17; `docs/spikes/ios.md`, F1) `simctl clone` made each copy in 3.3 s and 7.5 MB, four booted together in 19.6 s, and a booted copy took about 1.2 GB of memory; on a busy one `fork` made two in 36 to 54 s. `fork` is a command, not an MCP tool. Decisions D159, D191. An Android emulator's copy is its AVD started again, read-only, on a console port of its own (D1140): ```console $ phonedriver fork avd:Pixel_Tablet_API_37 -n 1 ok forked Pixel_Tablet_API_37 into 1 · 83.8 s android:emulator-5556 Pixel_Tablet_API_37 (fork 1) booted ``` The emulator runs `emulator -avd -port -read-only -no-snapshot-save`: it reads the AVD's disks and keeps what it changes in files of its own that go away when it stops, so any number of copies run side by side and none writes the AVD or its snapshots. The emulator starts a second instance of an AVD only when every running one was started `-read-only`: fork an AVD while it is off (`fork avd:`; `boot` with no name lists the AVDs that are off), or start the source with `PHONEDRIVER_EMULATOR_ARGS=-read-only`. A fork of a source started without it is refused with the emulator's own words (`Another emulator instance is running. Please close it or run all emulators with -read-only flag.`) and what to do. A copy holds what the AVD's disks hold, not what a running source changed since. Each copy takes the first console port from 5554 that no emulator has, nothing listens on, and no other start of this daemon holds, `PHONEDRIVER_EMULATOR_ARGS` is added to its command line as to `boot`'s (`-no-window -memory 2048`), and the emulator needs free disk beside the AVD for each copy's own files. A running fork is not its AVD: `boot avd:` starts the AVD rather than answer a fork, and the AVD stays among those that are off, so `fork avd:` makes more copies beside the first. A copy that has not booted Android in 300 s is stopped as hung, as is an AVD `boot` started. When one copy of several stops or hangs, the copies already started are stopped through their consoles, or killed with the processes they started (QEMU) when the console does not answer; one whose process already ended is left alone, because its port may be another emulator's by then. `forks.json` keeps each copy's boot id: an emulator's id is its port, and one started later on the port of a copy that stopped takes that id, so `fork rm` and `fork list` stop nothing whose boot id differs and forget the record (`forgot android:emulator-5556: the emulator there now is not the fork phonedriver started, so it was left running`). `fork rm` stops a copy through its console (`kill`) and waits until adb no longer lists it. A phone is refused (`is a phone, and a phone cannot be copied`), and so are an emulator whose AVD is not in the AVD folder (`ANDROID_AVD_HOME`, else `.android/avd`), one behind another computer's adb server, and a machine with no `emulator` program; nothing is started then. `--stop` does nothing for an emulator. ### Save an app's data and go back to it ```console $ phonedriver checkpoint signed-in --app Shop ok checkpoint "signed-in" · Shop's data, 238 KB · 1.3 s · the app was started again $ phonedriver checkpoint rewind signed-in ok rewound Shop's data to "signed-in" (saved 12 minutes ago, 238 KB) · 2.5 s app dev.example.shop (Shop) ...the screen after the rewind, as launch gives it... $ phonedriver checkpoint list $ phonedriver checkpoint rm signed-in ``` `checkpoint --app Shop` (or `checkpoint save --app Shop`) stops the app, copies its data folder (a copy-on-write clone on a Simulator, a `tar` on Android), keeps it under the phonedriver home and starts the app again. Without `--app`, an Android emulator saves its **whole state** (disk, memory, every running app; about 320 MB on an API 31 image, in 2 s), and a Simulator saves the app in front. `checkpoint rewind ` replaces the app's data with the saved copy, so what the app holds now is gone, then starts it on its first screen and prints the screen. A checkpoint belongs to the device it was made on. The data is the app's own files, databases and preferences; what the system keeps for the app elsewhere (the Simulator's keychain, a granted permission, an account on the device) is not in it. On a Simulator any app's data is taken; the runs used the testbed. On an Android emulator the app has to be a debug build (`run-as`) or the image has to give root (a Google APIs image does, a Play Store one does not); a release app on a phone cannot be read, and the reply says so. On a physical phone only an app phonedriver installed is saved or replaced, as for `apps clear`. A rewind is refused while another session holds the device. `checkpoint rewind` of a whole-device checkpoint loads the emulator's saved state in about 4 s and prints the saved screen; every ref read before it is stale. The emulator's own snapshots (`default_boot` and the person's) are never touched: phonedriver's are called `pd-`. Decisions D160, D161. ### iPhone or iPad A physical iOS device needs the runner signed with your Apple developer team (a free Apple ID is meant to work, not run here, see [#69](https://github.com/hridaya423/phonedriver/issues/69); its signature lasts 7 days, and the next command after that signs the runner again by itself). Plug the device in, unlock it, then: ```sh phonedriver ios setup # signing team, pairing, Developer Mode, developer disk image, then the runner phonedriver --device ios: snapshot ``` phonedriver reads the team from this Mac's Apple Development certificate. To make one, sign in under Xcode > Settings > Accounts, choose Manage Certificates and add an Apple Development certificate. With certificates for several teams, set `PHONEDRIVER_TEAM` to the ID of the one to use. The ID is the certificate's organizational unit. It is not the ID in parentheses that `security find-identity` prints after your name. The runner is signed as `dev.phonedriver.runner.`, so each team registers an app ID of its own (a free account can register ten a week, and this one is registered once). To sign it as another ID, set `PHONEDRIVER_BUNDLE_ID`. If macOS holds your certificate and will not sign with it, `phonedriver ios setup` says why: `CSSMERR_TP_NOT_TRUSTED` most often means Apple's "Worldwide Developer Relations - G3" intermediate certificate is missing from the keychain, and [Apple's certificate page](https://www.apple.com/certificateauthority/) has it. Without a team, the command stops with exit code 3 and says so. If the device has never been used with that team, the command stops with exit code 3 and asks for `phonedriver ios register`, which lets Xcode add the device to the team's Apple developer account (an account holds 100 iPhones a year). With a booted Simulator and an iPhone that has no team, the Simulator is the default device. If you set `PHONEDRIVER_TEAM` or `PHONEDRIVER_BUNDLE_ID`, run `phonedriver daemon stop` afterwards: the daemon reads them when it starts. #### iPhone without the cable After the setup above, with the device still on the cable: ```sh phonedriver wifi on ``` Unplug it. While the device and the Mac are on the same Wi-Fi network, `phonedriver devices` still lists it and most verbs work; `launch --net` and, from a Mac, `clipboard`, `perf` and `drain` need the cable. An iPhone over Wi-Fi has not been run on 0.2.0. `phonedriver doctor` says `over Wi-Fi` or `over USB`. The device answers only computers it already trusts. `phonedriver wifi off` stops it. A session can keep the phone while the cable comes and goes. It stays `ios:` with the same lease, session, checkpoints and `env` records. When the cable comes out, the call it cut runs again over Wi-Fi if nothing of it reached the phone or running it twice ends the same; otherwise it fails `interrupted` and says where the phone went. phonedriver looks for the phone on the network for up to 10 s. The next reply ends with `moved from usb to wifi`, and `devices` says `ios: is driven over wifi`. When the cable is back, the phone moves back to it before a later call, at least 30 s after the last move and never during a call, and that reply ends with `moved from wifi to usb`. A call with `--secret` text is never carried onto Wi-Fi from a Mac: it is refused, nothing of it is sent, and the refusal names the move. Secret calls stay refused until the cable is back. A phone you did not run `wifi on` for never moves, and nothing is asked of the network about it. The move was proven against fakes of the cable, the network and the phone; no iPhone was unplugged for it. Decisions D826, D1152, D1153. On a Mac over Wi-Fi, what phonedriver sends to the runner on the phone and what the runner sends back, screens and typed text included (`--secret` text too), crosses the network unencrypted. Only phonedriver can drive the runner, because it must prove the token the runner was started with (decision D106), but anyone who can read the network's traffic can read that stream. Use the cable for secrets, or a network you trust. Off a Mac, the runner's traffic goes through the Wi-Fi pairing's encrypted tunnel, and phonedriver checks that the device on the network is the one it paired with on the cable. A pairing made before 0.1.7 cannot be checked: plug the phone in once and run `phonedriver wifi on` again. Tested on an iPhone 13 Pro Max (iOS 27.0.1) on one network. An iPhone 14 Plus (iOS 26.1) was found and answered over Wi-Fi; taps on it were not run. A sleeping device stops answering on Wi-Fi until it wakes. phonedriver does not unlock an iPhone. From 0.1.4 it keeps an iPhone awake for 10 minutes after each use and stops on `phonedriver release`; in 0.1.3, set Settings > Display & Brightness > Auto-Lock to Never for a long task. The experimental CoreDevice tier was run on the cable only. See decision D47. ### Command lines of 0.1 0.2.0 folded duplicate verbs into one each (D1111). The old command lines still run, as the command that does it now, with a note on stderr, and `--help` lists only the new one (D1168): `pair` and `untether` run `wifi pair` and `wifi untether`, `ios wifi on|off` runs `wifi on|off`, `compare A [B] --image C` runs `screenshot --compare A [B] --diff-image C`, and `network` runs `sensor network`. These five are the folded command lines 0.1.8 shipped; the other verbs D1111 folded never shipped, and neither they nor the verbs 0.2.0 removed (D1110) are forwarded, so `phonedriver down` is an unknown verb, not `farm down`. Only the verb itself is read, after any global options: `phonedriver --device pair snapshot` and `phonedriver wifi status` are left as they are. ## Environment variables | Name | Default | Meaning | |---|---|---| | `PHONEDRIVER_HOME` | `~/.phonedriver` | Where the daemon keeps its socket (`run/`), `daemon.log`, `traces/`, `tmp/` and the iOS `runner/` builds. Set it to run a separate daemon. On macOS the socket path must stay under about 100 bytes. | | `PHONEDRIVER_SOCKET` | under `PHONEDRIVER_HOME` (else `$XDG_RUNTIME_DIR/phonedriver`) | The daemon's socket or named pipe. Point it at an `ssh -L` forward to use a remote machine's devices. | | `PHONEDRIVER_DEVICE` | none | The device to use when `--device` is not given. Also read by `phonedriver mcp`. `+` is a lane of an Android device ([several agents on one phone](#several-agents-on-one-android-phone)). | | `PHONEDRIVER_DISPLAY` | `main` | `hidden` makes the Android agent work on a second screen the person holding the phone cannot see (Android 13 and later; `--display hidden` does the same). Read by the CLI, `phonedriver mcp` and `doctor`. A call in the other mode reconnects, which takes a few seconds. Tested on an emulator and a HONOR X8 (Android 13); some makers' builds may refuse it. The phone has to be unlocked: on a locked phone the call fails with "The device is locked" and the phone stays asleep. While the agent works, the phone's own screen is kept on, so the phone does not lock under it (D86). | | `PHONEDRIVER_SESSION` | `default` | The session name, as `--session`. | | `PHONEDRIVER_TEAM` | the team of this Mac's Apple Development certificate | Apple developer team ID that signs the iOS runner on a physical device. Needed only with certificates for several teams. | | `PHONEDRIVER_BUNDLE_ID` | `dev.phonedriver.runner.` | The bundle ID the iOS runner is signed as for a physical device, on a Mac. Needed only when your team must use an ID of its own. The app on the device is this ID with `.xctrunner` after it. | | `PHONEDRIVER_IOS_TIER` | unset | `coredevice` drives an iOS 27 device through its developer services with nothing installed, `runner` through the runner. Unset: the runner, or nothing installed when no runner can be had (no signing team on a Mac, none installed off one; D145). The no-install tier is experimental; when it was chosen this way, a session's first device line ends `nothing installed, the experimental route: \`phonedriver ios setup\` installs the runner` (D261). A screen the phone's accessibility service gave no elements for is read from its picture, and the reply says why in a `hint:` line once per app: the app did not answer, or the service answers for no app, and what brings reads back (D265). | | `PHONEDRIVER_SIM_HID` | on | `0` sends a Simulator's touches and typing through the iOS runner, as a physical iPhone's go, instead of through the Simulator's own input port (which briefly toggles a hardware keyboard when typing via HID, D1155). A tap then starts the runner. For proving the path an iPhone takes without one (decision D670). | | `PHONEDRIVER_SIM_RUNNER` | off | `1` starts the iOS runner with every Simulator and reads its tree, presses its buttons, types and takes its screenshots through it, as before 0.2.0. Without it a Simulator is read and typed into through simio (D1155, D1156) and the runner starts when several fingers, a web page, text with quotes, `--` or characters a US keyboard lacks, or a `tap` that looks down a list for its text needs it. Read when the daemon starts. Use it to tell whether a difference on a Simulator comes from simio. | | `PHONEDRIVER_IOS_CMIO` | off | `1` takes a cabled iPhone's or iPad's screenshots (iOS 17 to 26, on a Mac) through the QuickTime capture macOS offers for it, with nothing installed on the device, instead of through the runner. The app running phonedriver needs the Camera permission. A capture that fails is dropped for the session and the runner takes the screenshots (D1157, D1158). Not yet run against a phone. | | `PHONEDRIVER_GUARD` | on | `off` stops phonedriver asking the human before a tap that spends money or cannot be undone (`Place order`, `Pay`, `Delete account`), and lifts every check on a physical device as `force` does: `shell` runs `input`, call intents, wipes and deletes from the storage root, `setting` writes what the device asks its user to confirm, and `open` takes a link that places a call. Set it for `phonedriver mcp` or the CLI only when you grant the agent full autonomy. See [The approval guard](#the-approval-guard). | | `PHONEDRIVER_ASK` | none | A comma list of more kinds of tap to ask the human about, besides payments and account deletion: `send` (Send, Reply, Post, Share), `delete` (Delete, Remove, Erase, Clear all, and any of the first three followed by one or two words that name what goes, such as `Delete Contact` or `Remove from List`, but not `Delete key`, a `#` tag, or `Remove` or `Erase` before a filter, tag, coupon, promo or drawing; English only, D960, D1012) and `install` (Install, Uninstall). For example `PHONEDRIVER_ASK=send,delete`. Read by `phonedriver mcp` and the CLI; a name that is not one of these stops the command with exit code 2. `PHONEDRIVER_GUARD=off` and `autonomous: true` skip these questions too. See [The approval guard](#the-approval-guard). | | `PHONEDRIVER_NOTIFY` | on | `off` stops the daemon raising a desktop notification when a phone needs a person: a locked device, a prompt only a person answers, an approval the guard holds, a `wait human`. A click focuses the device's window where it can (D1137): the Simulator on macOS with [`terminal-notifier`](https://github.com/julienXX/terminal-notifier) installed (grant it Notification permission in System Settings if macOS hides its banners), an emulator on Linux with `wmctrl`, and the live page everywhere with `live --notify-link` (command generation is unit-tested; interactive desktop clicks on macOS, Linux and Windows have not yet been verified live). The daemon sends none without a desktop session either (Linux with no `DISPLAY`, `WAYLAND_DISPLAY` or `DBUS_SESSION_BUS_ADDRESS`; Windows in session 0, as an ssh logon or a service is). Read where the daemon starts: run `phonedriver daemon stop` after changing it. | | `PHONEDRIVER_ALLOW_DEVICES` | none | A comma list of devices the daemon may use, for example `android:emulator-5554,android:R5CT123`. Every other device behaves as if it were not connected. See [Devices an agent must not touch](#devices-an-agent-must-not-touch). The daemon reads it when it starts: run `phonedriver daemon stop` first if one is running. | | `PHONEDRIVER_DENY_DEVICES` | none | A comma list of devices the daemon never lists, connects to or pushes the agent to, even with `--force`. Same entries and same rules as the allow list; a device named here is hidden even when the allow list names it too. | | `PHONEDRIVER_APPS_UNDER_TEST` | none | A comma list of package names, such as `com.example.app,com.example.other`: apps of yours that Gradle or Android Studio installed, not phonedriver. On a physical Android phone `apps clear`, `uninstall`, `grant`, `revoke` and `launch --grant` touch only apps phonedriver installed; the packages listed here count as installed by you. The daemon reads it when it starts, so set it in the environment of the command that starts it (for an MCP client, the server's `env`; see [Claude Code](/docs/claude-code/#an-app-you-are-developing)) and run `phonedriver daemon stop` first if a daemon is running. It is the person's setting and there is no tool argument for it, so an agent cannot add an app to the list. | | `PHONEDRIVER_APP_SCOPE` | none | A comma list of package names, such as `com.example.app`: the only apps the agent may read or act in (see [App scope](#app-scope)). Not the same as `PHONEDRIVER_APPS_UNDER_TEST`, which says which apps phonedriver may clear or uninstall on a physical phone and restricts nothing else. The daemon reads it when it starts; a client that sets a scope the running daemon was not started with is refused until `phonedriver daemon stop`. There is no tool argument for it, so an agent cannot set or clear it. | | `PHONEDRIVER_HOST_SHELL` | off | `1` lets `shell` act on this computer as well as the device: on an iOS Simulator it runs any program (without it only `defaults` and `log show|stream`, with no file named) and the `simctl` forms that read or write a Mac file, on an Android emulator it sends any console command. Read when the daemon starts; see [Shell](#shell) and decision D108. | | `PHONEDRIVER_EMULATOR_ARGS` | none | Extra flags, separated by spaces, that `boot` puts after the ones it sets when it starts an Android emulator (`-no-window -no-audio` on a machine with no display). Read when the daemon starts. See [A camera and a place for the device](#a-camera-and-a-place-for-the-device-emulator-simulator). | | `PHONEDRIVER_FILES` | none | The one folder on the machine with the device that `files` copies from and to (an absolute path). Without it every transfer and every listing is refused. For the MCP server, set it in the server's `env`. | | `PHONEDRIVER_SECRET` | none | The text for `type --secret`, instead of stdin. The daemon shows it as `•••` wherever it later appears on a screen it reads or in a command's output, until the daemon stops; a screenshot still shows what the phone shows. | | `PHONEDRIVER_SIM_SECRET_KEYS` | off | `1` types a Simulator's secrets as keys instead of setting them on their field, for a web page's field or a multi-line view, which cannot be set. Keys go to whatever has the keyboard, so an app that comes to the front meanwhile can receive some of the secret. Read when the daemon connects the Simulator; there is no tool argument for it (D625). | | `PHONEDRIVER_REPLAY_SECRET_ANY_FIELD` | off | `1` lets `replay` type a secret it reads from `PHONEDRIVER_SECRET_*` into any field. Without it a replayed secret goes only into a password or one-time code field (D105). Read by the process that replays: the CLI, or the MCP server. | | `PHONEDRIVER_TRACE_FULL` | off | `1` keeps observation text and the text of text targets in the traced requests (the daemon reads it at start). Replies are traced as returned either way: a summary or an error can name an element, as in `tapped @e6 "Busy"` or `no element matches "Pay"`. On an iPhone with nothing installed it also writes every message to and from the accessibility service to `daemon.log` as `ax …` lines, and why the video stream ended (D265): its time and direction, kind, selector, request, attribute, notification and error, elements as process and object numbers, the kind of each answer and its size in bytes, and the bundle id of the app in front. They hold nothing an element shows. On a Simulator it writes one `ax simio ms` or `ax runner ms, ms waiting` line per request to simio or the runner, and on an iPhone or iPad driven through the runner the latter, which tells how many reads a call made, through which route, and how long each took (D285). `w` is the part of `n` spent waiting for the request in front of it, often a polled screenshot (D771). | | `PHONEDRIVER_CRASH_PUSH` | on for an emulator, off for a physical device | `0` turns off, and `1` turns on for a physical device too, Android telling phonedriver of an app's crash or hang as it happens, through the activity controller. A stall there can restart the phone's system; no physical phone has run it. See [Logs and crashes](#logs-and-crashes), D685 and D1145. Read when the daemon starts. | | `PHONEDRIVER_TREE_AUDIT` | off | Android: `1` has every tree read come with a whole walk of the screen and writes to `daemon.log` whether the answer matched it, without the tree's text (D638). It doubles the work of a read. Read when the daemon starts. | | `PHONEDRIVER_TRACE_SCREENS` | off | `1` copies every screenshot next to its trace file. | | `PHONEDRIVER_AGENT_JAR` | built by `android-agent/build.sh` | Build time only: use this prebuilt Android agent jar. | | `ADB_SERVER_SOCKET` | `tcp:127.0.0.1:5037` | The adb server to use, for example a tunnel to another machine. | | `PHONEDRIVER_TEST_DEVICE`, `PHONEDRIVER_TEST_IOS_UDID`, `PHONEDRIVER_BENCH`, `PHONEDRIVER_BIN` | none | Tests and benchmarks only. | The runner's own `PHONEDRIVER_PORT`, `PHONEDRIVER_BUILD` and `PHONEDRIVER_UDID` are set by phonedriver for the iOS runner and are not for you. ### A device that does not answer `devices` asks each Android device for its system once per connection, and waits 5 s. One that accepts the command and answers nothing (an emulator on its way out, a wedged USB link) is listed with `not answering` in the OS column and a line under the table, `android:emulator-5562 is not answering: emulator-5562 did not answer `adb shell` within 5 s and is not asked again for 30 s` (`--json` and the MCP reply carry the same as `not_answering`). Restart that device, or leave it: calls about other devices do not wait for it. `--device` takes an id from `devices`, the part after its colon, or the name `devices` prints beside a Simulator, in any case, as `boot` and `fork` do; when two Simulators have the name, the command is refused with their ids (D793). A phone or an emulator is named by id. A command asks only the devices it is about. `devices --device X` lists every connected id and asks `X` alone, and exits 4 when `X` is not connected (D985); a command that names a device, or a name no device has, asks no other device anything; and a device the device list below refuses by its id is never asked. An AVD's name is asked of the running emulators only when the name you gave is an AVD on this computer, or by `boot`, and is kept for the connection. ### A connection adb drops adb sometimes drops a device and takes the connection up again: the device reads `offline`, or is not listed, for a moment. A command for a device the daemon has been using waits up to 10 s for it to come back. If the drop ended a call, one that only reads (`snapshot`, `screenshot`, `find`, `where`, `wait`, `check` and `assert`) or a `launch --restart` is then run once more, and a line says so; a call in which the approval guard, or a standing order under `autonomous`, had let a tap through is not (D825). Nothing that may change the device is run again: a cut `record`, `demo`, `env`, `snapshot rm` or `profile rm` fails `interrupted` (D927). A `type` is answered by what its field shows once the device is back: text that landed is not sent again (a `--submit` not yet sent is, unless the approval guard holds it on that screen), a field that still shows what it showed before gets the text once more, and the reply says which. A password or a `--secret` is never typed again: it counts as landed only when a field that was empty shows one dot for each character. A tap or any other action that was in flight is not sent again. Where nothing can be told, the call fails `interrupted` and exit code 4, says the action may or may not have landed, and a replay says which `--from` to run for either case. A device that stays away is waited for once; later commands fail at once. ### Devices an agent must not touch On a shared adb server (a rack of test phones, a staff phone left charging) the fence is a device list the daemon enforces. A device the list does not allow, or denies, behaves as if it were not connected: `devices` does not list it, `doctor` does not probe it, every call that names it (`--device`, `PHONEDRIVER_DEVICE`, `devices {use}`, a replay or the GitHub Action) gets the same "no device" error as for a typo, `--force` does not change that, and the agent is never pushed to it. Entries are the ids `phonedriver devices` shows (`android:emulator-5554`, `android:192.168.1.20:5555`, `ios:`, `sim:`), with or without the prefix, or an Android phone's hardware serial (`ro.serialno`, the number in `adb devices` over USB), so one rule hits the same phone over USB and over Wi-Fi. (Emulators from one system image share a serial: name an emulator by its id.) The serial is read from the phone only when an entry could name it and the id did not already settle the question: one read-only `getprop`, and nothing is pushed. A device that the ids alone settle, because a deny entry names it or an allow list holds only ids and not its own, is not asked anything, not even its Android version. A read that fails, comes back empty or gets no answer in 5 s hides the phone from a deny list and does not admit it to an allow list; a failed read is asked again on the next call, and a phone that gave no answer after 30 s. A Simulator the list hides is not offered by `boot` and is never started. An AVD gets its id only once it runs, so before a boot only `deny avd:` hides it; once it runs, it is judged by its id like any other device. When a source cannot be asked (no Xcode, no adb server), the "no device" error lists only the devices the list shows. When the daemon cannot say what the list hides (the file has an error), `doctor --device` probes nothing. Three places set the list, and they combine as follows: a device is hidden when any deny entry from any place names it, and, for each place that has an allow list, when that list does not name it. So a machine-wide file's allow list cannot be widened by an MCP client's `env`. - `PHONEDRIVER_ALLOW_DEVICES` and `PHONEDRIVER_DENY_DEVICES` in the environment that starts the daemon (for an MCP client, the server's `env`). - The file `devices` in the phonedriver home (`~/.phonedriver/devices`, or under `PHONEDRIVER_HOME`), for a setting that holds for every agent on the machine. It is read again whenever it changes, so adding a `deny` line takes effect on the next call. ``` # the lab rack allow android:emulator-5554 allow android:R5CT123 deny android:0123456789ABCDEF # Maria's phone ``` A line that is not `allow ` or `deny ` makes every device unavailable and the error names the file and the line: a list that cannot be read must not leave a phone open. `phonedriver devices` on a terminal ends with `1 device hidden by the device list`, followed by `(1 because it did not answer, so the list could not read its serial)` when that is why; the MCP `devices` reply says nothing about hidden devices. When the list hides every connected device, `devices` says `no devices` and the count, and does not list what could be started. The list covers what goes through the daemon. `wifi`, `ios setup` and `ios register` are commands a person runs on a device by name, and they talk to the device without it. The list is the person's setting, as with `PHONEDRIVER_APPS_UNDER_TEST` (D100): an agent with a shell on the computer can start its own daemon without it. ## App scope `PHONEDRIVER_APP_SCOPE=com.example.app,com.example.other` limits the daemon to those apps, so a phone that is signed in to real accounts can be handed to an agent that tests one app (decision D102). The daemon enforces it under every verb; it is the person's setting in the environment the daemon starts with (for an MCP client, the server's `env`), and no tool argument sets or clears it. It differs from `PHONEDRIVER_APPS_UNDER_TEST`: that variable lets phonedriver clear or uninstall apps Gradle installed, and restricts nothing the agent can read or tap. Use both for an app under test on a real phone. **In scope without being listed:** the system's permission, installer, VPN consent and crash dialogs that phonedriver already recognises as alerts, the keyboard window, and the status and navigation bars of the system UI (`com.android.systemui`; never read, so no notification text). Another app's window shaped like a bar is outside the scope. **A screen with no app in the scope.** A tree that shows no window of an app in the scope (an empty tree, which is also what a dark screen or a tree read too early looks like) counts as outside: input and screenshots are refused until a tree names the app. **Reads.** `snapshot`, `find`, `wait`, `page`, OCR, `compare` and the replies of actions show nothing from a window of an app outside the scope. The header says `app (outside the app scope)` and lists no elements. The home screen is such an app: it lists apps and may carry widgets, so its content is never shown, while `press home` still works. `screenshot` is refused while any window of another app is on screen (a notification shade, a share sheet, a split-screen app, a picture-in-picture window): the picture cannot be cut by window, so it is refused, not blanked. The check runs before and after the capture. Traces, saved steps and `replay --screens` come from these replies and screenshots, so they hold nothing else. **Actions.** `tap`, `type`, `clear`, `swipe`, `scroll`, `drag`, `pinch`, `press` keys, `clipboard set`, batch steps and `then` paths are refused while a window of an app outside the scope is on screen. `press back`, `press home`, `press lock` and `launch` of an app in the scope are allowed, so the agent can get back. `press recents` and `press notifications` are refused. `launch` and `open` of an app outside the scope are refused. `open ` needs `--app ` with a package in the scope, because a link can open any app. An `intent:` URL that names a component or a selector is refused, since Android starts that activity whatever app is named, and the agent refuses an `open` whose link would open in another app. `clipboard get` is refused, since the clipboard may hold what was copied in another app. **Pages.** `page` reads the web page of the app in the scope that the check found on screen, not whatever app is in front a moment later. **Apps, logs, network, settings.** `apps` lists only apps in the scope, and `stop`, `clear`, `uninstall`, `grant`, `revoke` and `notify` on any other app are refused as if it did not exist. `logs` and `wait log` read only an app in the scope; `wait log` without `--app` uses the scope's only package and is refused when the scope names several. On the Simulator the log is filtered by the app's own container folder, so another app whose bundle has the same name is not read. `network` is allowed (it shows device state, not app content), with the owner of a VPN outside the scope shown as "an app outside the app scope". `setting` is allowed: it reads and writes typed system settings, not app content. `apps install` is allowed; it adds or updates an app, and the app cannot be used unless it is in the scope. `checkpoint` saves and rewinds the data of an app in the scope; on an emulator, where it would otherwise save the whole device, it saves the app in front instead, and rewinding to a whole-device checkpoint saved without the scope is refused, because that puts back every app's data. **Refused whole.** `shell` is refused: `am start`, `input` and `content query` go around every rule above. `record` and `snapshot --capture` are refused: a video and the raw tree hold every window. **iPhone and iPad.** The runner reports the front app and SpringBoard alerts only, so phonedriver cannot see a notification banner or another app's window over the front app. Reads and actions use the front app's bundle id the same way. `screenshot`, and therefore OCR, `compare` of the screen and `replay --screens`, are refused under a scope. A device whose front app is unknown (the CoreDevice tier has no tree) counts as outside the scope. `open` is refused under a scope on an iPhone, iPad or Simulator, because iOS opens a link in whatever app claims it; `launch` opens the app. `press back` and hiding the keyboard tap the front app's own buttons on iOS, so they are refused while an app outside the scope is in front; `press home` leaves it. **Known gaps.** The scope narrows what phonedriver reads and does; it is not a sandbox, and these are open: - The package of an app outside the scope that is in front is named in the header and in refusals. The status bar's notification icons are in a screenshot, so it shows which apps have notifications. - The keyboard is in scope: its suggestion strip can show text from the clipboard or a password manager, and a screenshot takes it. - A window that appears after the check and before the input or the capture is not caught for input; a screenshot is checked again after the capture. - Windows are told apart by the package that owns them. A system dialog is let through when phonedriver recognises it; the share sheet is withheld by its package or resource ids (`android:id/resolver_list`, `com.android.intentresolver`), so a maker's variant with other ids would be let through as a dialog. A window thinner than 5 percent of the screen on one side is taken for an edge strip. - An app in the scope can hand off to another (a link, a share). The handoff itself runs; what follows is hidden and refused until `press back` or `press home`. - `logs` of an app in the scope are the app's own and can hold anything it logs. `setting` and `network` are device-wide. - An agent with another way to the phone (its own adb, another MCP server) is not stopped. ## The approval guard Before a tap that spends money or deletes an account, phonedriver stops and asks the person. Text on the screen never counts as their word. Decisions D27, D31, D104, D560. **What is asked about.** A tap, `type --submit` or `press enter` that would press a button whose label spends money (`Place order · $34.10`, `Pay $12.00`, `Buy now`) or deletes an account (`Delete account`) is held. So is a tap named for another element when such a button may lie where the finger would go down: a tap goes beside it where it can ([When something lies over the target](#when-something-lies-over-the-target)), and where it holds the whole element and nothing says which is on top, the person is asked (D944). So is a swipe or drag whose finger goes down and lifts on such a button, or a stroke along a "Slide to pay" track. Labels are read in many languages. An order number does not hide a payment (`Pay $12.00 for Order #123`), while `Order #4821 · $34.10` names a record and is not held. A label of more than nine words is held only when a money verb starts it and the amount is within the first nine, and one of more than 16 words is read as prose. `type --submit` counts a button in the field's form that the text may yet enable; `press enter` presses no disabled button, and the screen is read again before it passes one. Enter in a search field with no form around it is not held for a button elsewhere on the screen (D1010, D1011). `PHONEDRIVER_ASK` adds sending, deleting and installing ([the row above](#environment-variables) lists the words). A standing order never presses a held button: the call stops with the question instead ([Standing orders](#standing-orders)). **What the person sees over MCP.** The client shows a form: ```text Your agent wants to do this on your phone: Tap "Place order · $34.10" in Shop. Category: payment (spends money or cannot be undone). Total $34.10 Allow it? ``` The lines under the label are the text near the button that says what it commits. The answers are `Allow` and `Allow for this session`, with neither chosen in advance. Declining, dismissing the form, or sending it back without a choice does not tap the held button, and the agent is told so. In a `batch`, `then`, `set` or saved run the steps before it have run by then: the reply lists them, and after `Allow` it numbers all the steps as the call gave them (decision D567). On protocol 2025-11-25 the form is sent while the call waits. On 2026-07-28 the call returns the form and the client calls the same tool again with the answer; an answer counts only on a repeat of that exact call, with the same arguments, and the server keeps one open question at a time. **When the client cannot ask.** A client that cannot show a form, whose form fails, or that dismisses it within a second (as `claude -p` does) gets the question put on the page `phonedriver live` serves, when one is open ([Watch the phones in a browser](#watch-the-phones-in-a-browser)): Allow there allows that one tap. With no page open, the agent is told that the button was not tapped and to ask the person in chat. **On the command line.** Nothing is asked. The command prints what was held and the text near it, and exits with code 5. The agent asks the person in chat and runs the same command again with `--autonomous` only once they say yes. **What an answer covers.** `Allow` covers the one tap it was asked for, and that tap is sent at most once: after a dropped or moved connection the call fails `interrupted` instead of running again, a button back on screen for a standing order is asked about again, and a replayed Simulator tap you allowed that seems dropped is not tapped again (D825). `Allow for this session` covers later taps of the same kind (payments, say) in the same session until the daemon stops, and no other kind. A file copied to or from a phone is asked about each time, whatever the answer was for the last one ([Files to and from the device](#files-to-and-from-the-device)), and letting a stopped agent go on offers `Allow` alone. After the person answers, the screen is read again before the tap; if the button's label or the text near it changed, nothing is tapped: a single call answers with what the button now says, and a batch asks again. If another app is in front by then, nothing is sent at all, no tap and no scroll looking for the button, and the call says which app the person approved it in and which is in front (D560). **Several steps in one call.** In a `batch`, or a `tap` or `type` with `then`, the steps before the held one run once, the question is asked at the held step, and after `Allow` the call goes on from that step, with the answer covering that step alone. `set` is asked the same way when one field's tap is held; the fields before it stay set. A run exposed as a tool (`phonedriver expose`) replays the approved step alone and the steps after it without the approval. **Turning it off.** `autonomous: true` on a tool call, `--autonomous` on a command, or `PHONEDRIVER_GUARD=off` for the whole process skips every question. Use them only when the person has granted the agent full autonomy. ## A touch that would land elsewhere Before a touch, phonedriver checks what it would land on. It sends nothing, and says `an incoming call took the screen (System UI); nothing was sent` or `another app took the screen (); nothing was sent`, when another app is in front that the call was not aimed at, a call's screen is in front, or a window over the app holds a point of the touch (a call's heads-up pill, an alarm's banner). A tap on a control of the pill itself is sent. The keyboard, a permission dialog, the status and navigation bars and the app's own popups never stop a touch. The person answers or declines the call, then the same command runs again. `nothing more was sent` says earlier touches of the same call went (a search that scrolled before the call came). A `wait` that ends with another app in front says what took the screen after its timeout, and `snapshot` ends with a `hint:` line while a window of another app is over part of the screen. On Android the agent checks the window list again just before it injects and, when a window the check did not know has appeared, sends nothing; the call runs once more, and ends `a window appeared over the touch; nothing was sent` if it happens again (decision D517). A target that is not found while a system window lies over the app is answered `no element matches "Text"; a System UI banner covers the top of the screen, so the element may be under it: wait or dismiss it` (decision D568). A drag the device rejects because another app came in front under it ends the same way. On an iOS Simulator a touch that starts in the top 200 points waits for a notification banner over it to leave, up to 8 s (a banner that stays is an error, and nothing is touched). It looks twice, 150 ms apart, so a touch there is made about 0.2 s after the call; the reply waits for the screen from when the touch was made (D879, D882). A window down one side of the screen with nothing in it (MagicOS's gesture areas) covers nothing. Decisions D362 and D517; proved on an emulator and, for D362, on the Honor X8. On an iPhone or Simulator, `type --into` and `clear` also look after their tap that the field has focus in the app they were aimed at, and send nothing otherwise: `focus moved to ; nothing more was sent` (a notification banner that arrived under the tap opens its app), or `@e4 did not take focus after the tap, so nothing was typed; look at the screen, then type again`. The refusal for another app is proven on Simulators and, with nothing installed, on a physical iPhone (13 Pro Max, iOS 27.0.1). A field that already had focus is typed into or cleared without that tap, after one read that shows it still focused; a field in a web page and an addition are tapped, and wait a second. Android types into such a field without a tap too, web pages included, when it is the only field that reads as focused and in the window on top; for an addition the agent first puts the caret after the last character. A field beside a dialog that lets touches through cannot take keys while the dialog is up: nothing is sent, and the refusal names that window (`input focus is in another window of …`). A window that came up after the call aimed at the field takes the keys. When the tap for the field brought it up with a field of its own focused, as a search screen, a sheet or a popup does, that field is the one typed into: a replace empties it, `--append` adds after what it holds, the reply's `verified` is about it, and plain text stays out of it if it takes a password. On Android a text that did not land is not sent a second time while another field reads as focused. `type` with no `--into` reads the same way right before its keys and sends nothing when another app is in front or no field has focus. On Android the agent itself checks, right before each send of text and of `type`'s own Enter, that the app it is meant for still holds input focus, and sends nothing otherwise (`focus moved to `; `press enter` is not checked, and focus that moves during a long keys text is not seen); a screen of another package in the app's own task, as Settings' search is, counts as the app. On Android, each send of text or Enter names the app it is meant for, and the agent sends nothing when another app would get the keys: `focus moved to ; nothing was sent` (`nothing more` after a tap). A screen of another app inside the same task goes through, as Settings' search does. Proven on an API 37 emulator and an Honor X8 (Android 13). Two limits seen on the Honor X8: for a few seconds after a tap on a field that holds text, `snapshot` says `a dialog is in front`, because the caret's handle is a small window of the app; and where the keyboard lies over a button of a dialog that lets touches through while the dialog holds input focus, the Back that `tap` presses to hide the keyboard closes the dialog, and the reply says the button is no longer on screen. On its side, the Honor X8 still lists its three navigation buttons as the app's, and replies say `another app (gesture) is over the screen`; taps and typing reach the app. Chrome gives a number input's label as its text, so `type` into one answers `NOT verified` although the page took the value; read the page before typing again (API 37 emulator; 0.1.8 does the same). ## A screen that comes back A reply after an action prints only what changed. When the screen is a new one, but is one you were shown 2 to 8 calls ago, it says so instead of printing it again: ``` ok tapped @e27 "Taps" screen from 4 calls ago ("Last tap: none") is back, except: - @e1 + @e69 text "Last tap: none" ``` The refs of that screen hold again, apart from the lines listed. The closing of a dialog or a step back to the page just left still reads `the screen before the last one is back`. The reply is shortened only when at most a quarter of the new screen's lines differ, in the same app. `snapshot` always prints the whole screen, and `snapshot --diff` compares with the screen before only. A screen you saw through `--interactive`, `--within` or `--max-lines` is not remembered. Decisions D546, D547. A list's size is part of what a reply compares: a list that grew or shrank reads `~ @e1 list 12 rows → 13 rows`, whether or not its new rows are on the screen (decision D571). ## Debugging When something does not work: - `phonedriver doctor` checks the toolchain, devices and the socket, and says how to fix each problem. - `$PHONEDRIVER_HOME/daemon.log` (default `~/.phonedriver/daemon.log`) holds the daemon's own messages and startup errors; past 4 MiB it is moved to `daemon.log.1` when the next daemon starts. - `$PHONEDRIVER_HOME/traces/.jsonl` has one line per request: method, parameters, the device a device call went to, whether it reached another screen, the reply's summary, `ms` and settle time. Typed text is recorded only as a length, and so is the text of a text target. The reply's summary and an error's message are recorded as returned, so they can name elements from the screen (`tapped @e6 "Busy"`, `no element matches "Pay €49.99"`, an approval refusal's `On screen:` lines): read trace lines before you share them. Start the daemon with `PHONEDRIVER_TRACE_FULL=1` to keep observation text and text targets, and `PHONEDRIVER_TRACE_SCREENS=1` to keep screenshots. A running daemon keeps its options: `phonedriver daemon stop` first. - iOS: `$PHONEDRIVER_HOME/runner/.log` is the runner's output, and `runner//build.log` is its first build. - `phonedriver daemon stop` stops the daemon and the iOS runners it started, and waits up to 5 s for its process to end, on Windows too; if it has not ended, it says so and exits 1 instead of reporting success (D909). The next command starts a new one, as does the next call of an MCP server that was running (D984). A runner an earlier daemon left running (one killed with `kill -9`, for one) is ended by the next `daemon stop`, which says so; ending the runner the stopped daemon started itself adds no line (D961). - Ctrl-C of a `wait` ends the wait in the daemon too, so the next call does not stand behind it. Ctrl-C of a `scroll --until` or `scroll --collect` ends it after the drag in progress (D523; it used to go on for up to 30 drags, and the next call waited 13 s behind them); a tap, `type`, `set`, `batch` or replay that has begun runs to its end. A daemon that is killed during a call that may have touched the device says so (`The call may have acted before it stopped: run phonedriver snapshot before you repeat it`); a read such as `snapshot` or `find` does not, and so does `disconnected` on a Simulator that was shut down. A call that waited 2 s or more behind another ends its summary `· waited 4.0 s for the wait before it on this device` (D354); a read such as `snapshot` or `find`, which has no summary, ends with the line `waited 10.0 s for the wait before it on this device`, and the JSON reply of every such call has `waited_ms` and `waited_for`. A call that did not queue is unchanged. Exit codes: `0` done, `1` the command failed, `2` the command line is wrong, `3` a person must act on the device (unlock, trust, allow, or resume an agent they stopped), `4` no matching device or it was disconnected, `5` an action that spends money or cannot be undone needs the human's approval (add `--autonomous` only when the user has granted full autonomy; see [The approval guard](#the-approval-guard)). On a terminal, a first command that takes more than a second says what it is doing (building the runner, starting the agent). ## Device on another machine, Wi-Fi and shell ### Use a device on another machine Put each machine that has devices in a `phonedriver.toml` (the nearest one from the working directory upward, else the one in phonedriver's home) and run `phonedriver farm up`. It needs the same `phonedriver` version on every machine and `ssh` that works without a prompt; nothing listens on any machine, and there is no tunnel to make: ```toml [hosts.winbox] ssh = "me@winbox" binary = "C:/tools/phonedriver.exe" home = "C:/tools/pd-home" adb_server = "tcp:127.0.0.1:5037" sdk = "D:/Android/Sdk" [hosts.minibox] ssh = "minibox" ``` Only `ssh` is needed; `binary` is the host's path to phonedriver (default `phonedriver`), `home` its `PHONEDRIVER_HOME`, `adb_server` and `sdk` its `ADB_SERVER_SOCKET` and `ANDROID_HOME`, and `shell` (`sh`, `cmd` or `powershell`) lets a path hold a space. ```sh phonedriver farm up phonedriver devices phonedriver --device winbox/android:emulator-5554 snapshot phonedriver farm status phonedriver farm down ``` `farm up` connects every host at once and prints a row each: `up`, its version and how many devices, or `down` and why. `devices` lists every host's devices as `host/id`. A bare id works when only one host has it. Every command that works through the daemon takes a device of a host as it takes a local one (`doctor`, `init`, `start`, `wifi`, `ios`, `boot` and `fork` work on the machine they run on, and say so for a `host/device`; D557): `screenshot -o`, `record`, `files`, `live`, `bug`, `replay` and a scene (`--as alice=winbox/android:emulator-5554 --as bob=minibox/sim:UDID`). A path you give is on your machine: `record -o clip.mp4` writes `clip.mp4` here (the host also keeps its own copy under its `tmp` folder for a day, as for a local run), and a file over 256 MiB is refused before it is sent. Saved runs, scenes and pixel baselines are files on your machine. If a link drops, the next call says `host winbox is down: ` (exit code 4) and the link comes back by itself after 1 s, then 2 s, up to 30 s; `phonedriver farm status` shows each host. A host on another version is refused and both versions are named; a host binary older than this feature says it is too old and what to install. Approvals, the stop switch and the live page work as for a local phone: the question reaches you, and your answer goes to the host that has the phone. The old way still works for one device: forward the host's daemon socket yourself and point `PHONEDRIVER_SOCKET` at it. ```sh ssh -N -L /tmp/phonedriver-mini.sock:/Users/you/.phonedriver/run/daemon.sock mini & export PHONEDRIVER_SOCKET=/tmp/phonedriver-mini.sock phonedriver snapshot ``` Two things differ from a local run. `phonedriver screenshot` prints a path on the machine that has the device; `phonedriver screenshot shot.png` (or `-o shot.png`) writes the file on your machine instead. The MCP `screenshot` tool returns the image itself, so it works unchanged. ### Several agents on one Android phone Add `+` and a short name to a device id and the session works on a lane: a hidden screen of its own on that phone (Android 13 and later). Each lane has its own lease, so several agents use one phone or emulator at the same time, and the phone's own screen stays free: ```sh PHONEDRIVER_SESSION=one phonedriver --device emulator-5554+a launch settings PHONEDRIVER_SESSION=two phonedriver --device emulator-5554+b launch clock phonedriver devices ``` ```console ID MODEL OS TIER LEASE DISPLAY android:emulator-5554 sdk_gphone64_x86_64 Android 17 (API 37) agent - main android:emulator-5554+a sdk_gphone64_x86_64 Android 17 (API 37) agent one (idle 3s) hidden (display 13) android:emulator-5554+b sdk_gphone64_x86_64 Android 17 (API 37) agent two (idle 3s) hidden (display 12) ``` For MCP, give each agent its own lane in its config: `"env": { "PHONEDRIVER_DEVICE": "emulator-5554+a" }`. With one device connected, `+a` is enough. The name is 1 to 8 lowercase letters or digits. `press landscape` and `press portrait` are refused on a lane: they turn the phone's own screen (D936). A Simulator and an iPhone have no lanes, and `+name` on one is refused as such (D965). A lane closes, and the apps on it with it, when its session releases it (`phonedriver release`) or has made no call for ten minutes. On an emulator a lane's video is two pixels a point at 15 frames a second, because an emulator's encoder is software and falls behind at full size; screenshots and text read from pixels are the same as on the main screen, and a recording of a lane is that size. An app runs in one place at a time. If two lanes launch the same app, it moves to the second one and the first is left on its home screen, so give each lane a different app, or give one of them a user of its own (below). The clipboard is one for the phone, so lanes take turns to paste. Tried on one emulator (API 37) with two lanes beside the main screen; not on a physical phone. #### One app under several accounts (experimental) A lane can run as an Android user of its own, so one app runs twice on one emulator, each with its own data and account: ```sh phonedriver --device emulator-5554+b profile new --app dev.phonedriver.testbed phonedriver --device emulator-5554+a launch dev.phonedriver.testbed phonedriver --device emulator-5554+b launch dev.phonedriver.testbed phonedriver release ``` `profile new` makes a clone profile of the main user, named `phonedriver-`, and installs the packages `--app` names into it; they must be installed on the device already. A device holds one clone profile, and a second lane's `profile new` makes a work (managed) profile; the reply says which. One app then has up to three accounts: the main user's, on any other lane or on the screen, and each profile's. `devices` shows the lane's user, and `launch` and `open` on it say `as Android user N`. In a scene, `--profile` makes the profile for one run and removes it when the run ends, passes or fails: ```sh phonedriver replay chat.steps --as alice=emulator-5554+a --as bob=emulator-5554+b --profile bob=dev.phonedriver.testbed ``` For a third account, bind another name to another lane and give it a `--profile` too: `--as carol=emulator-5554+c --profile carol=dev.phonedriver.testbed`. The profile and everything in it are removed when the lane's holder runs `release` (or its MCP server exits), on `daemon stop`, when the daemon leaves after 15 idle minutes, and on `phonedriver --device + profile rm`. A lane that has been idle for ten minutes keeps its profile until one of those. `daemon stop` during a `profile new` waits for it, up to 420 s. If a daemon is killed, the user stays on the device: the lane runs as it when next used, and `profile rm` removes it. A removal that the device does not carry out is said, and the command fails. A `profile new` that is refused lets go of a lane it was the first call on. Making a profile is heavy for the emulator: `profile new` took 11 to 267 s (about 40 s on a quiet computer) on API 37 emulators on a Windows host, and Android's services stay busy with the new user for up to two minutes after. With one app running in it, a profile took 0.4 to 0.7 GB of a 6 GB emulator's memory, given back when it is removed. On a busy computer a scene has failed with apps that stopped answering or a lane that answered `disconnected`, and six times an emulator process exited: twice for a reason that was not found, and four times in the Windows host's NVIDIA graphics driver, each time on an emulator with profiles on it (D622, D624). On a Windows computer with an NVIDIA graphics card, start an emulator that is to hold three accounts with its software renderer: `emulator -avd -gpu swangle_indirect -feature -Vulkan`. Drawing on the card, the graphics driver ended the emulator, with Vulkan on and with it off; on the software renderer three accounts passed 6 of 6 runs with no fault, a small count, with replays about as long (D624). On a profile lane, `launch`, `open`, `app stop`, `clear` and `uninstall`, `grant`, `revoke` and the app's logs act in the lane's user. `checkpoint --app`, `storage`, `perf`, `drain`, `files`, `setting`, `env`, `install`, `notifications`, `page`, `snapshot --source` and `launch --jump` are refused there, because they would read or change the main user. `camera`, `location` and `network` change the emulator's hardware, which every user shares. `shell` runs as the main user. A crash of the same package under the other user can be reported on the lane. The agent's paste reaches every profile, so the main user and the profiles see each other's clipboard. Refused: a `--device` without a lane; a device whose `pm get-max-users` is 1; a third profile on one device; a physical phone without `--on-phone` (not proven on one); iOS. Decisions D615 to D624. ### Android over Wi-Fi An Android 11 or later phone on the same network needs no cable. On the phone, turn on Developer options, then Wireless debugging. `phonedriver wifi pair` shows a QR code in the terminal (the flow Android Studio uses): ```sh phonedriver wifi pair ``` On the phone choose Wireless debugging, then Pair device with QR code, and scan it. phonedriver finds the phone on the network, pairs, connects, and prints `connected: android:192.168.1.20:41233`. It waits 2 minutes for the scan. Exit code 3 means nobody scanned; 1 means adb's mDNS is unavailable or pairing failed, and the message says what to do. Tested on a HONOR X8 (Android 13). If the QR does not work (the phone and computer are on different networks, a guest network, or a router that blocks mDNS), pair with the code instead. On the phone choose Pair device with pairing code. Then: ```sh adb pair 192.168.1.20:37099 adb connect 192.168.1.20:41233 phonedriver devices ``` The first address and the six-digit code are on the pairing screen; the second address is on the Wireless debugging screen (the port changes each time wireless debugging is switched on). The phone then appears as `android:192.168.1.20:41233`. If it shows `offline`, `phonedriver doctor` says what to check. #### Away from your Wi-Fi Wireless debugging works only on the Wi-Fi it was switched on for. To use a phone from anywhere you can reach it, for example over [Tailscale](https://tailscale.com), switch the phone to classic adb over TCP while it is connected by cable or already over Wi-Fi: ```sh phonedriver wifi untether ``` It lists the phone's addresses (`wlan0 (Wi-Fi)`, `tun0 (Tailscale)`), stops if the phone is on mobile data only, runs `adb tcpip 5555`, connects to the first address that answers and prints `connected: android::5555`. With more than one device pass `--device android:`. Tested on a HONOR X8 (Android 13). On a Mac, an adb server that macOS keeps off the local network is restarted by both commands. A phone connected in more than one way is one device: see [One phone, several connections](#one-phone-several-connections). This is opt-in on purpose. adb then listens on port 5555 on every network the phone joins, until it reboots. A new computer still has to be allowed on the phone's screen, but do this only on networks you trust, or with Tailscale on both ends and the phone's other networks untrusted. `adb -s :5555 usb` or a reboot turns it off. See decision D30. ### One phone, several connections A phone or emulator that adb lists more than once (a cable and Wi-Fi, the TLS port and port 5555, `emulator-5554` and `adb connect 127.0.0.1:5555`) is one line in `phonedriver devices`, with one lease: ``` ID MODEL OS TIER LEASE android:emulator-5566 sdk_gphone64_x86_64 Android 17 (API 37) agent - android:emulator-5566 is also connected as 127.0.0.1:5567 ``` `--device` takes either name. The id is that of the first connection phonedriver opened, else the cable or the emulator's own name, then an address, and it does not change when that connection goes while another is listed (`devices` then says `is driven over ...`). When the connection in use goes and another is there, the session carries on over it: refs, the lease and a lane's hidden screen with the apps on it are as they were, and the first reply afterwards ends with `moved from emulator-5566 to 127.0.0.1:5567` (`--json`: `moved`). A call that only looks, or that had sent the device nothing yet, is carried out over the other connection. One that may have reached the device is not sent twice: a `type` is answered by its field, as in [A connection adb drops](#a-connection-adb-drops), and anything else fails `interrupted` (exit code 4) and says so: ``` error: the connection to android:emulator-5558 dropped during this tap (device android:emulator-5558 disconnected): it may or may not have landed, and it is not sent again; moved from 127.0.0.1:5559 to emulator-5558 hint: Check with the command the message names, `phonedriver snapshot` where it names none, and send only what did not land: running the whole call again can repeat what did. ``` A `type` cut the same way answered: ``` ok typed into @e32 · the connection dropped, and the field already held the text · moved from emulator-5558 to 127.0.0.1:5559 · verified ``` A connection that stalls without closing, as Wi-Fi does when a phone walks away, is given up after about 5 s of a call waiting on it, when another connection of the phone still answers. The move waits for the new connection's first picture: on API 37 emulators on a Windows PC it took about 0.15 s on a quiet one and 1 to 2 s, once 9 s, with the guest load between 5 and 10. If the agent did not survive (more than 10 s with no connection), the line adds that the hidden screen is new and empty; when the agent is replaced over the same connection, a reply says `the agent on was replaced` (D930). With one connection nothing changes: a drop is retried as before. A cut call says which command shows whether it landed (`files list` for a push), and a cut `batch` which steps ran (D933, D934). A push is written beside the file's name and moved there once whole, so a cut one leaves nothing under the name; a hidden `.phonedriver-part-…` file can stay in the folder (D935). A `files` transfer on a stalled connection is given up like any call (D932). An answer to an approval question is not acted on when the agent was replaced since it was asked (D929). Connections are folded only on proof: the same serial number, the same boot id, and a shell started over one found over the other. Emulators of one version share a serial number, and copies of one saved state share the boot id too, so the third is what tells two devices apart. Anything that cannot be asked stays a line of its own. Both connections have to be listed together once, by any command, before one can stand in for the other, and again after either of them dropped, since adb can take an address up again reaching another device (D928). While a device is held that happens by itself a few seconds after the connection is back; if the other one goes before then, the lanes on it are lost. Each connection is also asked which running device it reaches every time it is opened, the one the device is named after too, and nothing is started on another (D935); the device list hides a connection it does not allow, so an allow list needs each name or the hardware serial. Android only, seen on emulators with two connections; with a phone's cable and Wi-Fi it is not proven. Decisions D817 to D824, D928 to D935. ### Settings by key On Android 17, the Settings app answers the shell user's `cmd app_function` calls, and phonedriver uses them so an agent can change a setting without opening its screen: ``` phonedriver setting find dark theme # keys, what each accepts, and screens phonedriver setting get dark_ui_mode/dark_ui_activated # dark_ui_mode/dark_ui_activated = false phonedriver setting set dark_ui_mode/dark_ui_activated true # ok dark_ui_mode/dark_ui_activated = true phonedriver setting find "dark theme|media volume" # several searches in one call phonedriver setting set # several writes in one call phonedriver setting open dark_ui_mode # shows that settings screen phonedriver setting open "Dark theme" # the same screen, by the title it shows phonedriver setting restore [...] # writes back what your writes replaced ``` The API 37 emulator lists 182 settings on 196 screens; 105 can be written. A write answers with the value the device reports afterwards, and a refusal carries the device's reason. On a physical device, a setting the device marks as needing its user's confirmation (NFC, mobile data, the camera and microphone switches) answers `unsupported` without `--force`. Older Android, iOS and the Simulator answer that the device has no settings by key: use `shell` there. Decision D57. **Putting settings back.** The first write of a key answers `ok = true (was false)`, and the daemon keeps that first value in `settings-before/.json` under its home, owner-only. `setting restore` writes every kept value back and prints a line for each: `ok = false (was true)` for one it restored, ` = false already`, or `kept = 2: someone changed it since phonedriver did (before that: 5)` when the value is no longer the one phonedriver left, which stays. `setting restore ` restores that key only. Nothing is restored on its own, because the change may be what you asked for: `release` lists what is still changed. The record is a file, so a restore still works after the agent or the daemon that made the change has died. Settings changed with `shell` or by tapping through screens are not recorded. Decision D120. ### Logs and crashes On Android, `phonedriver logs` prints the last 20 log lines of the app in front (`logs ` for another, `--grep "error|warn"`, `--head 0` for all, `--since 300` to read five minutes back) and, first, its last crash. An action during which the app in front crashed carries the crash in its own reply, an `open` of an address included, also one that started an app which was not in front (D630, D632; `launch` has its own words, below): ``` ok tapped @e6 "Busy" · new screen alert android: "phonedriver testbed keeps stopping" ... crashed: dev.phonedriver.testbed stopped during this action: android.app.RemoteServiceException$CrashedByAdbException: shell-induced crash at android.app.ActivityThread.throwRemoteServiceException(ActivityThread.java:2581) hint: `phonedriver logs dev.phonedriver.testbed` prints its last log lines ``` In a `batch` the lines stand under the step during which the app crashed, and `--json` has them as that step's `crashed` (D836). A `set` or a batch step that fails carries them with the failure. **Pushed by the device (Android): on for emulators, off for physical devices.** On an emulator Android tells the daemon as it happens: the agent holds Android's activity controller, which the system calls when an app crashes or stops answering, so the reply needs no read of the log (D681, D682), and a tap that reaches a new screen skips that read (about 47 ms median on an API 37 emulator, D1145). It takes the controller only while no other tool holds it (`am monitor`, `monkey`), never replaces or clears theirs, and gives its own back when the agent ends after the daemon's goodbye (D1146); `doctor` has a `crash watch` line. A physical device is left off: Android waits for the controller at every activity start and resume while holding its own locks, so a stall there can end with Android's watchdog restarting the phone's system, apps and all. Hour-long soaks with it passed on emulators drawing in software; on an emulator drawing on a loaded host's graphics card the system was restarted, with it and without it; no physical phone has run it (D685). Start the daemon with `PHONEDRIVER_CRASH_PUSH=1` to have a physical device push too, or `PHONEDRIVER_CRASH_PUSH=0` to turn it off everywhere (stop a running daemon first with `phonedriver daemon stop`: it keeps the setting it started with). An emulator reached over TCP (Wi-Fi debugging) counts as physical. With it on, an app that stops answering is named in `crashed:` too, and an `act` or `wait` still reading its screen ends there instead of when the app answers again. One declared between two calls is said by the next action: ``` ok tapped @e34 "Cancel" · no change: the app drew the press and nothing after it not responding: dev.phonedriver.testbed stopped answering before this action, and no reply has said so: Input dispatching timed out hint: `snapshot` shows what is in front now; if Android put its "isn't responding" dialog up, its buttons close the app or wait for it ``` A crash or hang that happened between two calls is said by the next action on that app, within a minute, as `before this action, and no reply has said so`: an action asks about the app in front before it, the app it launches and the app in front after it, and one that fails prints it after its hint. A `snapshot` or another read does not use it up (D835). A `batch` runs no step after one whose app stopped answering, and neither it nor a `set` reads that app again before it replies (D834). Android declares an app unanswering only when it leaves input or a broadcast waiting, so a blocked app that nothing was sent to is not named. There is one activity controller on a device: while another tool holds it (`am monitor`, `monkey`), phonedriver leaves it alone, reads crashes from the log after an action as before, names no hang, and `doctor` says so; it takes the controller within 15 s of the other tool's end. A tool that takes it while phonedriver holds it is noticed within 60 s. Until then a crash is still read from the log, since an app that gives way to another with no word from the system is checked, but a hang is not named. On an iOS Simulator the reply says `crashed:` when an action leaves the home screen in front and the app's process is gone (D393). An iPhone's logs cannot be read. Decision D58. A `launch` whose app is not in front once the screen has settled, or sits under Android's dialog for its crash, says so at the end of its first line. When the app's crash is in its crash log: ``` ok launched Clock, but Clock crashed at start (`logs com.google.android.deskclock` prints its last lines) · new screen ``` On an iOS Simulator the crash comes from the report macOS writes under `~/Library/Logs/DiagnosticReports` (the newest one for the app since the launch began): the exception and the first frame in the app's own code, with no `logs` to point at, since a Simulator's logs cannot be read: ``` ok launched Testbed, but Testbed crashed at start: EXC_BREAKPOINT (SIGTRAP) in AppDelegate.application(_:didFinishLaunchingWithOptions:) · new screen ``` macOS writes that report some seconds after the crash, so the reply reads the Simulator's own log first. An action or a launch whose app died on a crash signal says so at once, and `bug` adds the function once the report is there (it waits up to 40 s after the action for it): ``` ok tapped @e37 "Send" · new screen crashed: dev.phonedriver.testbed stopped during this action: exited on SIGTRAP (from the Simulator's log; macOS's report with the function is not written yet) hint: `phonedriver bug --text` names the function once macOS has written the report ``` A replayed step carries the same words (`3. tapped @e37 "Send" · crashed: exited on SIGTRAP (…)`). An app the log says is alive, was force-quit (`simctl terminate`, the app switcher) or ended by calling `exit` is not called crashed, and no report is waited for (D660). One that ended some other way (a SIGKILL) and is gone from `launchctl list` is called crashed with `the app's process ended during this step; macOS had written no crash report yet` (D393). The app of a `bug` report is then the app that crashed. A physical iPhone has no such report or log on the Mac, and a crash after the reply is not caught. Decisions D356, D605, D660. When no crash was logged, the line ends `` , but {name} is not in front after {s} s ({package in front} is): it is still starting, or it quit at start; `snapshot` shows which ``. A screen of another package in the app's own task, as Settings' search is, is the app in front, so `launch Settings` over its search succeeds (D979). The crash dialog is recognised by its ids, not its words, so a device in another language gets the same reply with the app's name in that language (`…, but Horloge crashed at start` in French). An app that crashes after the reply is not caught: the next `snapshot` shows the launcher or the dialog. Decision D314. ### App shortcuts: `launch --jump` (Android) An Android app can offer shortcuts, the entries its home screen icon shows on a long press. `launch` on the command line ends with the ones it can start: ``` $ phonedriver launch Clock ok launched Clock · new screen … jumps: New alarm · New timer · Start · Screen saver $ phonedriver launch Clock --jump "New alarm" ok launched Clock at "New alarm" · new screen … ``` One call lands where the menu path would take several. An app that is not in front is opened first, then the shortcut is started: Android drops a shortcut's start while its app shows nothing. The list is read from the device each time, so there is nothing saved to go stale. A shortcut can lead into another app: Phone's `New contact` opens the Contacts editor, and the first line says so, `ok restarted Phone at "New contact", and com.google.android.contacts is in front · new screen`. `--jump` takes a short label, else a long one, compared as text is read (`wi-fi` starts `Wi‑Fi`). The line lists up to five names, in a launcher's order, and says how many more there are. `--restart` stops the app first; a saved run keeps the `--jump`. A jump is refused, with nothing done, when the app has no shortcut of that name (the reply lists them), when two share the name (it names their long labels), when the app disabled it, or when its label reads as one the approval guard knows for paying, deleting or deleting an account: a shortcut shows no screen to ask the person about, so launch the app and tap the button. Under an app scope only the scope's apps are listed or started. On iOS `--jump` is refused: iOS gives no way to list or start another app's shortcuts from a computer, and `launch` prints no `jumps:` line. The MCP server has no argument for it and its `launch` replies are unchanged. Decision D572. ### A touch that lands on another app (iOS Simulator) A call that sends touches (`scroll --until`, `set`, `replay`, `batch`, a tap by text) stops when another app has taken the screen since it began, and says so: `another app took the screen (Settings); nothing more was sent`, or `(the home screen)` for SpringBoard, and `Testbed crashed (EXC_CRASH (SIGTRAP) in …); the home screen took the screen; nothing more was sent` when macOS kept a crash report. The error is a refusal with the hint to run `snapshot`. A replayed step also checks the app it was saved on against the app in front, and a `batch` keeps the aim it began with. A touch already on its way when the app left is not recalled, and the reply does not claim it landed elsewhere: the step before the refusal is listed as done, which is true of the saved app, and the refusal for the next step says `nothing was touched`. A `launch`, `open`, `press home`, a tap that itself opens another app, an alert named with `--expect`, the keyboard and a share sheet the app opened are sent. **Not guarded: a banner.** A notification banner is SpringBoard's own and the Simulator's tree never lists it (`snapshot`, `snapshot --json`, 2 tries), so a tap that falls on a banner goes to the banner; `snapshot --pixels` reads its text by OCR but gives no frame. Whether an iPhone's runner lists one is not known yet. Decision D357. Keys name no point and go to whatever has the keyboard, so the app in front is asked for again before the erase of a `type`, before its text and its Enter, and before a `press` of a keyboard key; a different app ends the call with the same refusal, and the Home Screen's own search opening Spotlight is not one. **A switch that is under way as the keys go can still take them:** the Simulator names the app it is leaving for a moment (Contacts launched 0.2 to 0.7 s into a `type`, iOS 26.5). The reply then says `NOT verified: came to the front while this was typed`; look at both apps before typing again. Decision D566. A field with more than 32 characters is emptied by selecting all and deleting once. A Simulator drops the first such key after an app starts, and the delete then takes one character; when the field still shows old text, the erase is sent once more (D627). **A secret on a Simulator is not typed.** `type --secret` sets the value on the aimed app's own text field, so no key carries it and an app that comes up meanwhile gets none of it. It works on single-line, search and password fields. A web page's field cannot be set, nor a multi-line text view (which keeps a set value from its app), and nor can a secret be added to a password field that already holds text, since that reads only as dots: those are refused, with nothing typed. `PHONEDRIVER_SIM_SECRET_KEYS=1` where the daemon runs types such secrets as keys instead, as any text, and the reply says an app that came up could have received them. The same goes for a Simulator whose accessibility translator cannot be used. A physical iPhone and an Android device type a secret as before. Decision D625. XCTest on a Simulator writes what it reads to the Simulator's log, a plain field's value included. phonedriver turns that subsystem (`com.apple.dt.xctest`) off before its runner reads there, and resets it when it releases the Simulator. A daemon that was killed releases nothing, so the next daemon to start, and `phonedriver daemon stop`, put the subsystem back where this home turned it off; the setting file of a Simulator that is shut down is removed. `doctor` has an `xctest log` line for a Simulator where it is off, and says whether phonedriver turned it off; `xcrun simctl spawn log config --subsystem com.apple.dt.xctest --reset` puts it back by hand (D633, D634). Other text longer than 16 characters is sent to a Simulator in runs of 16, and each run after the first is sent only once the field has grown by the last one, so an app that comes up mid-way takes at most 16 characters. The call stops there and says how many were sent; nothing follows, `--submit`'s Enter included. A field that rewrites or cuts what is typed into it stops the call the same way. Past a tab or a line end only the app in front is asked for. Decision D626. ### Rows iOS lists and does not show XCTest lists some rows that are not on the screen. phonedriver leaves them out of what is shown, so `check`, `assert`, `tap` and `scroll --until` do not count them: what a row wholly off the screen holds (Settings' Add Language list put 2,161 elements of 43 pages at its top corner, D962), and, on a Simulator read through the runner, the rows of a list that an app hides under a view of its own, such as Settings' search showing `No Results` (D964). The second is proven on a Simulator only. Three limits, seen on an iOS 26.5 Simulator: - In Safari with its toolbar collapsed, a tap on a link in the bottom strip only expands the toolbar and still replies `ok tapped`: scroll the link higher, or tap again. - After a contact is deleted, Contacts' list can keep that contact's section in the snapshot, as a group with an empty cell. - `bug` can still say macOS has not written its crash report while the `.ips` is already in `~/Library/Logs/DiagnosticReports` (Photos, 30 to 60 s after the crash): run it again later, or read the file. ### Reading a whole list `scroll down --collect` scrolls a list a page at a time and prints every row it passed, each once and in the list's order: ``` $ phonedriver scroll down --collect ok collected 22 rows in 3 scrolls down: the list ended · new screen button "Google" "Services & preferences" button "Network & internet" "Mobile, Wi‑Fi, hotspot" … button "Tips & support" "Help articles, phone & chat" screen now: … ``` A row is its snapshot line without the `@ref`, followed by the lines of what it holds (`button "Dark theme" "Will turn on when Bedtime starts", switch "Dark theme" off`). `--collect 60` stops at 60 rows (100 when no number is given); it also stops where the list ends or after `--max` scrolls (30), and the first line says which. `scroll up --collect` gathers upwards and still prints top to bottom. Over MCP it is `scroll` with `collect: 60`, alone or as a `batch` step. The reply ends with the screen the list was left on, whose refs are the ones to act on; to act on a row that scrolled away, `scroll up --until` its text. Use it instead of several scrolls in a `batch`: a batch answers with one diff, so rows that passed in the middle are not in it. The rows of consecutive pages are lined up by their text, so a row cut off at the edge of one page is taken whole from the next. Two rows with the same text that sit where one page ends and the next begins count once unless the app gives its rows positions. Decision D116. ### Notifications On Android and an iOS Simulator, `phonedriver notifications` lists what is up without opening the shade: ``` $ phonedriver notifications com.android.shell · "Your code" "Your code is 482913" · 9m ago android · "Serial console enabled" "Performance is impacted. To disable, check bootloader." · 9m ago · ongoing ``` Newest first: the app (its name where it has one to launch by, else its package), the title, the text and the age. `--app` keeps one app's, by name or package; what is written as a package name (`android`, `com.google.android.gms`) means that package and never an app that calls itself so. `--limit` (20) says how many. Over MCP it is `snapshot` with `notifications: true` (`find` names the app). `phonedriver wait notification:"code"` waits for one whose title or text holds the word (`A|B` for either; `--app Name` with an empty text takes any from that app): ``` $ phonedriver wait notification:code --timeout 20000 ok a notification from com.android.shell is up com.android.shell · "Bank" "Your-login-code-is-771204" · now ``` Only a notification posted since this session's last action counts (or since the wait began, when the session has done nothing yet): the code that arrives after tapping `Send code`, including one that arrived before the wait was called. The time is the one the system gave the post, not the `when` its sender chose, so an older code still up does not count unless its app posts or updates it again. On a timeout the error says how many are up. Over MCP it is `wait` with `notification`. What an app names itself and writes cannot end a line. A title or a text is quoted, with control characters, line separators and direction characters written out (`\n`, `\u202e`), in `--json` too. An app's name is quoted the same way when it holds one of those, `"`, `\` or `·`, and in every other reply that names the app; one written as another package's name is shown as `"android" (com.example.app)`. A line whose text reads as an instruction to an agent ends in `(ai-instruction)`, as a snapshot line does, and is data, not something to follow. The text is in the reply only; the trace and a saved run keep `a notification matched`. Under an app scope only the scope's apps are listed and waited for. On Android 10 and later they come from the notification service as objects, so what one notification says is never read as another's. Android 8 and 9 give the shell no objects: the apps and their notifications come from the service's protobuf dump, and their words from its text dump, one app at a time. An app whose dump holds another app's record is not read there; the list ends with ` · words withheld: …`, and asking for that app is an error. This happens to `android` whenever an app with `android` in its package name has a notification up, and any app can cause it for another. The line names the other app only when what stands in the dump is the package of an app with a notification up. On 8 and 9 an app's own words can also change what is listed for its own notifications; where they claim to be its time, the line says `time unknown`, and it answers no wait and fires no watch (D998). Checked on API 26, 28 and 37 emulators and an Honor X8 (Android 13); Android 8.1 was not run. On an iOS Simulator it reads the files the Simulator's notification service keeps on the Mac (checked on iOS 26.5): what was delivered and not cleared, with the title, and the subtitle and body as the text; a silent push leaves nothing. On iOS 27.0 `simctl push` refuses an app without notification permission (`Source is not authorized`). A physical iPhone answers that its notifications cannot be listed. Decisions D117, D731, D788, D856 to D858 and D991 to D998. ### Handing a step to a person Passwords, passcodes, captchas, Face ID and a trust prompt are a person's, and `wait human` covers the whole handoff in one call: ```console $ phonedriver wait human:"sign in to the bank app" --until "Accounts" --timeout 180000 … waiting for a person: sign in to the bank app (0:42 of 3:00) ok a person finished · 1m 12s · new screen app com.example.bank (Bank) @e1 heading "Accounts" ``` The person gets a desktop notification (`PHONEDRIVER_NOTIFY=off` turns it off), the device is sent nothing while they work, and the call ends when `--until` holds (a text, an `@ref` or `gone:"text"`). Over MCP it is `wait` with `human` and `condition`. Without `--until` it ends when the screen is another one and has been still for 3 seconds: typing into the same page does not end it, and a screen that keeps moving never goes still, so give `--until` whenever you can name the screen. The default time is 5 minutes. A timeout says the person did not finish and what was asked. What they typed into a password, code or card-code field is masked in the reply and in every later reply. A saved run keeps the step; `replay` tells the person again and goes on when they finish, and with no terminal (CI) it stops at the step and says a person is needed. ### Stopping the agent from the phone Press Volume Down twice, quickly (within 400 ms), on an Android phone the agent is using, and it stops at once: a swipe in progress is lifted, a `batch`, `set` or `replay` does not start its next step, and every later call on that phone, from any agent, fails: ```console error: the person stopped the agent on the phone (Volume Down twice, 14:02:07) hint: Stop and tell your user; once they say go on, run `phonedriver resume`. Nothing was sent after the stop. ``` The time is the phone's clock. The presses work in any app, and they lower the volume by a step or two as they always do; phonedriver leaves the volume as your finger set it. The stop is kept until you let the agent go on, and it lasts through a daemon restart and a new connection to the phone (both tested against a fake device). To let it go on, tell your agent, run `phonedriver resume` (`--device` to pick the phone), or press `Resume the agent` on the live page. Over MCP the agent calls `devices` with `resume: true`, and your client asks you, naming the phone and how and when it was stopped; `Allow` lets it go on and anything else leaves it stopped. A client that cannot ask, such as `claude -p`, leaves it stopped and tells the agent to ask you in chat and not to call again until you say yes and open the live page, where it asks you. The refusal never tells the agent to pass `autonomous: true` (D1169). An agent driving the CLI runs `phonedriver resume` once you said yes. Each resume says what allowed it, in its reply, in the trace and in `bug --html` (D255). The computer shows a desktop notification when the phone stops it (`PHONEDRIVER_NOTIFY=off` turns it off), `devices` says `stopped on the phone at 14:02:07` in the lease column, and `doctor` and `devices` say the keys stop the agent when a physical Android phone is connected. The live page has a `Stop the agent` button on every phone, which stops it the same way, and it becomes `Resume the agent` while the phone is stopped. An iPhone has no stop of its own: phonedriver cannot see its volume keys, so use the live page's Stop (D238 to D240). The keys were run on the API 37 and API 26 emulators, with the presses written by `sendevent`, and on one phone, an Honor X8, where a real double press stopped the agent; no other maker's build was tried. ### Networks, VPNs and waiting on a log line On Android, `phonedriver sensor network` prints what the device is connected to, read-only and with no approval: ``` 100 cellular on eth0 · dns 10.0.2.3 101 wifi (default) on wlan0 · dns 10.0.2.3 102 wifi+vpn of dev.example.vpn on tun0 for uids 0-99999 over 101 · dns 10.77.0.1 always-on vpn none lockdown off not given: private DNS ``` Each line is a network the platform lists as connected: its id, transports (`wifi`, `cellular`, `vpn`, ...), the system default, and its interface and DNS servers. A VPN names the package that owns it, the user id ranges whose traffic it carries and the network it runs over. Below them come the always-on VPN app and its lockdown setting and the private DNS mode, from the secure and global settings. A field the platform did not give is listed after `not given:` and is not guessed; an emulator with `private_dns_mode` never set says so. The default is the system's default network: with a VPN up it stays the Wi-Fi or cellular network under it, and the VPN's `uids` say whose traffic goes through the VPN. `phonedriver --json sensor network` and the `network` tool return the same as fields (decision D99). The read works the same on a physical Android phone; it was only run on an emulator. `wait` also waits on the VPN and on the log: ``` phonedriver wait vpn:up # a VPN network is connected phonedriver wait vpn:down phonedriver wait log:"tunnel up|handshake" --app "My VPN" # a log line written from now on, of that app ``` `vpn:up` and `vpn:down` read the network state once a second. `log:` follows the log from the moment the wait begins (a line that was already written does not count) and returns the first line that holds one of the `|`-separated words, ignoring case; `--app` (the MCP `app`) keeps only that app's lines. The reply quotes the line: `ok log line: I/pd016 ( 5750): pd-016-check`. Lines can hold secrets, so the reply is masked like every other (decision D70). On a timeout the error says what was last seen: `timed out after 3189 ms waiting for the VPN to be up; last seen: cellular, wifi (default)`, or `waiting for a log line with "x" (164 lines arrived, none matched)`. Matching is on the whole line, so a pattern that also appears in a command line `adbd` logs (the `shell` that wrote the line) matches that first. Android follows `logcat`; the iOS Simulator follows `log stream` at debug level, run the way `shell` runs programs, with `--app` scoped to the app's process; a physical iPhone or iPad answers that its log cannot be followed. On iOS `network` and `wait vpn:` answer that the device's networks cannot be read. A VPN app asks for consent the first time it starts a connection: a "Connection request" dialog from `com.android.vpndialogs`, which phonedriver reports like any system dialog (`alert com.android.vpndialogs: "Connection request"`) and `tap OK` answers. On an emulator you can skip it: `phonedriver shell "appops set ACTIVATE_VPN allow"` pre-authorises the app, so the dialog never appears (checked on an API 37 emulator: with `default` the dialog came up, after `allow` the VPN connected with no dialog). `appops set ACTIVATE_VPN default` takes it back. ### Screens with no element list A web view with accessibility off, a Flutter screen or a game gives no list of elements. A `snapshot`, with or without `--no-settle`, first reads such a screen again for up to 2 s, since an app between two screens lists nothing for a moment (D919). phonedriver then reads the screenshot's text on the machine the daemon runs on and adds the lines it finds, marked `(ocr)`; `tap "Send"` taps one. `snapshot --pixels` asks for this on any screen. macOS and Windows use the text recognition the system ships. Linux uses Tesseract when the `tesseract` program is on the `PATH` (`apt install tesseract-ocr`); without it, `--pixels` answers that pixels cannot be read and names the package. Decisions D61, D64 and D65. ### A web page that is not in the tree yet A web view can be on the screen before its page reaches the accessibility tree: on an iOS 26.5 Simulator read through XCTest, the first read after an app opened its web view held the web view and nothing readable in it, and the page came about 700 ms later. There, when a snapshot finds a web view with no text in it, it reads again for up to 3 s. If no text has come, the snapshot ends `the web view has no readable text: its page may be loading or a picture; snapshot again or take a screenshot`: a page that is one picture (a canvas, a map, a chart) never gets text, and `screenshot` shows it. Each app costs that wait once per session; coming back to the page later answers at once, with the same line (decisions D277, D283). Android devices, physical iPhones and Simulators read without XCTest do not wait: nothing has shown their pages arriving after their web views. ### What the snapshot has no text for A map, a drawing canvas, a chart or a photo has detail that no line of the snapshot describes. `screenshot --unexplained` cuts out just those parts, each with the screen point of its top left: ``` $ phonedriver screenshot --unexplained ok 1 part the snapshot has no text for at 152,440 · 104x104 px · /…/tmp/…/01M….png hint: a pixel is its part's top left plus the pixel: 52,52 in the first is `tap 204,492` ``` A pixel `x,y` of a part is the point `152+x,440+y`. Text of any height (a paragraph is its words), labeled buttons and rows, the edges of every element, the keyboard and the status bar count as described; detail elsewhere is a part, at most 4, largest first, none under 40 points on a side. On a screen the snapshot describes whole it takes no picture: `ok the snapshot has text for all of this screen, so no picture was taken`. On the testbed's canvas on the Android emulator the part was 104 by 104 pixels against 411 by 923 for the screen; a map and iOS were not run. In MCP it is `screenshot` with `unexplained`, which returns each part as an image. Decision D224. ### Controls with no label A toolbar of bare icons, a crop handle or a custom button has no text, so the snapshot says `@e14 button` and nothing more. When the app gave it an id that no other element on the screen has and that holds no UUID, the line shows that instead (`@e14 button #crop`), and `tap '#crop'` taps it (decisions D245, D796). `screenshot --unlabeled` answers what they are with one small picture instead of the whole screen: ```console $ phonedriver screenshot --unlabeled ok 3 unlabeled controls · 196x72 px · /…/tmp/…/01J….png e14 e15 e19 ``` The picture is each of those controls cut from one capture, side by side, each in a frame with its ref beside the frame, so `e14` in the picture is the ref of `tap @e14`. A control is shown with 4 points around it, and one larger than 96 points is shown by its middle 96. A row ends at 400 pixels and the next tile starts a new row. With none on the screen there is no picture, only `ok no unlabeled controls on this screen`. `--within ` keeps the controls inside that element. A snapshot that has such controls ends with one line that says how many and names the flag, and so does a reply whose changes bring new ones (`hint: 2 new controls with no label: …`); the MCP server sends it once a session. A control whose line shows its id is not counted there. A switch, checkbox, radio button, slider or text field is not counted: its role word already says what it is. In MCP it is `screenshot` with `unlabeled`. ### Screens too deep or too large to read whole XCTest reads at most 62 levels of an iOS app's tree at a time, and React Native nests deeper. The runner reads again below each element on the last level, up to 32 more reads per snapshot, so a screen 120 views deep comes back whole in one snapshot (the Simulator's testbed; no React Native app was run with this). What those reads do not reach is not listed, and the snapshot ends with `hint: this screen was read in part, so some elements are not listed; \`phonedriver screenshot\` shows them, and \`tap x,y\` taps a point on the picture`. An iPhone or iPad read without the runner says the same when its reader stops at 400 elements, 40 levels or its time limit. On the Simulator, a screen past 4,000 elements or 80 levels of the accessibility tree is handed to the runner. Android has no such limit. Decisions D4 and D243. ### React Native and Flutter apps Two test apps, `testbeds/react-native` (React Native 0.88.1) and `testbeds/flutter` (Flutter 3.50.1), were driven on the Android emulator; iOS was not run. The counts below are from their own logs (D271). - **Taps.** A tap by ref and by id landed 20 of 20 times on each of six buttons in both apps, and by text on the five with text, a button with no press feedback included. A React Native `testID` and a Flutter `Semantics(identifier:)` are ids: `tap '#save'`. A Flutter `Key` alone does not reach the accessibility tree. React Native's `Button` reads in capitals (`PRIMARY`), as Android draws it. - **Snapshots.** Every control on the screen had a line in both apps, a button 60 views deep and a React Native web view's link and field included. A control with no label shows its id (`button #icon_star`) when the app gave it one. - **Typing.** `type --into` was verified in both apps. A Flutter text field ignores a paste; `type` then sets the text (D273), a secret with the sensitive flag and never key by key, and an `--append` as what the field held and the new text (D278). A Flutter password field shows the text as dots once it is set, and is verified by its length. - **Forms.** `set` takes a control by the text a person sees beside it: React Native's `Switch` with its `Text` to the left, a slider or a picker under its `Text`, in one parent (D279, the rule `check` reads a value by). Flutter's slider, whose node is only its thumb and says its share in its description, is measured by one drag of the thumb. A control with no text beside it in its own parent is reached by its ref or id. - **Tabs.** Flutter's navigation bar names a tab `Form · Tab 2 of 5` (its label is two lines). `tap "Form"` finds it: a text that equals one line of a label matches when no whole label does, and a word inside a line does not (`tap "For"` finds nothing) (D280). - **Late screens.** A sheet that rose 600 ms or more after a React Native tap was not in the reply, 0 of 10, though the app showed it. A tap that drew only its press, or nothing on a control, now watches the screen about 1.3 s in all, and the sheets at 600 and 1,000 ms after a `TouchableOpacity` or a `Pressable` without feedback are in the reply 39 or 40 times in 40 (D296). On a slow or loaded device a sheet that comes about a second after a tap can be missed, and the reply usually reads `no change`: the native testbed's sheet 1,000 ms after a tap was in the reply 35 times in 35 at guest load under 7 and 46 times in 55 at load 5 to 8, where the emulator drew it up to 2.2 s after the tap. A miss is a change in the tap's first half second, which ends the call before the sheet, or a sheet the app draws seconds late; a reply that says the video was behind the phone may be followed by more. A sheet later than that is answered `no change after N ms`; `wait "Close sheet"` or a `snapshot` finds it. In the Flutter app the same sheets are in the reply 10 of 10. - **Starting.** `launch` waits up to 10 s for the app to draw something to read or tap; an app that draws sooner is answered when it does. When the 10 s pass first, the reply says `… has not drawn its first screen after 10 s` (D281). A React Native debug build with dev support on waits for its Metro server before it draws. React Native's debug manifest asks for `ACCESS_LOCAL_NETWORK`; on Android 17 its prompt came at every start, and `--expect alerts:deny` answers it. On an Android emulator a `launch` also waits, up to 3 s more, until the app's own window lists something: Flutter listed its elements up to about 4 s after its drawing went quiet, and before this wait 8 of 20 cold launches of the Flutter testbed on a worn emulator answered `this screen gives no element list` (D289). ### What changed between two screenshots On a screen with no element list, looking again costs a second picture. `screenshot --compare` answers in text: ```console $ phonedriver screenshot before.png $ phonedriver tap "Auto-Capitalisation" $ phonedriver screenshot --compare before.png changed: 1 region, 0.6% of the screen region 304,592 64x40 (no text changed) $ phonedriver tap "Auto-Capitalisation" $ phonedriver screenshot --compare before.png same ``` That is a switch that moved and moved back. Where text differs, the reply has a line for each text that changed (`~ "Will turn on when Bedtime starts" → "Will never turn off automatically" at 132,545`), appeared (`+ "General" at 203,86`) or went (`- "Settings" at 84,143`), with the point to tap. At most twelve lines, then `and 14 more`. With one file the screen now is compared with it; with two files nothing is asked of a device. `--diff-image out.png` also writes the later picture with the regions boxed. Over MCP, `screenshot` with `compare: true` compares the screen with the last screenshot that call returned for the same device and sends no image. The text is read from the pictures by the same recognition as above, so it can misread small or stylized type. A time in the top tenth of the picture that changed (the status bar's clock) is left out; other status bar text that changed is reported like any other. Both pictures must be the same size; take them without `--native` so that the points can be tapped. Decisions D76 and D89. ### Accessibility problems on a screen `snapshot --audit` adds the screen's accessibility problems after its lines: ```console $ phonedriver snapshot --audit ... audit: 2 findings @e15 searchbox "Search": 336x38pt, under 44x44pt @e16 button "Dictate": 17x22pt, under 44x44pt ``` Two checks, from the element list alone: a control (a button, field, switch, tab or anything that can be tapped or typed into) with no label, hint or text inside it, which a screen reader has nothing to say for (`@e1 button: no name a screen reader can say`); and a tap target smaller than 44 by 44 points on iOS or 48 by 48 on Android, the size Apple's and Google's guidelines ask for. A target cut off by the screen's edge or by the list around it, and a link, are not measured. At most 20 lines, then `and 3 more`. Over MCP, `snapshot` takes `audit: true`. Decision D90. With `--source` too, a finding on an Android view that a layout declares gets one line under it: the change that ends it, in the layout's words. It is printed and never applied: ```console $ phonedriver snapshot --audit --source … audit: 10 findings … @e18 button "T": 24x24pt, under 48x48pt fix testbeds/android/app/src/main/res/layout/sight_views.xml:105: set android:layout_width to "48dp" (it is 24dp) and set android:layout_height to "48dp" (it is 24dp) on the