Skip to content

Android TV devices ​

Each worker holds one emulator for its lifetime. Where it comes from is the device provider's job; the driver only needs its serial.

managed ​

toets creates, boots, snapshots and resets emulators itself.

  • AVD: toets_<model>_api<level>_<tag> (e.g. toets_tv_1080p_api34_android-tv), created with avdmanager from an installed system image. toets never downloads images; a missing one fails with the exact sdkmanager command.
  • Clean snapshot: on first use the AVD is cold-booted once and saved as the toets_clean snapshot. Creation is locked across worker processes.
  • Workers boot -read-only instances from toets_clean: several run at once, none can change the snapshot, and boots take seconds instead of minutes.
  • Reset: restoring toets_clean (adb emu avd snapshot load) returns the whole device to a known state; released emulators are reused this way. Emulator versions that refuse snapshot loads on -read-only instances ("Snapshot load is disabled because "-read-only" was specified") are restarted from toets_clean instead, on the same port. An emulator that can not be reset is stopped and replaced by a fresh one.
  • Reuse across runs: with reuse: true, emulators stay up after the run and the next run adopts them.
ts
import { platforms } from '@toets/test';

platforms.androidTV({
  model: 'tv_1080p',
  osVersion: '34',
  managed: { reuse: true, emulatorArgs: ['-gpu', 'swiftshader_indirect'] },
});
managed optionDefault
imageTagandroid-tv (or google-tv)
abihost architecture
headlesstrue
reusefalse
bootTimeoutMs300000
basePort5554 (worker n from +2n)
emulatorArgsnone
avdHomeANDROID_AVD_HOME

external ​

You start the emulators; toets hands them out by worker index (TOETS_DEVICES=emulator-5554,emulator-5556) (devices: { mode: 'external' }, see @toets/test). The driver waits for boot on start.

command ​

A lease broker or device farm leases and releases devices through commands that print JSON (see @toets/test). Return the adb serial as the address. prepareAndroidDevice(serial) waits for boot and reports API level and whether it is a TV, so a broker integration can fail fast.

CI ​

Android emulators need hardware acceleration: Linux with KVM (/dev/kvm accessible) or macOS. Cache the SDK system image and the AVD directory (it holds toets_clean) between runs to skip the cold boot.

Trap ​

App data and device state are separate. app.reset() clears app data (pm clear); it does not undo device-level changes such as settings a test toggled. Restore the snapshot for that.