Expand description
Client for the emulator’s gRPC controller: the emulator fast path (design D7, android-driver requirement “Emulator fast path”).
An emulator started with -grpc <port> -grpc-use-token serves the
EmulatorController service and writes the port and a bearer token into its
discovery file. resolve finds them for an adb serial, and
Controller::connect opens the connections and reads the hardware. When
the endpoint cannot be used the error is Unavailable, whose warning says
how to enable it: the launch flag, or the console command that needs no
restart.
The client handles the protocol quirks spike S7 found:
- scaling needs both width and height (
scaled_size); - raw rows arrive top-down although the proto says bottom-up (
Frame); - the display size is only in the deprecated
hardwareConfig(Hardware::from_status); - every call needs a deadline, because some emulator ports accept TCP and
never answer (
Options); sendKeyaccepts and drops keys when the AVD has no keyboard, so the client sends none and reportsHardware::keyboardinstead;- the stream repeats unchanged frames and the status bar clock changes on
its own, so changes are detected on hashes without the status bar
(
ChangeDetector).
Modules§
- proto
- The
android.emulation.controlclient, generated bybuild.rsfrom the installed emulator’semulator_controller.proto.
Structs§
- Change
Detector - Detects content changes in a sequence of frames, such as a frame stream. Feeds the settle signal: frames keep arriving while nothing changes.
- Controller
- A connected emulator controller.
- Discovery
- Parsed contents of one discovery file.
- Display
Size - Size of the emulator’s display in pixels, in its natural orientation.
- Endpoint
- Where an emulator’s controller listens and how to authenticate to it.
- Found
- One discovery file found on disk.
- Frame
- A raw RGB888 frame.
- Frame
Hasher - Hashes frame content without the status bar.
- Frame
Key - Identity of a frame’s content outside the status bar.
- Frame
Stream - A subscription to the emulator’s frames.
- Hardware
- The virtual hardware the driver needs to know about.
- Options
- Deadlines of the client.
- Touch
Point - One contact in a touch event.
- Unavailable
- The emulator’s control endpoint cannot be used, so taps and frames fall back
to the agent.
Unavailable::warningis the text for the target status.
Enums§
- Discovery
Error - A discovery file that could not be parsed.
- Error
- Why a call on a connected controller failed.
- Frame
Error - Why bytes do not make a frame.
- Observation
- What a frame means relative to the one before it.
Constants§
- BYTES_
PER_ PIXEL - Bytes per pixel of the RGB888 frames the client requests.
- DOWN_
PRESSURE - Pressure of a finger on the glass; the touchscreen’s axis maximum is 1024.
- MAX_
MESSAGE - Largest message the client accepts: a native RGBA8888 frame of a 1080x2400 display is 10.4 MB, beyond tonic’s default of 4 MB.
- PROTO_
SOURCE - The proto file the client was generated from, as
build.rsfound it.
Functions§
- candidate_
dirs - Directories the emulator writes discovery files to, in search order:
$XDG_RUNTIME_DIR/avd/runningwhen set, then the per-OS default (~/Library/Caches/TemporaryItems/avd/runningon macOS,/run/user/<uid>/avd/runningon Linux,%LOCALAPPDATA%\Temp\avd\runningon Windows), thenavd/runningunder the temporary directory. For one emulator the authoritative answer is its console commandavd discoverypath. - console_
port_ from_ serial - The console port in an emulator serial:
emulator-5554gives 5554. - find_
for_ serial - The discovery whose console port matches
serial. When several match, as when a crashed emulator left a stale file next to the live one, the last one infoundwins;scan_dirorders files oldest first. - pid_
from_ file_ name - The pid in a discovery file name:
pid_59226.inigives 59226. - resolve
- Resolves
serialthrough the discovery files indiscovery::candidate_dirs. - resolve_
in - Resolves
serialthrough the discovery files indirs; when several files name the serial, the newest wins. - scaled_
size - The frame size to request for frames
working_widthpixels wide. - scan_
dir - Reads every
pid_*.iniindir, oldest modification first. A file that cannot be read, such as one an exiting emulator just removed, is skipped.