device is a runtime proxy over the Android emulator API. Use it for emulator-level operations — such as setting location, placing images in the virtual camera scene, configuring network proxies, passing audio to the microphone, or running raw adb commands — that sit outside app UI interactions. Use driver for interacting with the app itself.
device is only available while a flow is running.
On a real phone, only adb works. The methods marked Emulator only drive the emulator and don’t work on a real phone.
setGeoLocation
Emulator only
Sets the emulator’s GPS location.
Use this to test location-aware features without physically moving a device. See Mock device location for a full walkthrough.
setVirtualSceneImage
Emulator only
Places an image into the Android emulator’s virtual camera scene. Use this to test features that require the camera to see a specific image — such as barcode or QR code scanning.
Virtual scene is scoped to barcode/QR code scanning and augmented reality (AR) use cases. It is not a general photo or video injection mechanism. See Android barcode and QR scanning for a full walkthrough.
playAutomation
Emulator only
Triggers an automation macro on the Android emulator. Use this in combination with setVirtualSceneImage to animate the virtual camera toward a placed image.
The Android emulator determines the available built-in macros.
Walk_to_image_room is the macro used to animate the virtual camera toward a placed image. See Android Emulator camera support for more detail on virtual scene automation.setProxy
Emulator only
Configures a proxy for the Android emulator’s network traffic.
clearProxy
Emulator only
Removes any proxy configuration from the Android emulator.
Call
clearProxy() at the end of any flow that sets a proxy to avoid affecting subsequent flows.passAudioAsMicrophoneInput
Emulator only
Plays an audio file on the runner host so the emulator receives it as microphone input. Use this to test recording, voice, or speech-recognition features with known audio.
The command timeout (1 minute by default) bounds playback. For audio longer than a minute, pass
durationSeconds. See Microphone injection for a full walkthrough.adb
Runs an adb command against the emulator or real phone and returns its combined stdout/stderr. Use this as an escape hatch for emulator or device operations not covered by a dedicated device method — such as dumpsys, emu sensor set, or pull. emu commands work on emulators only.
Pass the arguments either as a single string (split on whitespace; quote a single value that contains spaces) or as an array (preferred when building arguments programmatically). The command does not go through a host shell, so it does not expand variables or run pipes.
Prefer a dedicated
device method when one exists. See Measure performance and Mock hardware sensors for adb usage in context.