"Set image for Android camera" command
On Android cloud devices whose "Device Type" is set to "Emulator (arm64-v8a)", you can simulate taking a photo by using the "Set image for Android camera" command.
This command sets the camera image of the device. Therefore, whenever the application under test (AUT) accesses the camera, it can see the image you have set and take a photo of it.
However, there are some limitations to this command. For details, please refer to the following sections.
Restrictions
When using this feature, please note:
- You can only set the back camera image. Currently, setting the front camera image is not supported.
- The image you set is a single still image. It is shown as a steady camera feed (the same frame, continuously) and does not play back as motion video. You can provide an animated image, but it will only display the first frame.
- Shooting settings, such as flash and focus, have no effect on the captured image.
- If the AUT attempts to take a photo before setting an image with this command, the AUT will not crash, but it will not be able to retrieve any photo.
If the input image is too large in terms of dimensions, it will be downscaled to at most 1920×1080. Whether downscaling occurs or not, the input image will then aspect-fit into whatever resolution the app requests. Therefore, an app whose requested aspect ratio differs from your image will see black bars around the image (letterboxing/pillarboxing).
Information for App Developers
Any API that receives frames from the device camera receives the set image — CameraX, Camera2, the deprecated Camera API, and libraries built on them such as ML Kit barcode scanning. There is no restricted subset of APIs and no special integration required.