Repository navigation
Description
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-tvorgoogle-tvimages, 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
tabletonly 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
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
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"
src/drivers/android/device-profile-source.ts: thebuiltinprofile keeps its rawTag :value astag, besides thedeviceClassit already maps.src/drivers/android/image-fit.ts(from Simlock ships its own Pixel 9 Android profile, read before the SDK #487, which holdsisPlayStoreImage): gains a purefits(profile, image)with the four checks, and the profile facts it reads:libraryprofile: its own fields (Simlock ships its own Pixel 9 Android profile, read before the SDK #487).builtinprofile, SDK or custom (OEM : User): kind fromtag; no API range; Play Store allowed; not a tablet. A devices.xml profile's device type, API range, Play Store and screen size decide its class and images #490 adds a custom profile'sdevices.xmldetails.propertiesprofile (adevices.xmlprofileavdmanagerdid not list): no check applies, every image fits, as today; A devices.xml profile's device type, API range, Play Store and screen size decide its class and images #490 changes this.- Kind check, as sdklib's
DeviceSystemImageMatcherincmdline-tools20.0: a TV profile (android-tvorgoogle-tv) takes an image tagged either; a profile taggedai-glassesorandroid-xr-glasses(sdklib'sDevice.isAiGlasses) takesai-glassesorandroid-xr-glasses; the SDK profile with idxr_glasses_devicetakesandroid-xr-ost; any other kind takes an image with that exact tag; a profile with no kind takes an image with none ofandroid-wear,android-desktop,android-tv,google-tv,android-automotive,android-automotive-playstore,android-automotive-distantdisplay,android-xr,android-xr-glasses,ai-glasses,chromeos. - API range: the image's level is
AndroidVersion.ApiLevelfrom itssource.properties(android-Baklavais 35), else the integer part of its folder level (36.1is 36). An image with neither fits only a profile with no range. - Play Store image:
isPlayStoreImagefrom Simlock ships its own Pixel 9 Android profile, read before the SDK #487, the only rule for it. - Tablet image: tagged
tabletoraosp_tablet.
src/drivers/android/index.ts:SystemImage.tags(from Simlock ships its own Pixel 9 Android profile, read before the SDK #487) is whatfitsreads. The catalog'simages[].tagand--image-tagstill use the folder name.listCatalog:modelRuntimes[model]is the levels with at least one fitting image, oldest first.runtimes,defaultRuntimeandimagesstay 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#matchingImageorder, applied to fitting images only.- A refusal is a
RuntimeMissingError. It isdownloadable: true(names the level as the component) only when the asked level has no image installed at all and itsgoogle_apisimage for the host ABI would fit; otherwisedownloadable: false. SoComponentInstaller, which skips a levelfindComponentalready 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 withoutat 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>isnone 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'sAndroidImageTagMissingErrormessage. #requireImageinprovisionpicks among fitting images only, by the same order. If none is left (removed sinceresolveSpec), it throws the sameRuntimeMissingError; it never falls back to a misfit image.- The comments on
installedApiLevelsand inresolveSpecthat 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 ofpairedRuntimesOf(the worker'smodelRuntimesfor the model, filtered by image tag as today), on every platform. Was:defaultRuntimewhen 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: aruntime-missingwarm-pool-target-unreachablefinding for an exact version that the platform's catalog lists inruntimesbut not in the model'smodelRuntimessays<model> does not pair with <platform name> <version>and suggestssimlock catalog --platform <platform>, notcomponent 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) andsrc/core/catalog-match.ts: pick a level for a class or a range frommodelRuntimes, then callresolveSpecwith it; they now see only fitting levels. Under an image tag they count a level whenimageshas that tag there;resolveSpecmay 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.tsfits,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) withfindComponent: unchanged; thedownloadablerule 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'smodelRuntimes; each worker lists only fitting pairs.src/gateway/routing/serviceability.ts: refuses at once withRUNTIME_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
doctorreadRUNTIME_MISSINGrefusals for warm targets; covered by thedoctor.tschange above.
Rules in play
architecture.md: one function decides fit, and the catalog,resolveSpecandprovisionall 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-tvandgoogle-tvimages 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.1counts as 36;android-BaklavawithAndroidVersion.ApiLevel=35fits Pixel 9; an image with no number fits only a profile with no range - a profile tagged
ai-glassesorandroid-xr-glassesfits both image tags;xr_glasses_devicefits onlyandroid-xr-ost; a phone profile fits anandroid-xr-ostimage - 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-playstoreimage as a Play Store image - a
tabletimage fits only a tablet profile --image-tagand the catalog'simages[].taguse the folder name of an image whoseSystemImage.TagIddiffers from it- an SDK or custom profile fits by its
Tag :value with no API range and Play Store allowed - a
devices.xmlprofileavdmanagerdid not list pairs with every installed level, as today modelRuntimeslists only levels with a fitting image;runtimes,defaultRuntimeandimagesstill list every installed image, including a newest level no model fits- every pair
listCataloglists resolves throughresolveSpec, 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: falsewhen 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: trueonly when itsgoogle_apisimage would fit; an installed level with only misfit images isdownloadable: 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 provisioncreates the device from a fitting image and throwsRUNTIME_MISSINGwhen 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, notcomponent 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
resolveSpecandlistCatalog(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 --jsonlists for each library, SDK and custom model only levels with a fitting image.docs/CLI.mdsays how Android models pair with images (modelRuntimes, the sentence "On Android every model pairs with every installed API level"), what--image-tagand--allow-downloaddo for a misfit, the newRUNTIME_MISSINGmessages, and that an idle device on a level that no longer fits is not reused.
Out of scope
- A custom profile's
devices.xmlAPI range, Play Store flag and screen size (A devices.xml profile's device type, API range, Play Store and screen size decide its class and images #490). - A catalog field listing fitting tags per level (rejected in ADR 0025).
- Retiring idle devices made on an image that no longer fits.
Depends on
- The other 15 Android library profiles, and Medium Tablet as Android's tablet #488
- Leasing calls lease-end participants before it reclaims a device #469
- simlock doctor says why agent-device is not available #471
Approval
- Approved for delivery
Written by an agent.
Activity
github-actions commentedon Oct 13, 2026
Now
task:ready: approved, technical spec present, #488, #469, #471 closed or reviewed in this feature's stack.feat(android): a lease only uses a system image that fits its model (#…
feat: gateway, doctor and CLI.md follow the fitting pairs (#489)
refactor: image-fit keeps its helpers private (#489)
chore: fallow complexity ignores for the fit builders (#489)
docs: CLI.md and ARCHITECTURE.md name the runtime a worker picks as t…
test: review fixes for image fit tests, comments and docs (#489)
feat(android): an Android lease only uses a system image that fits it…
feat(android): a devices.xml profile's API range, Play Store and scre…
feat(android): doctor reports a devices.xml profile hidden by a libra…