Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/internal/flows/device-selection.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ How one lease request becomes one concrete device, virtual or physical.
| Default mode | `ios.defaultMode` (`full`); Android always `full` | Per request with no `mode` |
| Operator preference lists | `ios.defaultModels`, `android.defaultModels` | Merged once at start |
| Built-in preference lists | `Driver.defaultModels` of each driver | Merged once at start, after the operator's |
| Catalog | `DriverCatalog.listCatalog` → `Driver.listCatalog` | Per class or range request; no cache |
| Catalog | `DriverCatalog.listCatalog` → `Driver.listCatalog` | Per class or range request; built on every read (Android keeps only its `avdmanager list device` answer, below) |
| Android profile library (16) | `drivers/android/profiles/` | Static |
| Android SDK profiles | `avdmanager list device` | Each catalog; each resolve of a model the library lacks; each library provision (seed) |
| Android SDK profiles | `avdmanager list device`, kept in `AvdmanagerDeviceList` | Asked by each catalog, each resolve of a model the library lacks, each library provision (seed); run again only when the sdklib jar, the tools' `source.properties`, the user's devices.xml, an image's or add-on's devices.xml, or an `extras/<vendor>/<item>` extra's devices.xml or `source.properties` changed size or modified time, appeared or went, or an image was installed or removed; 30 s limit |
| Android devices.xml | `$ANDROID_USER_HOME/devices.xml`, else `.android/devices.xml` | Each catalog; a resolve no earlier source answered |
| Android system images | `<sdk>/system-images/android-*/<tag>/<abi>` + `source.properties` | Each resolve, catalog, provision |
| Android fit rule | `drivers/android/image-fit.ts` `fits` | With every image read |
Expand Down
2 changes: 0 additions & 2 deletions src/core/warm-pool/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,5 +131,3 @@ pool's own `state.db` tables, kept across restarts and cleared by nuke.
it waits; a burst larger than `count` pays the boot.
- **A failing target retries forever.** 1, 2, 4 … minutes, at most 10 apart, no attempt limit; each
try boots or creates a device. `retry.ts` is the one place to add a limit.
- **A hung `avdmanager` leaves one stuck process per 30 s.** The catalog check abandons a read
after 30 s, but the driver's call has no timeout of its own.
2 changes: 1 addition & 1 deletion src/core/warm-pool/catalog-check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { DriverCatalog, PlatformCatalog } from "../driver-catalog.js";
import { stableError } from "../stable-error.js";
import type { LearnedKind } from "./learned.js";

/** why: the longest the pool waits for a catalog read; `avdmanager` has no timeout of its own. */
/** why: the longest the pool waits for a catalog read, whatever bound the driver's own read has. */
const CATALOG_READ_LIMIT_MS = 30_000;

interface CatalogCheckOptions {
Expand Down
16 changes: 7 additions & 9 deletions src/drivers/android/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Parent: [drivers](../AGENTS.md). Flows: [device selection](../../../docs/interna
| `adb-host-protocol.ts` | adb host-protocol framing (`adbHostRequest`, `OKAY`/`FAIL`), for both callers |
| `default-adb-server.ts` | `DefaultAdbServerGate`: protocol check of the server on 5037 |
| `physical-handler.ts` | `AndroidPhysicalHandler`: enrol, presence, reclaim, passthrough for phones |
| `device-profile-source.ts` | `DeviceProfileRegistry`; SDK and devices.xml profile sources |
| `device-profile-source.ts` | `DeviceProfileRegistry`; SDK and devices.xml profile sources; `AvdmanagerDeviceList`, the kept `list device` answer |
| `profiles/index.ts` | `LibraryDeviceProfileSource`: Simlock's 16 profiles |
| `image-fit.ts` | `fits`, `misfitReason`: which system image a profile takes |
| `sdk-paths.ts` | `locateSdk`: SDK root and tool paths, shared with `prerequisites.ts` |
Expand Down Expand Up @@ -80,8 +80,7 @@ Reclaim — `reclaim`:
Ownership gate: before any `emu kill` or snapshot load, `adb emu avd path` (5 s timeout, asked every time, never cached) must name this device's own AVD directory; unreachable, timed out or another path → nothing is sent (a snapshot reclaim then shuts down and wipes).

`shutdown`: gate, then `adb emu kill`, wait, SIGKILL. `destroy`: kills the emulator this process started, or after a restart each attached
emulator whose bounded `emu avd path` names this AVD (any serial that cannot answer → refuse), then `avdmanager delete avd`, frees the port.
`listManaged`: `<root>/*.avd` + `adb devices` + `ro.boot.qemu.avd_name` per serial; only root members count.
emulator whose bounded `emu avd path` names this AVD (any serial that cannot answer → refuse), then `avdmanager delete avd`, frees the port. `listManaged`: `<root>/*.avd` + `adb devices` + `ro.boot.qemu.avd_name` per serial; only root members count.

Profiles — library (`profiles/`), SDK (`avdmanager list device`), devices.xml
(`$ANDROID_USER_HOME/devices.xml`, else `.android/devices.xml` under `ANDROID_PREFS_ROOT`, `ANDROID_SDK_HOME`
Expand Down Expand Up @@ -115,8 +114,8 @@ No slim: `resolveSpec` ignores `mode` and returns a full spec. `fresh` is core's

Screen — `screenCapture` and `input`, only when `create` got `scrcpyServerPath` and `tcpStreamConnector`: [screen](screen/AGENTS.md), [input](input/AGENTS.md).

Plain facts: `avdmanager list device` runs on every `listCatalog`, resolve of a model the library lacks,
and library provision (seed); nothing is cached. The sdkmanager catalog is never read. Existing devices are not re-checked for fit.
Plain facts: `listCatalog`, a resolve of a model the library lacks and a library provision (seed) share one `AvdmanagerDeviceList`: `avdmanager list device` runs again only when the size or modified time of a file it reads profiles from changed, or one appeared or went: the tools package's `lib/sdklib/sdklib.core.jar` (legacy `tools/lib/sdklib*.jar`) and `source.properties`, the user's devices.xml, `devices.xml` in each `system-images/*/*/*` and `add-ons/*` directory (a new image is a new path), and `devices.xml` and `source.properties` in each `extras/*/*` directory (avdmanager reads an extra whose `source.properties` says `Extra.Path=DeviceProfiles`).
Otherwise the last good answer is served; a failed run is not kept; concurrent callers share one run. The sdkmanager catalog is never read. Existing devices are not re-checked for fit.

## State and timers

Expand All @@ -130,9 +129,9 @@ and library provision (seed); nothing is cached. The sdkmanager catalog is never
| `adb devices` in `listManaged` | 30 s | none |
| AVD path query (listing / boot) | 5 s | none |
| Physical read / uninstall | 30 s / 60 s | none |
| `avdmanager list device` | 30 s | none |

Writes: `<root>/<avd>.avd/` (config, boot properties, snapshots, baseline marker); `$SIMLOCK_HOME/adb-server.json` (`pid`, `port`, `startedAt`).
Reads only: the user's AVD home, devices.xml, the SDK.
Writes: `<root>/<avd>.avd/` (config, boot properties, snapshots, baseline marker); `$SIMLOCK_HOME/adb-server.json` (`pid`, `port`, `startedAt`). Reads only: the user's AVD home, devices.xml, the SDK.

## Rules

Expand All @@ -145,6 +144,5 @@ Reads only: the user's AVD home, devices.xml, the SDK.

- **Simlock's adb server is stopped by pid only.** `ADB_REJECT_KILL_SERVER=1` refuses its `kill-server`.
No record → `occupied`: find it with `lsof` (Windows: `Get-NetTCPConnection -LocalPort <port>`; the message names `lsof` only), or move `drivers.android.adbServerPort` (one per instance).
- **A physical command can restart a 5037 server of another protocol (ADR 0022 §5).** One started
between the gate and the command is restarted by adb's client. Run every adb on the host from one platform-tools.
- **A physical command can restart a 5037 server of another protocol (ADR 0022 §5).** One started between the gate and the command is restarted by adb's client. Run every adb on the host from one platform-tools.
- **Port checks are partial.** A port handed out but not yet booted reads free to another instance.
Loading
Loading