@Implements(value=android.hardware.camera2.CameraManager.class, minSdk=21) public class ShadowCameraManager extends Object
CameraManager
Modifier and Type | Class | Description |
---|---|---|
static class |
ShadowCameraManager.ShadowCameraManagerGlobal |
Shadow class for internal class CameraManager$CameraManagerGlobal
|
Constructor | Description |
---|---|
ShadowCameraManager() |
Modifier and Type | Method | Description |
---|---|---|
void |
addCamera(String cameraId,
CameraCharacteristics characteristics) |
Adds the given cameraId and characteristics to this shadow.
|
protected CameraCharacteristics |
getCameraCharacteristics(String cameraId) |
|
protected String[] |
getCameraIdList() |
|
boolean |
getTorchMode(String cameraId) |
Returns what the supplied camera's torch is set to.
|
protected CameraDevice |
openCameraDeviceUserAsync(String cameraId,
CameraDevice.StateCallback callback,
Handler handler) |
Enables
CameraManager.openCamera(String, StateCallback, Handler) to open a
CameraDevice . |
protected CameraDevice |
openCameraDeviceUserAsync(String cameraId,
CameraDevice.StateCallback callback,
Handler handler,
int uid) |
|
protected CameraDevice |
openCameraDeviceUserAsync(String cameraId,
CameraDevice.StateCallback callback,
Executor executor,
int uid) |
|
void |
removeCamera(String cameraId) |
Removes the given cameraId and associated characteristics from this shadow.
|
protected void |
setTorchMode(String cameraId,
boolean enabled) |
@Implementation protected String[] getCameraIdList() throws CameraAccessException
CameraAccessException
@Implementation protected CameraCharacteristics getCameraCharacteristics(String cameraId)
@Implementation(minSdk=23) protected void setTorchMode(String cameraId, boolean enabled)
@Implementation(minSdk=28) protected CameraDevice openCameraDeviceUserAsync(String cameraId, CameraDevice.StateCallback callback, Executor executor, int uid) throws CameraAccessException
CameraAccessException
@Implementation(minSdk=25, maxSdk=27) protected CameraDevice openCameraDeviceUserAsync(String cameraId, CameraDevice.StateCallback callback, Handler handler, int uid) throws CameraAccessException
CameraAccessException
@Implementation(minSdk=21, maxSdk=24) protected CameraDevice openCameraDeviceUserAsync(String cameraId, CameraDevice.StateCallback callback, Handler handler) throws CameraAccessException
CameraManager.openCamera(String, StateCallback, Handler)
to open a
CameraDevice
.
If the provided cameraId exists, this will always post
to the provided {@link Handler}.
Unlike on real Android, this will not check if the camera has been disabled by device policy
and does not attempt to connect to the camera service, so
{@link CameraDevice.StateCallback#onError(CameraDevice, int)} and
{@link CameraDevice.StateCallback#onDisconnected(CameraDevice)} will not be triggered by
{@link CameraManager#openCamera(String, StateCallback, Handler)}.
CameraAccessException
public void addCamera(String cameraId, CameraCharacteristics characteristics)
The result from getCameraIdList()
will be in the order in which cameras were added.
IllegalArgumentException
- if there's already an existing camera with the given id.public void removeCamera(String cameraId)
IllegalArgumentException
- if there is not an existing camera with the given id.public boolean getTorchMode(String cameraId)