Skip to content

Simlock ships its own Pixel 9 Android profile, read before the SDK #487

Closed

Description

@V3RON

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
Loading
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
Loading
  • src/drivers/android/device-profile-source.ts: DeviceProfile gains a third kind, library, with name, id (its avdmanager id, e.g. pixel_9), names ([name, id]), deviceClass, imageKind (the SDK tag id, or undefined for a phone or tablet), apiRange ({ min, max? }), playStore (boolean), tablet (boolean), hardware (key→value config.ini lines), bootProperties (key→value) and copiedFrom (the cmdline-tools version, e.g. "20.0"). isCustom is false for it. The catalog lists its class from deviceClass.
  • src/drivers/android/profiles/: one file per profile, named after its id with - for _ (pixel-9.ts). index.ts imports every file and exports the list and a LibraryDeviceProfileSource. hardware-keys.ts exports LIBRARY_HARDWARE_KEYS: the 104 hw.* and vm.heapSize keys that avdmanager create avd -d pixel_9 writes with cmdline-tools 20.0, without hw.cpu.arch and hw.device.hash2. That run's config.ini is checked in as profiles/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 four hw.display6.* keys.
  • profiles/pixel-9.ts: hardware copied from that run, as written (e.g. hw.ramSize=2G); imageKind none, apiRange 35-, playStore true, tablet false, no boot properties, class phone, from nexus.xml in cmdline-tools 20.0.
  • src/drivers/android/index.ts:
    • defaultDeviceProfileSources returns [library, builtin, user].
    • provision for a library profile first checks every hardware and bootProperties key and value with the driver's one line check (below); a refusal throws before avdmanager create avd runs. It then seeds avdmanager create avd with the first profile avdmanager list device prints, as it does for a devices.xml profile today. It rewrites config.ini: removes every hw.* line except hw.cpu.arch, every vm.heapSize line and every skin.* line; writes the profile's hardware; and sets PlayStore.enabled to yes when the profile allows Play Store and isPlayStoreImage(image) is true, else no. It writes the profile's bootProperties to boot.prop in the AVD directory, or removes a boot.prop the seed wrote when the profile has none. All of this happens before #configHash captures its baseline.
    • If a write after avdmanager create avd fails, provision rethrows and deletes nothing: the AVD stays in Simlock's root with no registry record, an orphan that simlock doctor reports and doctor --purge-orphans destroys, as for any provision failure after create avd today. Every value is checked before create avd, so only a filesystem error can get there.
    • SystemImage gains tags: the comma-separated SystemImage.TagId from the image's source.properties, or [folder name] when it has none or cannot be read.
    • A new module src/drivers/android/image-fit.ts holds isPlayStoreImage(image), ADR 0025 §3's rule and the only one in the driver: a google_apis_playstore tag; or android-automotive-playstore as its only tag; or android-wear as its only tag at API 25 or newer (sdklib's MIN_RECOMMENDED_WEAR_API) in a folder other than android-wear-cn. An Android lease only uses a system image that fits its model #489 adds fits to the same module.
    • The CR/LF/NUL check becomes one exported function (from device-profile-source.ts's containsForbiddenCharacter), used by the devices.xml parser, #mergeConfigIniLines and the boot.prop writer. So every config.ini write (library, devices.xml, simlock.mark) also refuses NUL, and no second copy is left.
    • Other config.ini keys avdmanager writes (disk.dataPartition.size, showDeviceFrame, fastboot.*, ...) are the same for every SDK profile in cmdline-tools 20.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 reports Physical size: 1080x2424 from simlock adb shell wm size and density 420 from wm density. On a host whose SDK ships pixel_9 these 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

  • BuiltinDeviceProfileSource and UserDeviceProfileSource: still read, after the library. A name in both the library and either of them resolves to the library, in resolve and in catalog alike, because both go through matchProfile over 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 no pixel_9 its phone default becomes Pixel 9 because the catalog now lists it.
  • Existing tests that assert catalog.models order (src/drivers/android/index.test.ts) now see Pixel 9 first; they change to the new order.
  • #resolvedProfiles (the driver's model→profile cache between resolveSpec and provision): holds the library profile like any other.
  • #writeDurableMark: writes simlock.mark at first boot, after provision; it merges into the rewritten file. The rewrite never touches simlock.mark.
  • #configHash / #avdConfig: reads image.sysdir.1, hw.* and disk.dataPartition.* after the rewrite.
  • DeviceProvisioner (src/core/device-provisioner.ts): releases its claim when provision throws. The AVD left in the root is an orphan; Doctor (src/core/doctor.ts) reports it and --purge-orphans destroys it after re-proving the root, as today.
  • boot.prop: nothing in Simlock reads or writes it today (searched src); the emulator reads it at boot.

Rules in play

  • safety.md: Simlock never writes the SDK or devices.xml; config.ini and boot.prop are 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.md rule 1: provision destroys nothing; an AVD it leaves behind goes through doctor --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 device does not list pixel_9
  • resolves "Pixel 9" to the library profile when avdmanager list device lists pixel_9 too
  • resolves "Pixel 9" to the library profile when devices.xml defines a "Pixel 9"
  • resolves pixel_9 and PIXEL 9 to 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, with pixel_9 as its other name
  • provisions a library device with every hardware value of the profile in config.ini
  • provisions identical hw.* and vm.heapSize lines whether avdmanager list device lists pixel_9 or not
  • removes every hw.* (except hw.cpu.arch), vm.heapSize and skin.* line the seed wrote that the profile does not set
  • keeps image.sysdir.1, tag.id, abi.type, target, hw.cpu.arch, disk.dataPartition.size and showDeviceFrame as avdmanager wrote them
  • sets PlayStore.enabled=yes on a Play Store image when the profile allows Play Store, and no on a google_apis image or for a profile that does not
  • writes the profile's boot properties to boot.prop, and removes a seed's boot.prop when 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 avd runs
  • refuses NUL in a simlock.mark value and in a devices.xml value, through the one shared check
  • rethrows and deletes nothing when a write after avdmanager create avd fails
  • seeds avdmanager create avd with the first profile avdmanager list device prints, also when it lists pixel_9
  • LIBRARY_HARDWARE_KEYS equals the hw.* and vm.heapSize keys of profiles/fixtures/pixel-9.config.ini without hw.cpu.arch and hw.device.hash2, and Pixel 9's hardware equals that file's values
  • isPlayStoreImage is true for a google_apis_playstore tag, a single android-automotive-playstore tag and a single android-wear tag at 25 or newer, and false for android-wear at 24, android-wear-cn, google_apis and google-tv,google_apis
  • an image's tags come from SystemImage.TagId, and from the folder name when it has none
  • index.ts imports exactly the profile files in the folder
  • each profile file is named after its id with - for _
  • no name, ignoring case, appears in two profiles
  • every profile sets every key in LIBRARY_HARDWARE_KEYS, and only hw.* and vm.heapSize keys other than hw.cpu.arch and hw.device.hash2
  • every profile names the cmdline-tools version 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.phone is Pixel 9

Done when

  • simlock catalog --platform android --json lists "Pixel 9" first, with class phone and other name pixel_9. A host whose SDK lacks pixel_9 is covered by the tests above.
  • The "provisions identical lines" test passes.
  • On a host with the Android SDK (emulator and adb installed): a lease of "Pixel 9" boots with its library screen size and is released, proven by e2e/slow-android-smoke.test.ts (run through scripts/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 and devices.xml.

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, #470, #472 closed or reviewed in this feature's stack.

  4. self-assigned this
    on Oct 13, 2026
  5. added 2 commits that reference this issue on Oct 13, 2026
    f0d5b36
    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