Repository navigation
Description
Part of #485.
Scope
Simlock gets its own Android profile library, read before the SDK and devices.xml, with one profile: Pixel 9. After this PR, simlock lease --device "Pixel 9" --platform android works on a host whose SDK does not ship pixel_9, and the device's hardware is the same on every host.
Assumption: the library ships only Pixel 9 here; the other 15 profiles are #488, so this PR reviews the mechanism and one data file.
In short
A library profile is a TypeScript file Simlock ships, e.g. src/drivers/android/profiles/pixel-9.ts, holding everything the SDK's own Pixel 9 profile sets. A name in the library resolves to it before the SDK or devices.xml is asked.
flowchart LR
A[lease --device X] --> L{library has X?}:::changed
L -- yes --> P[create from the library profile]:::changed
L -- no --> S{SDK has X?}
S -- yes --> Q[create from the SDK profile]
S -- no --> U{devices.xml has X?}
U -- yes --> R[create from devices.xml]
U -- no --> E[UNKNOWN_MODEL]
classDef changed stroke-width:3px
| Request | SDK ships pixel_9? |
Today | After |
|---|---|---|---|
--device "Pixel 9" |
yes | SDK profile | library profile |
--device "Pixel 9" |
no | UNKNOWN_MODEL |
library profile |
--device pixel_9, --device "PIXEL 9" |
either | SDK profile, or UNKNOWN_MODEL |
library profile |
--device "Pixel 9", also in devices.xml |
no | devices.xml profile | library profile |
--device "Pixel 8" |
yes | SDK profile | SDK profile |
simlock catalog model order |
SDK order | SDK order | library models first, then SDK, then devices.xml |
If this goes wrong, a Pixel 9 device boots with another model's hardware, or does not boot.
Technical spec
Modules touched
flowchart LR
D[AndroidDriver<br/>index.ts]:::changed --> R[DeviceProfileRegistry<br/>device-profile-source.ts]:::changed
R --> L[LibraryDeviceProfileSource<br/>profiles/index.ts]:::changed
L --> P9[profiles/pixel-9.ts]:::changed
R --> B[BuiltinDeviceProfileSource]
R --> U[UserDeviceProfileSource]
D --> A[avdmanager create avd]
D --> C[config.ini, boot.prop]:::changed
E[e2e/slow-android-smoke.test.ts]:::changed
classDef changed stroke-width:3px
src/drivers/android/device-profile-source.ts:DeviceProfilegains a third kind,library, withname,id(its avdmanager id, e.g.pixel_9),names([name, id]),deviceClass,imageKind(the SDK tag id, orundefinedfor a phone or tablet),apiRange({ min, max? }),playStore(boolean),tablet(boolean),hardware(key→valueconfig.inilines),bootProperties(key→value) andcopiedFrom(thecmdline-toolsversion, e.g."20.0").isCustomis false for it. The catalog lists its class fromdeviceClass.src/drivers/android/profiles/: one file per profile, named after itsidwith-for_(pixel-9.ts).index.tsimports every file and exports the list and aLibraryDeviceProfileSource.hardware-keys.tsexportsLIBRARY_HARDWARE_KEYS: the 104hw.*andvm.heapSizekeys thatavdmanager create avd -d pixel_9writes withcmdline-tools20.0, withouthw.cpu.archandhw.device.hash2. That run'sconfig.iniis checked in asprofiles/fixtures/pixel-9.config.ini, so the list and Pixel 9's values can be tested against it. Every SDK phone, tablet, TV, Wear and desktop profile writes the same 104; the automotive ones add fourhw.display6.*keys.profiles/pixel-9.ts:hardwarecopied from that run, as written (e.g.hw.ramSize=2G);imageKindnone,apiRange35-,playStoretrue,tabletfalse, no boot properties, classphone, fromnexus.xmlincmdline-tools20.0.src/drivers/android/index.ts:defaultDeviceProfileSourcesreturns[library, builtin, user].provisionfor alibraryprofile first checks everyhardwareandbootPropertieskey and value with the driver's one line check (below); a refusal throws beforeavdmanager create avdruns. It then seedsavdmanager create avdwith the first profileavdmanager list deviceprints, as it does for adevices.xmlprofile today. It rewritesconfig.ini: removes everyhw.*line excepthw.cpu.arch, everyvm.heapSizeline and everyskin.*line; writes the profile'shardware; and setsPlayStore.enabledtoyeswhen the profile allows Play Store andisPlayStoreImage(image)is true, elseno. It writes the profile'sbootPropertiestoboot.propin the AVD directory, or removes aboot.propthe seed wrote when the profile has none. All of this happens before#configHashcaptures its baseline.- If a write after
avdmanager create avdfails,provisionrethrows and deletes nothing: the AVD stays in Simlock's root with no registry record, an orphan thatsimlock doctorreports anddoctor --purge-orphansdestroys, as for anyprovisionfailure aftercreate avdtoday. Every value is checked beforecreate avd, so only a filesystem error can get there. SystemImagegainstags: the comma-separatedSystemImage.TagIdfrom the image'ssource.properties, or[folder name]when it has none or cannot be read.- A new module
src/drivers/android/image-fit.tsholdsisPlayStoreImage(image), ADR 0025 §3's rule and the only one in the driver: agoogle_apis_playstoretag; orandroid-automotive-playstoreas its only tag; orandroid-wearas its only tag at API 25 or newer (sdklib'sMIN_RECOMMENDED_WEAR_API) in a folder other thanandroid-wear-cn. An Android lease only uses a system image that fits its model #489 addsfitsto the same module. - The CR/LF/NUL check becomes one exported function (from
device-profile-source.ts'scontainsForbiddenCharacter), used by thedevices.xmlparser,#mergeConfigIniLinesand theboot.propwriter. So everyconfig.iniwrite (library,devices.xml,simlock.mark) also refuses NUL, and no second copy is left. - Other
config.inikeysavdmanagerwrites (disk.dataPartition.size,showDeviceFrame,fastboot.*, ...) are the same for every SDK profile incmdline-tools20.0 (checked for all 16 library models) and stay as written.
e2e/slow-android-smoke.test.ts: leases "Pixel 9" by name and checks the booted device reportsPhysical size: 1080x2424fromsimlock adb shell wm sizeand density 420 fromwm density. On a host whose SDK shipspixel_9these equal the SDK's values; this test proves a library device boots, and the unit tests prove the library is used. Its comment about "the AVD id a built-in profile is listed with" is fixed.
Contract and event changes
None. DeviceClass already has every class; the catalog shape is unchanged.
Other code on the same state
BuiltinDeviceProfileSourceandUserDeviceProfileSource: still read, after the library. A name in both the library and either of them resolves to the library, inresolveand incatalogalike, because both go throughmatchProfileover the ordered list.DriverCatalog#classDefaults(src/core/driver-catalog.ts): unchanged; it picks the first listed default with a paired runtime, so on a host whose SDK has nopixel_9its phone default becomes Pixel 9 because the catalog now lists it.- Existing tests that assert
catalog.modelsorder (src/drivers/android/index.test.ts) now see Pixel 9 first; they change to the new order. #resolvedProfiles(the driver's model→profile cache betweenresolveSpecandprovision): holds the library profile like any other.#writeDurableMark: writessimlock.markat first boot, afterprovision; it merges into the rewritten file. The rewrite never touchessimlock.mark.#configHash/#avdConfig: readsimage.sysdir.1,hw.*anddisk.dataPartition.*after the rewrite.DeviceProvisioner(src/core/device-provisioner.ts): releases its claim whenprovisionthrows. The AVD left in the root is an orphan;Doctor(src/core/doctor.ts) reports it and--purge-orphansdestroys it after re-proving the root, as today.boot.prop: nothing in Simlock reads or writes it today (searchedsrc); the emulator reads it at boot.
Rules in play
safety.md: Simlock never writes the SDK ordevices.xml;config.iniandboot.propare written only inside Simlock's own AVD root.architecture.md: one line check and one Play Store rule in the driver; the registry stays the only matcher.safety.mdrule 1:provisiondestroys nothing; an AVD it leaves behind goes throughdoctor --purge-orphans.testing.md: the library checks look at every file in the folder, not a fixed list.
Tests
Seam: AndroidDriver through createDriver in src/drivers/android/index.test.ts (model on the "device-profile sources" tests), and a new src/drivers/android/profiles/library.test.ts, modelled on src/drivers/android/device-profile-source.test.ts.
- resolves "Pixel 9" to the library profile when
avdmanager list devicedoes not listpixel_9 - resolves "Pixel 9" to the library profile when
avdmanager list devicelistspixel_9too - resolves "Pixel 9" to the library profile when
devices.xmldefines a "Pixel 9" - resolves
pixel_9andPIXEL 9to the library's Pixel 9 - resolves a model the library does not have through the SDK, then
devices.xml, as today - lists Pixel 9 first in the catalog, once, as
phone, not custom, withpixel_9as its other name - provisions a library device with every
hardwarevalue of the profile inconfig.ini - provisions identical
hw.*andvm.heapSizelines whetheravdmanager list devicelistspixel_9or not - removes every
hw.*(excepthw.cpu.arch),vm.heapSizeandskin.*line the seed wrote that the profile does not set - keeps
image.sysdir.1,tag.id,abi.type,target,hw.cpu.arch,disk.dataPartition.sizeandshowDeviceFrameasavdmanagerwrote them - sets
PlayStore.enabled=yeson a Play Store image when the profile allows Play Store, andnoon agoogle_apisimage or for a profile that does not - writes the profile's boot properties to
boot.prop, and removes a seed'sboot.propwhen the profile has none - captures the config hash after the library's keys are written
- refuses a library value with CR, LF or NUL before
avdmanager create avdruns - refuses NUL in a
simlock.markvalue and in adevices.xmlvalue, through the one shared check - rethrows and deletes nothing when a write after
avdmanager create avdfails - seeds
avdmanager create avdwith the first profileavdmanager list deviceprints, also when it listspixel_9 LIBRARY_HARDWARE_KEYSequals thehw.*andvm.heapSizekeys ofprofiles/fixtures/pixel-9.config.iniwithouthw.cpu.archandhw.device.hash2, and Pixel 9'shardwareequals that file's valuesisPlayStoreImageis true for agoogle_apis_playstoretag, a singleandroid-automotive-playstoretag and a singleandroid-weartag at 25 or newer, and false forandroid-wearat 24,android-wear-cn,google_apisandgoogle-tv,google_apis- an image's tags come from
SystemImage.TagId, and from the folder name when it has none index.tsimports exactly the profile files in the folder- each profile file is named after its
idwith-for_ - no name, ignoring case, appears in two profiles
- every profile sets every key in
LIBRARY_HARDWARE_KEYS, and onlyhw.*andvm.heapSizekeys other thanhw.cpu.archandhw.device.hash2 - every profile names the
cmdline-toolsversion it was copied from - Pixel 9's class, image kind, API range, Play Store and tablet flags and boot properties are
phone, none,35-, yes, no, none - in
src/core/driver-catalog.test.ts: with Android's built-in phone list and a catalog that lists Pixel 9 paired and no Pixel 8,classDefaults.phoneis Pixel 9
Done when
simlock catalog --platform android --jsonlists "Pixel 9" first, with classphoneand other namepixel_9. A host whose SDK lackspixel_9is covered by the tests above.- The "provisions identical lines" test passes.
- On a host with the Android SDK (
emulatorandadbinstalled): a lease of "Pixel 9" boots with its library screen size and is released, proven bye2e/slow-android-smoke.test.ts(run throughscripts/slow-e2e.sh). docs/CLI.md"Where Android models come from" names Simlock's own profiles as the first place, and says a library name wins over the SDK anddevices.xml.
Out of scope
- The other 15 library profiles, the
tabletclass and its default (The other 15 Android library profiles, and Medium Tablet as Android's tablet #488). - Pairing models only with images that fit (An Android lease only uses a system image that fits its model #489); this PR keeps every model paired with every installed level.
doctorreporting a hiddendevices.xmlprofile (doctor reports a devices.xml profile that a library profile hides #491).- Devices made before this PR: no code here touches an existing AVD.
Depends on
Approval
- Approved for delivery
Written by an agent.
Activity
github-actions commentedon Oct 13, 2026
Now
task:ready: approved, technical spec present, #470, #472 closed or reviewed in this feature's stack.feat(android): Simlock ships a Pixel 9 profile, read before the SDK (#…
test: fallow complexity ignores for the two Android harness builders (#…
fix: library profile claims and tag-fallback test (#487)
feat(android): Simlock ships its own Pixel 9 Android profile, read be…
feat(android): doctor reports a devices.xml profile hidden by a libra…