Skip to content

An Android lease only uses a system image that fits its model #489

Closed

Description

@V3RON

Part of #485.

Scope

An Android lease only gets a system image that fits its model, as Android Studio decides it, and the catalog lists only the pairs a lease would accept. After this PR a TV lease gets a TV image or fails saying what to install, and Pixel 9 is refused on API 34. This covers library and SDK models, and custom models as avdmanager lists them; the extra details only devices.xml holds (API range, Play Store, screen size) come in #490.

In short

An image fits a model when Android Studio would offer it for that profile. Four checks:

  • Kind: the image is for the same kind of device, e.g. a TV takes android-tv or google-tv images, a phone takes none of the TV, Wear, car, desktop, XR, glasses or ChromeOS images.
  • API range: the image's API level is in the profile's range, e.g. Pixel 9 needs 35 or newer.
  • Play Store: a Play Store image only on a profile that allows Play Store; Pixel 6 does not.
  • Tablet images: an image tagged tablet only on a tablet profile.
flowchart LR
  A[lease X, --os N?, --image-tag T?] --> B[images that fit X]:::changed
  B -- some --> C[newest fitting level, or N; best fitting image there]:::changed
  B -- none --> E[RUNTIME_MISSING says what would fit]:::changed
  classDef changed stroke-width:3px
Loading

Host with API 35 google_apis, API 36 google_apis_playstore, API 34 android-tv:

$ simlock lease --platform android --device "Television (1080p)"
Leased Television (1080p), Android 34 ...                     # was: Android 36, phone image
$ simlock lease --platform android --device "Pixel 9" --os 34
RUNTIME_MISSING: No installed system image fits Pixel 9 at Android 34: it needs Android 35 or newer
Request Today After
"Television (1080p)" 36, phone image 34 android-tv
"Television (1080p)" --os 36 36, phone image RUNTIME_MISSING, downloadable: false
"Television (1080p)" --image-tag google_apis 35, phone image RUNTIME_MISSING, downloadable: false
"Television (720p)" (SDK only) 36, phone image 34 android-tv
"Television (1080p)", a google-tv image also at 36 36, a phone or the Google TV image 36 google-tv
"Wear OS Large Round", an android-wear image at 34 36, phone image 34 android-wear
"Pixel 9" 36 36 Play Store
"Pixel 9" --os 34 34 RUNTIME_MISSING, downloadable: false
"Pixel 9" --os 37 --allow-download (nothing at 37) downloads 37 google_apis downloads 37 google_apis
"Television (1080p)" --os 37 --allow-download (nothing at 37) downloads 37 google_apis RUNTIME_MISSING, downloadable: false, nothing downloaded
"Pixel 6" 36 35 google_apis
"Pixel 6" --os 36 --allow-download 36 Play Store RUNTIME_MISSING, downloadable: false (36 is installed, so nothing is downloaded; the operator installs its google_apis image with sdkmanager)
"Pixel 6" --image-tag google_apis_playstore 36 Play Store RUNTIME_MISSING, downloadable: false
"Medium Phone" --image-tag google_apis_playstore 36 Play Store 36 Play Store
"Medium Phone" --os 35 35 google_apis 35 google_apis
"Pixel 9 Pro" (SDK only, no API range known) 36 36
"My Tablet" (custom, no device type) 36 36; pairs with 35 and 36, not the TV image at 34

If this goes wrong, leases that should work fail with RUNTIME_MISSING, or a misfit image is still used.

Technical spec

Modules touched

