Package org.robolectric.shadows
Class ShadowCameraManager
- java.lang.Object
-
- org.robolectric.shadows.ShadowCameraManager
-
@Implements(value=android.hardware.camera2.CameraManager.class, minSdk=21) public class ShadowCameraManager extends Object
Shadow class forCameraManager
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classShadowCameraManager.ShadowCameraManagerGlobalShadow class for internal class CameraManager$CameraManagerGlobal
-
Constructor Summary
Constructors Constructor Description ShadowCameraManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddCamera(String cameraId, CameraCharacteristics characteristics)Adds the given cameraId and characteristics to this shadow.protected CameraCharacteristicsgetCameraCharacteristics(String cameraId)protected String[]getCameraIdList()booleangetTorchMode(String cameraId)Returns what the supplied camera's torch is set to.protected CameraDeviceopenCameraDeviceUserAsync(String cameraId, CameraDevice.StateCallback callback, Handler handler)EnablesCameraManager.openCamera(String, StateCallback, Handler)to open aCameraDevice.protected CameraDeviceopenCameraDeviceUserAsync(String cameraId, CameraDevice.StateCallback callback, Handler handler, int uid)protected CameraDeviceopenCameraDeviceUserAsync(String cameraId, CameraDevice.StateCallback callback, Executor executor, int uid)voidremoveCamera(String cameraId)Removes the given cameraId and associated characteristics from this shadow.protected voidsetTorchMode(String cameraId, boolean enabled)
-
-
-
Method Detail
-
getCameraIdList
@Implementation protected String[] getCameraIdList() throws CameraAccessException
- Throws:
CameraAccessException
-
getCameraCharacteristics
@Implementation protected CameraCharacteristics getCameraCharacteristics(String cameraId)
-
setTorchMode
@Implementation(minSdk=23) protected void setTorchMode(String cameraId, boolean enabled)
-
openCameraDeviceUserAsync
@Implementation(minSdk=28) protected CameraDevice openCameraDeviceUserAsync(String cameraId, CameraDevice.StateCallback callback, Executor executor, int uid) throws CameraAccessException
- Throws:
CameraAccessException
-
openCameraDeviceUserAsync
@Implementation(minSdk=25, maxSdk=27) protected CameraDevice openCameraDeviceUserAsync(String cameraId, CameraDevice.StateCallback callback, Handler handler, int uid) throws CameraAccessException- Throws:
CameraAccessException
-
openCameraDeviceUserAsync
@Implementation(minSdk=21, maxSdk=24) protected CameraDevice openCameraDeviceUserAsync(String cameraId, CameraDevice.StateCallback callback, Handler handler) throws CameraAccessExceptionEnablesCameraManager.openCamera(String, StateCallback, Handler)to open aCameraDevice.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)}.- Throws:
CameraAccessException
-
addCamera
public void addCamera(String cameraId, CameraCharacteristics characteristics)
Adds the given cameraId and characteristics to this shadow.The result from
getCameraIdList()will be in the order in which cameras were added.- Throws:
IllegalArgumentException- if there's already an existing camera with the given id.
-
removeCamera
public void removeCamera(String cameraId)
Removes the given cameraId and associated characteristics from this shadow.- Throws:
IllegalArgumentException- if there is not an existing camera with the given id.
-
getTorchMode
public boolean getTorchMode(String cameraId)
Returns what the supplied camera's torch is set to.
-
-