public static class CallbackProxies.DeviceStateCallbackProxy extends CameraDeviceImpl.StateCallbackKK
CameraDevice.StateCallback.ErrorCode
ERROR_CAMERA_DEVICE, ERROR_CAMERA_DISABLED, ERROR_CAMERA_IN_USE, ERROR_CAMERA_SERVICE, ERROR_MAX_CAMERAS_IN_USE
Constructor and Description |
---|
DeviceStateCallbackProxy(Dispatchable<CameraDeviceImpl.StateCallbackKK> dispatchTarget) |
Modifier and Type | Method and Description |
---|---|
void |
onActive(CameraDevice camera)
The method called when a camera device begins processing
capture requests . |
void |
onBusy(CameraDevice camera)
The method called when a camera device is busy.
|
void |
onClosed(CameraDevice camera)
The method called when a camera device has been closed with
CameraDevice.close() . |
void |
onDisconnected(CameraDevice camera)
The method called when a camera device is no longer available for
use.
|
void |
onError(CameraDevice camera,
int error)
The method called when a camera device has encountered a serious error.
|
void |
onIdle(CameraDevice camera)
The method called when a camera device has finished processing all
submitted capture requests and has reached an idle state.
|
void |
onOpened(CameraDevice camera)
The method called when a camera device has finished opening.
|
void |
onUnconfigured(CameraDevice camera)
The method called when a camera device has no outputs configured.
|
onSurfacePrepared
public DeviceStateCallbackProxy(Dispatchable<CameraDeviceImpl.StateCallbackKK> dispatchTarget)
public void onOpened(CameraDevice camera)
CameraDevice.StateCallback
At this point, the camera device is ready to use, and
CameraDevice.createCaptureSession(java.util.List<android.view.Surface>, android.hardware.camera2.CameraCaptureSession.StateCallback, android.os.Handler)
can be called to set up the first capture
session.
onOpened
in class CameraDevice.StateCallback
camera
- the camera device that has become openedpublic void onDisconnected(CameraDevice camera)
CameraDevice.StateCallback
This callback may be called instead of CameraDevice.StateCallback.onOpened(android.hardware.camera2.CameraDevice)
if opening the camera fails.
Any attempt to call methods on this CameraDevice will throw a
CameraAccessException
. The disconnection could be due to a
change in security policy or permissions; the physical disconnection
of a removable camera device; or the camera being needed for a
higher-priority camera API client.
There may still be capture callbacks that are invoked after this method is called, or new image buffers that are delivered to active outputs.
The default implementation logs a notice to the system log about the disconnection.
You should clean up the camera with CameraDevice.close()
after
this happens, as it is not recoverable until the camera can be opened
again. For most use cases, this will be when the camera again becomes
available
.
onDisconnected
in class CameraDevice.StateCallback
camera
- the device that has been disconnectedpublic void onError(CameraDevice camera, int error)
CameraDevice.StateCallback
This callback may be called instead of CameraDevice.StateCallback.onOpened(android.hardware.camera2.CameraDevice)
if opening the camera fails.
This indicates a failure of the camera device or camera service in
some way. Any attempt to call methods on this CameraDevice in the
future will throw a CameraAccessException
with the
CAMERA_ERROR
reason.
There may still be capture completion or camera stream callbacks that will be called after this error is received.
You should clean up the camera with CameraDevice.close()
after
this happens. Further attempts at recovery are error-code specific.
onError
in class CameraDevice.StateCallback
camera
- The device reporting the errorerror
- The error code, one of the
StateCallback.ERROR_*
values.CameraDevice.StateCallback.ERROR_CAMERA_IN_USE
,
CameraDevice.StateCallback.ERROR_MAX_CAMERAS_IN_USE
,
CameraDevice.StateCallback.ERROR_CAMERA_DISABLED
,
CameraDevice.StateCallback.ERROR_CAMERA_DEVICE
,
CameraDevice.StateCallback.ERROR_CAMERA_SERVICE
public void onUnconfigured(CameraDevice camera)
CameraDeviceImpl.StateCallbackKK
onUnconfigured
in class CameraDeviceImpl.StateCallbackKK
public void onActive(CameraDevice camera)
CameraDeviceImpl.StateCallbackKK
capture requests
.onActive
in class CameraDeviceImpl.StateCallbackKK
public void onBusy(CameraDevice camera)
CameraDeviceImpl.StateCallbackKK
onBusy
in class CameraDeviceImpl.StateCallbackKK
public void onClosed(CameraDevice camera)
CameraDevice.StateCallback
CameraDevice.close()
.
Any attempt to call methods on this CameraDevice in the
future will throw a IllegalStateException
.
The default implementation of this method does nothing.
onClosed
in class CameraDevice.StateCallback
camera
- the camera device that has become closedpublic void onIdle(CameraDevice camera)
CameraDeviceImpl.StateCallbackKK
onIdle
in class CameraDeviceImpl.StateCallbackKK