flowchart LR
  LC[listCatalog]:::changed --> F[image-fit.ts fits]:::changed
  RS[resolveSpec]:::changed --> F
  P[provision / #requireImage]:::changed --> F
  IMG[#installedImages]:::changed --> SP[image source.properties]
  DPS[device-profile-source.ts<br/>builtin profile keeps its tag]:::changed
  F --> DPS
  GM[gateway request-match.ts]:::changed --> LC
  DOC[core doctor.ts<br/>warm-pool-target-unreachable]:::changed
  classDef changed stroke-width:3px
Loading
sequenceDiagram
  participant A as agent (CLI/MCP/HTTP)
  participant D as daemon core
  participant V as Android driver
  A->>D: lease "Television (1080p)" --os 36
  D->>V: resolveSpec(model, 36)
  V->>V: images at 36 that fit the TV profile: none
  V-->>D: RuntimeMissingError(36, downloadable: false)
  D-->>A: RUNTIME_MISSING, exit 12, "No installed system image fits Television (1080p) at Android 36: it needs a TV image"
Loading
  • src/drivers/android/device-profile-source.ts: the builtin profile keeps its raw Tag : value as tag, besides the deviceClass it already maps.
  • src/drivers/android/image-fit.ts (from Simlock ships its own Pixel 9 Android profile, read before the SDK #487, which holds isPlayStoreImage): gains a pure fits(profile, image) with the four checks, and the profile facts it reads:
  • src/drivers/android/index.ts:
    • SystemImage.tags (from Simlock ships its own Pixel 9 Android profile, read before the SDK #487) is what fits reads. The catalog's images[].tag and --image-tag still use the folder name.
    • listCatalog: modelRuntimes[model] is the levels with at least one fitting image, oldest first. runtimes, defaultRuntime and images stay every installed image.
    • resolveSpec, no version: the newest level with a fitting image. With a version: that level, which must have a fitting image. With an image tag: an image of that folder tag that fits, at the asked level or the newest such level. Within a level, today's #matchingImage order, applied to fitting images only.
    • A refusal is a RuntimeMissingError. It is downloadable: true (names the level as the component) only when the asked level has no image installed at all and its google_apis image for the host ABI would fit; otherwise downloadable: false. So ComponentInstaller, which skips a level findComponent already finds, is only asked for a level with nothing installed.
    • The refusal message is No installed system image fits <model> at Android <level>: <reason>, or without at Android <level> when no version was asked. <reason> is the first of these checks, in this order, that rules out every image considered (the images at that level; with no version, every installed image): API range → it needs Android <min> or newer / <max> or older; kind → it needs a <kind> image (TV, Wear OS, automotive, desktop, XR, AI glasses; a profile with no kind: phone or tablet; any other kind: it needs an image tagged <tag>); Play Store → <model> does not take Play Store images; tablet → <model> does not take tablet images. When no single check rules out every image, <reason> is none of the installed images fit it. With an image tag whose image misfits: the <tag> image does not fit it, then the first check that image fails, e.g. the google_apis image does not fit it: it needs a TV image. A level with nothing installed: Android <level> is not installed. A host with no image at all: no system image is installed. An image tag with no image of that tag installed keeps today's AndroidImageTagMissingError message.
    • #requireImage in provision picks among fitting images only, by the same order. If none is left (removed since resolveSpec), it throws the same RuntimeMissingError; it never falls back to a misfit image.
    • The comments on installedApiLevels and in resolveSpec that say every model pairs with every level are fixed.
  • src/gateway/routing/request-match.ts: for a request that names a model and no OS, the runtime a worker will pick is the newest of pairedRuntimesOf (the worker's modelRuntimes for the model, filtered by image tag as today), on every platform. Was: defaultRuntime when paired, else the only paired one. iOS already picks the newest paired runtime (#resolveDefaultRuntime), so its answer only changes where today's rule had none (several paired, default not paired). No platform branch. Under an image tag whose image misfits at that level the prediction can miss, the gap ADR 0025 §4 accepts.
  • src/core/doctor.ts: a runtime-missing warm-pool-target-unreachable finding for an exact version that the platform's catalog lists in runtimes but not in the model's modelRuntimes says <model> does not pair with <platform name> <version> and suggests simlock catalog --platform <platform>, not component install. The rule reads only the catalog, so it holds on every platform; on iOS it replaces today's false "is not installed" for a runtime that dropped a model. Assumption: that iOS message fix is in scope, since the alternative is a platform branch in the core.

Contract and event changes

None. modelRuntimes keeps its shape; only its contents narrow.

Other code on the same state

  • LeaseAcquisitionCoordinator (src/leasing/lease-acquisition-coordinator.ts) and src/core/catalog-match.ts: pick a level for a class or a range from modelRuntimes, then call resolveSpec with it; they now see only fitting levels. Under an image tag they count a level when images has that tag there; resolveSpec may still refuse it when that image misfits (ADR 0025 §4).
  • The core resolves the spec before it looks for an idle device. For a request that names a model and an exact level, or no OS, idle devices are matched by that exact level: an idle device on a level that still fits is reused as it is, and one on a level that no longer fits (a TV on a phone image) is not picked. A request that names a class or an OS range matches idle devices by range (src/leasing/acquisition-planner.ts, src/core/domain.ts fits, src/core/warm-pool/policy.ts), so it can still pick such a device until idle cleanup removes it (ADR 0025 §4, accepted by the maintainer).
  • ComponentInstaller (src/core/component-installer.ts) with findComponent: unchanged; the downloadable rule above only asks it for a level with no image, so it never settles as "already installed" without fixing the lease.
  • DriverCatalog#classDefaults: a default counts when it pairs with a level; now that means a fitting image.
  • src/gateway/aggregate.ts: unions each worker's modelRuntimes; each worker lists only fitting pairs.
  • src/gateway/routing/serviceability.ts: refuses at once with RUNTIME_MISSING ("Runtime missing for android 36") when no worker pairs the model with the level; through a gateway the agent gets that message, not the worker's.
  • The warm pool and doctor read RUNTIME_MISSING refusals for warm targets; covered by the doctor.ts change above.

Rules in play

  • architecture.md: one function decides fit, and the catalog, resolveSpec and provision all call it; ADR 0008 §3's agreement test must still walk every listed pair.
  • safety.md: no implicit downloads; a lease never offers a download that could not help.
  • testing.md: each of the four checks needs a test that goes red when the check is deleted.

Tests

Seam: AndroidDriver listCatalog, resolveSpec and provision through createDriver in src/drivers/android/index.test.ts (model on the "image tag" tests and the test that walks every catalog pair through resolveSpec); fits directly in a new src/drivers/android/image-fit.test.ts; the gateway rule in the existing request-match tests; the doctor finding in src/core/doctor.test.ts.

  • a TV profile fits android-tv and google-tv images and no phone image
  • a Wear, automotive, desktop profile fits only images with its exact tag
  • a profile with no kind fits no TV, Wear, automotive, desktop, XR, glasses or ChromeOS image
  • an image below a profile's API range does not fit; 36.1 counts as 36; android-Baklava with AndroidVersion.ApiLevel=35 fits Pixel 9; an image with no number fits only a profile with no range
  • a profile tagged ai-glasses or android-xr-glasses fits both image tags; xr_glasses_device fits only android-xr-ost; a phone profile fits an android-xr-ost image
  • a Play Store image does not fit a profile that disallows Play Store, and fits one that allows it
  • an Automotive (1024p landscape) profile fits a single-tag android-automotive-playstore image as a Play Store image
  • a tablet image fits only a tablet profile
  • --image-tag and the catalog's images[].tag use the folder name of an image whose SystemImage.TagId differs from it
  • an SDK or custom profile fits by its Tag : value with no API range and Play Store allowed
  • a devices.xml profile avdmanager did not list pairs with every installed level, as today
  • modelRuntimes lists only levels with a fitting image; runtimes, defaultRuntime and images still list every installed image, including a newest level no model fits
  • every pair listCatalog lists resolves through resolveSpec, and a level it leaves out is refused
  • a lease with no version gets the newest level with a fitting image, and fails RUNTIME_MISSING, downloadable: false when there is none
  • each refusal reason gives its message, as listed above, including mixed misfits, a level with nothing installed and a host with no image; an image that fails both API range and kind gives the API range reason
  • a level with nothing installed is downloadable: true only when its google_apis image would fit; an installed level with only misfit images is downloadable: false
  • an image tag whose image misfits fails RUNTIME_MISSING, downloadable: false, with the misfit message
  • within a level, the fitting image follows today's order: host-native google_apis, host-native, google_apis, any
  • provision creates the device from a fitting image and throws RUNTIME_MISSING when none is left, never using a misfit image
  • the gateway expects the newest paired runtime, after the image-tag filter, for a model with no OS, on Android and iOS alike
  • doctor names simlock catalog, not component install, for an installed version the target's model does not pair with, and keeps today's text for a version that is not installed
  • each row of the table under "In short" gives its After result from resolveSpec and listCatalog (the rows' Leased ... lines are the CLI view of that result)
  • in src/leasing/lease-acquisition-coordinator.test.ts (fake driver): an idle device on a level the catalog pairs is reused by an exact request; one on a level it no longer pairs is not picked by an exact request, and is still picked by a range request

Done when

  • The "each row" test passes.
  • simlock catalog --platform android --json lists for each library, SDK and custom model only levels with a fitting image.
  • docs/CLI.md says how Android models pair with images (modelRuntimes, the sentence "On Android every model pairs with every installed API level"), what --image-tag and --allow-download do for a misfit, the new RUNTIME_MISSING messages, and that an idle device on a level that no longer fits is not reused.

Out of scope

Depends on

Approval

  • Approved for delivery

Written by an agent.

Activity

  1. added
    task:draft
    on Oct 12, 2026
  2. added
    task:ready
    and removed
    task:draft
    on Oct 13, 2026
  3. github-actions commented on Oct 13, 2026

    @github-actions
    Contributor

    Now task:ready: approved, technical spec present, #488, #469, #471 closed or reviewed in this feature's stack.

  4. self-assigned this
    on Oct 13, 2026
  5. added 3 commits that reference this issue on Oct 13, 2026
    5a27313
    4a7fcdf
    253976d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

task:ready

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions