Merge "Camera2: Final API revisions" into lmp-dev
diff --git a/api/current.txt b/api/current.txt
index 3eb5b57..18c600f 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -12673,17 +12673,17 @@
public abstract class CameraCaptureSession implements java.lang.AutoCloseable {
ctor public CameraCaptureSession();
method public abstract void abortCaptures() throws android.hardware.camera2.CameraAccessException;
- method public abstract int capture(android.hardware.camera2.CaptureRequest, android.hardware.camera2.CameraCaptureSession.CaptureListener, android.os.Handler) throws android.hardware.camera2.CameraAccessException;
- method public abstract int captureBurst(java.util.List<android.hardware.camera2.CaptureRequest>, android.hardware.camera2.CameraCaptureSession.CaptureListener, android.os.Handler) throws android.hardware.camera2.CameraAccessException;
+ method public abstract int capture(android.hardware.camera2.CaptureRequest, android.hardware.camera2.CameraCaptureSession.CaptureCallback, android.os.Handler) throws android.hardware.camera2.CameraAccessException;
+ method public abstract int captureBurst(java.util.List<android.hardware.camera2.CaptureRequest>, android.hardware.camera2.CameraCaptureSession.CaptureCallback, android.os.Handler) throws android.hardware.camera2.CameraAccessException;
method public abstract void close();
method public abstract android.hardware.camera2.CameraDevice getDevice();
- method public abstract int setRepeatingBurst(java.util.List<android.hardware.camera2.CaptureRequest>, android.hardware.camera2.CameraCaptureSession.CaptureListener, android.os.Handler) throws android.hardware.camera2.CameraAccessException;
- method public abstract int setRepeatingRequest(android.hardware.camera2.CaptureRequest, android.hardware.camera2.CameraCaptureSession.CaptureListener, android.os.Handler) throws android.hardware.camera2.CameraAccessException;
+ method public abstract int setRepeatingBurst(java.util.List<android.hardware.camera2.CaptureRequest>, android.hardware.camera2.CameraCaptureSession.CaptureCallback, android.os.Handler) throws android.hardware.camera2.CameraAccessException;
+ method public abstract int setRepeatingRequest(android.hardware.camera2.CaptureRequest, android.hardware.camera2.CameraCaptureSession.CaptureCallback, android.os.Handler) throws android.hardware.camera2.CameraAccessException;
method public abstract void stopRepeating() throws android.hardware.camera2.CameraAccessException;
}
- public static abstract class CameraCaptureSession.CaptureListener {
- ctor public CameraCaptureSession.CaptureListener();
+ public static abstract class CameraCaptureSession.CaptureCallback {
+ ctor public CameraCaptureSession.CaptureCallback();
method public void onCaptureCompleted(android.hardware.camera2.CameraCaptureSession, android.hardware.camera2.CaptureRequest, android.hardware.camera2.TotalCaptureResult);
method public void onCaptureFailed(android.hardware.camera2.CameraCaptureSession, android.hardware.camera2.CaptureRequest, android.hardware.camera2.CaptureFailure);
method public void onCaptureProgressed(android.hardware.camera2.CameraCaptureSession, android.hardware.camera2.CaptureRequest, android.hardware.camera2.CaptureResult);
@@ -12692,8 +12692,8 @@
method public void onCaptureStarted(android.hardware.camera2.CameraCaptureSession, android.hardware.camera2.CaptureRequest, long);
}
- public static abstract class CameraCaptureSession.StateListener {
- ctor public CameraCaptureSession.StateListener();
+ public static abstract class CameraCaptureSession.StateCallback {
+ ctor public CameraCaptureSession.StateCallback();
method public void onActive(android.hardware.camera2.CameraCaptureSession);
method public void onClosed(android.hardware.camera2.CameraCaptureSession);
method public abstract void onConfigureFailed(android.hardware.camera2.CameraCaptureSession);
@@ -12780,7 +12780,7 @@
public abstract class CameraDevice implements java.lang.AutoCloseable {
method public abstract void close();
method public abstract android.hardware.camera2.CaptureRequest.Builder createCaptureRequest(int) throws android.hardware.camera2.CameraAccessException;
- method public abstract void createCaptureSession(java.util.List<android.view.Surface>, android.hardware.camera2.CameraCaptureSession.StateListener, android.os.Handler) throws android.hardware.camera2.CameraAccessException;
+ method public abstract void createCaptureSession(java.util.List<android.view.Surface>, android.hardware.camera2.CameraCaptureSession.StateCallback, android.os.Handler) throws android.hardware.camera2.CameraAccessException;
method public abstract java.lang.String getId();
field public static final int TEMPLATE_MANUAL = 6; // 0x6
field public static final int TEMPLATE_PREVIEW = 1; // 0x1
@@ -12790,8 +12790,8 @@
field public static final int TEMPLATE_ZERO_SHUTTER_LAG = 5; // 0x5
}
- public static abstract class CameraDevice.StateListener {
- ctor public CameraDevice.StateListener();
+ public static abstract class CameraDevice.StateCallback {
+ ctor public CameraDevice.StateCallback();
method public void onClosed(android.hardware.camera2.CameraDevice);
method public abstract void onDisconnected(android.hardware.camera2.CameraDevice);
method public abstract void onError(android.hardware.camera2.CameraDevice, int);
@@ -12804,15 +12804,15 @@
}
public final class CameraManager {
- method public void addAvailabilityListener(android.hardware.camera2.CameraManager.AvailabilityListener, android.os.Handler);
method public android.hardware.camera2.CameraCharacteristics getCameraCharacteristics(java.lang.String) throws android.hardware.camera2.CameraAccessException;
method public java.lang.String[] getCameraIdList() throws android.hardware.camera2.CameraAccessException;
- method public void openCamera(java.lang.String, android.hardware.camera2.CameraDevice.StateListener, android.os.Handler) throws android.hardware.camera2.CameraAccessException;
- method public void removeAvailabilityListener(android.hardware.camera2.CameraManager.AvailabilityListener);
+ method public void openCamera(java.lang.String, android.hardware.camera2.CameraDevice.StateCallback, android.os.Handler) throws android.hardware.camera2.CameraAccessException;
+ method public void registerAvailabilityCallback(android.hardware.camera2.CameraManager.AvailabilityCallback, android.os.Handler);
+ method public void unregisterAvailabilityCallback(android.hardware.camera2.CameraManager.AvailabilityCallback);
}
- public static abstract class CameraManager.AvailabilityListener {
- ctor public CameraManager.AvailabilityListener();
+ public static abstract class CameraManager.AvailabilityCallback {
+ ctor public CameraManager.AvailabilityCallback();
method public void onCameraAvailable(java.lang.String);
method public void onCameraUnavailable(java.lang.String);
}
diff --git a/core/java/android/hardware/camera2/CameraAccessException.java b/core/java/android/hardware/camera2/CameraAccessException.java
index ca71e81..91ef6ca 100644
--- a/core/java/android/hardware/camera2/CameraAccessException.java
+++ b/core/java/android/hardware/camera2/CameraAccessException.java
@@ -61,7 +61,7 @@
*
* <p>The camera has failed to open or has failed at a later time
* as a result of some non-user interaction. Refer to
- * {@link CameraDevice.StateListener#onError} for the exact
+ * {@link CameraDevice.StateCallback#onError} for the exact
* nature of the error.</p>
*
* <p>No further calls to the camera will succeed. Clean up
diff --git a/core/java/android/hardware/camera2/CameraCaptureSession.java b/core/java/android/hardware/camera2/CameraCaptureSession.java
index fc2141f..29e42ea 100644
--- a/core/java/android/hardware/camera2/CameraCaptureSession.java
+++ b/core/java/android/hardware/camera2/CameraCaptureSession.java
@@ -32,18 +32,18 @@
* sending images to the desired targets. Therefore the setup is done asynchronously, and
* {@link CameraDevice#createCaptureSession createCaptureSession} will send the ready-to-use
* CameraCaptureSession to the provided listener's
- * {@link CameraCaptureSession.StateListener#onConfigured onConfigured} callback. If configuration
+ * {@link CameraCaptureSession.StateCallback#onConfigured onConfigured} callback. If configuration
* cannot be completed, then the
- * {@link CameraCaptureSession.StateListener#onConfigureFailed onConfigureFailed} is called, and the
+ * {@link CameraCaptureSession.StateCallback#onConfigureFailed onConfigureFailed} is called, and the
* session will not become active.</p>
*<!--
* <p>Any capture requests (repeating or non-repeating) submitted before the session is ready will
* be queued up and will begin capture once the session becomes ready. In case the session cannot be
- * configured and {@link StateListener#onConfigureFailed onConfigureFailed} is called, all queued
+ * configured and {@link StateCallback#onConfigureFailed onConfigureFailed} is called, all queued
* capture requests are discarded.</p>
*-->
* <p>If a new session is created by the camera device, then the previous session is closed, and its
- * associated {@link StateListener#onClosed onClosed} callback will be invoked. All
+ * associated {@link StateCallback#onClosed onClosed} callback will be invoked. All
* of the session methods will throw an IllegalStateException if called once the session is
* closed.</p>
*
@@ -86,7 +86,7 @@
* looper}.
*
* @return int A unique capture sequence ID used by
- * {@link CaptureListener#onCaptureSequenceCompleted}.
+ * {@link CaptureCallback#onCaptureSequenceCompleted}.
*
* @throws CameraAccessException if the camera device is no longer connected or has
* encountered a fatal error
@@ -103,7 +103,7 @@
* @see #setRepeatingBurst
* @see #abortCaptures
*/
- public abstract int capture(CaptureRequest request, CaptureListener listener, Handler handler)
+ public abstract int capture(CaptureRequest request, CaptureCallback listener, Handler handler)
throws CameraAccessException;
/**
@@ -131,7 +131,7 @@
* looper}.
*
* @return int A unique capture sequence ID used by
- * {@link CaptureListener#onCaptureSequenceCompleted}.
+ * {@link CaptureCallback#onCaptureSequenceCompleted}.
*
* @throws CameraAccessException if the camera device is no longer connected or has
* encountered a fatal error
@@ -147,7 +147,7 @@
* @see #setRepeatingBurst
* @see #abortCaptures
*/
- public abstract int captureBurst(List<CaptureRequest> requests, CaptureListener listener,
+ public abstract int captureBurst(List<CaptureRequest> requests, CaptureCallback listener,
Handler handler) throws CameraAccessException;
/**
@@ -185,7 +185,7 @@
* looper}.
*
* @return int A unique capture sequence ID used by
- * {@link CaptureListener#onCaptureSequenceCompleted}.
+ * {@link CaptureCallback#onCaptureSequenceCompleted}.
*
* @throws CameraAccessException if the camera device is no longer connected or has
* encountered a fatal error
@@ -203,7 +203,7 @@
* @see #stopRepeating
* @see #abortCaptures
*/
- public abstract int setRepeatingRequest(CaptureRequest request, CaptureListener listener,
+ public abstract int setRepeatingRequest(CaptureRequest request, CaptureCallback listener,
Handler handler) throws CameraAccessException;
/**
@@ -245,7 +245,7 @@
* looper}.
*
* @return int A unique capture sequence ID used by
- * {@link CaptureListener#onCaptureSequenceCompleted}.
+ * {@link CaptureCallback#onCaptureSequenceCompleted}.
*
* @throws CameraAccessException if the camera device is no longer connected or has
* encountered a fatal error
@@ -263,7 +263,7 @@
* @see #stopRepeating
* @see #abortCaptures
*/
- public abstract int setRepeatingBurst(List<CaptureRequest> requests, CaptureListener listener,
+ public abstract int setRepeatingBurst(List<CaptureRequest> requests, CaptureCallback listener,
Handler handler) throws CameraAccessException;
/**
@@ -274,7 +274,7 @@
*
* <p>Any currently in-flight captures will still complete, as will any burst that is
* mid-capture. To ensure that the device has finished processing all of its capture requests
- * and is in ready state, wait for the {@link StateListener#onReady} callback after
+ * and is in ready state, wait for the {@link StateCallback#onReady} callback after
* calling this method.</p>
*
* @throws CameraAccessException if the camera device is no longer connected or has
@@ -285,7 +285,7 @@
*
* @see #setRepeatingRequest
* @see #setRepeatingBurst
- * @see StateListener#onIdle
+ * @see StateCallback#onIdle
*/
public abstract void stopRepeating() throws CameraAccessException;
@@ -293,15 +293,15 @@
* Discard all captures currently pending and in-progress as fast as possible.
*
* <p>The camera device will discard all of its current work as fast as possible. Some in-flight
- * captures may complete successfully and call {@link CaptureListener#onCaptureCompleted}, while
- * others will trigger their {@link CaptureListener#onCaptureFailed} callbacks. If a repeating
+ * captures may complete successfully and call {@link CaptureCallback#onCaptureCompleted}, while
+ * others will trigger their {@link CaptureCallback#onCaptureFailed} callbacks. If a repeating
* request or a repeating burst is set, it will be cleared.</p>
*
* <p>This method is the fastest way to switch the camera device to a new session with
* {@link CameraDevice#createCaptureSession}, at the cost of discarding in-progress work. It
* must be called before the new session is created. Once all pending requests are either
- * completed or thrown away, the {@link StateListener#onReady} callback will be called,
- * if the session has not been closed. Otherwise, the {@link StateListener#onClosed}
+ * completed or thrown away, the {@link StateCallback#onReady} callback will be called,
+ * if the session has not been closed. Otherwise, the {@link StateCallback#onClosed}
* callback will be fired when a new session is created by the camera device.</p>
*
* <p>Cancelling will introduce at least a brief pause in the stream of data from the camera
@@ -332,7 +332,7 @@
*
* <p>Note that creating a new capture session with {@link CameraDevice#createCaptureSession}
* will close any existing capture session automatically, and call the older session listener's
- * {@link StateListener#onClosed} callback. Using {@link CameraDevice#createCaptureSession}
+ * {@link StateCallback#onClosed} callback. Using {@link CameraDevice#createCaptureSession}
* directly without closing is the recommended approach for quickly switching to a new session,
* since unchanged target outputs can be reused more efficiently.</p>
*
@@ -340,7 +340,7 @@
* repeating requests or bursts are stopped (as if {@link #stopRepeating()} was called).
* However, any in-progress capture requests submitted to the session will be completed as
* normal; once all captures have completed and the session has been torn down,
- * {@link StateListener#onClosed} will be called.</p>
+ * {@link StateCallback#onClosed} will be called.</p>
*
* <p>Closing a session is idempotent; closing more than once has no effect.</p>
*/
@@ -348,10 +348,10 @@
public abstract void close();
/**
- * A listener for tracking the state of a camera capture session.
+ * A callback object for receiving updates about the state of a camera capture session.
*
*/
- public static abstract class StateListener {
+ public static abstract class StateCallback {
/**
* This method is called when the camera device has finished configuring itself, and the
@@ -439,10 +439,17 @@
}
/**
- * <p>A listener for tracking the progress of a {@link CaptureRequest}
- * submitted to the camera device.</p>
+ * Temporary for migrating to Callback naming
+ * @hide
+ */
+ public static abstract class StateListener extends StateCallback {
+ }
+
+ /**
+ * <p>A callback object for tracking the progress of a {@link CaptureRequest} submitted to the
+ * camera device.</p>
*
- * <p>This listener is called when a request triggers a capture to start,
+ * <p>This callback is invoked when a request triggers a capture to start,
* and when the capture is complete. In case on an error capturing an image,
* the error method is triggered instead of the completion method.</p>
*
@@ -451,7 +458,7 @@
* @see #setRepeatingRequest
* @see #setRepeatingBurst
*/
- public static abstract class CaptureListener {
+ public static abstract class CaptureCallback {
/**
* This constant is used to indicate that no images were captured for
@@ -625,7 +632,7 @@
}
/**
- * This method is called independently of the others in CaptureListener,
+ * This method is called independently of the others in CaptureCallback,
* when a capture sequence finishes and all {@link CaptureResult}
* or {@link CaptureFailure} for it have been returned via this listener.
*
@@ -655,7 +662,7 @@
}
/**
- * This method is called independently of the others in CaptureListener,
+ * This method is called independently of the others in CaptureCallback,
* when a capture sequence aborts before any {@link CaptureResult}
* or {@link CaptureFailure} for it have been returned via this listener.
*
@@ -684,4 +691,11 @@
}
}
+ /**
+ * Temporary for migrating to Callback naming
+ * @hide
+ */
+ public static abstract class CaptureListener extends CaptureCallback {
+ }
+
}
diff --git a/core/java/android/hardware/camera2/CameraDevice.java b/core/java/android/hardware/camera2/CameraDevice.java
index 097b430..0bb742c 100644
--- a/core/java/android/hardware/camera2/CameraDevice.java
+++ b/core/java/android/hardware/camera2/CameraDevice.java
@@ -199,8 +199,8 @@
* <p>It can take several hundred milliseconds for the session's configuration to complete,
* since camera hardware may need to be powered on or reconfigured. Once the configuration is
* complete and the session is ready to actually capture data, the provided
- * {@link CameraCaptureSession.StateListener}'s
- * {@link CameraCaptureSession.StateListener#onConfigured} callback will be called.</p>
+ * {@link CameraCaptureSession.StateCallback}'s
+ * {@link CameraCaptureSession.StateCallback#onConfigured} callback will be called.</p>
*
* <p>If a prior CameraCaptureSession already exists when a new one is created, the previous
* session is closed. Any in-progress capture requests made on the prior session will be
@@ -340,12 +340,12 @@
*
* @param outputs The new set of Surfaces that should be made available as
* targets for captured image data.
- * @param listener The listener to notify about the status of the new capture session.
- * @param handler The handler on which the listener should be invoked, or {@code null} to use
+ * @param callback The callback to notify about the status of the new capture session.
+ * @param handler The handler on which the callback should be invoked, or {@code null} to use
* the current thread's {@link android.os.Looper looper}.
*
* @throws IllegalArgumentException if the set of output Surfaces do not meet the requirements,
- * the listener is null, or the handler is null but the current
+ * the callback is null, or the handler is null but the current
* thread has no looper.
* @throws CameraAccessException if the camera device is no longer connected or has
* encountered a fatal error
@@ -357,7 +357,7 @@
* @see StreamConfigurationMap#getOutputSizes(Class)
*/
public abstract void createCaptureSession(List<Surface> outputs,
- CameraCaptureSession.StateListener listener, Handler handler)
+ CameraCaptureSession.StateCallback callback, Handler handler)
throws CameraAccessException;
/**
@@ -393,10 +393,10 @@
*
* <p>Immediately after this call, all calls to the camera device or active session interface
* will throw a {@link IllegalStateException}, except for calls to close(). Once the device has
- * fully shut down, the {@link StateListener#onClosed} callback will be called, and the camera
+ * fully shut down, the {@link StateCallback#onClosed} callback will be called, and the camera
* is free to be re-opened.</p>
*
- * <p>Immediately after this call, besides the final {@link StateListener#onClosed} calls, no
+ * <p>Immediately after this call, besides the final {@link StateCallback#onClosed} calls, no
* further callbacks from the device or the active session will occur, and any remaining
* submitted capture requests will be discarded, as if
* {@link CameraCaptureSession#abortCaptures} had been called, except that no success or failure
@@ -407,24 +407,24 @@
public abstract void close();
/**
- * A listener for notifications about the state of a camera
- * device.
+ * A callback objects for receiving updates about the state of a camera device.
*
- * <p>A listener must be provided to the {@link CameraManager#openCamera}
- * method to open a camera device.</p>
+ * <p>A callback instance must be provided to the {@link CameraManager#openCamera} method to
+ * open a camera device.</p>
*
- * <p>These events include notifications about the device completing startup (
+ * <p>These state updates include notifications about the device completing startup (
* allowing for {@link #createCaptureSession} to be called), about device
* disconnection or closure, and about unexpected device errors.</p>
*
* <p>Events about the progress of specific {@link CaptureRequest CaptureRequests} are provided
- * through a {@link CameraCaptureSession.CaptureListener} given to the
+ * through a {@link CameraCaptureSession.CaptureCallback} given to the
* {@link CameraCaptureSession#capture}, {@link CameraCaptureSession#captureBurst},
- * {@link CameraCaptureSession#setRepeatingRequest}, or {@link CameraCaptureSession#setRepeatingBurst} methods.
+ * {@link CameraCaptureSession#setRepeatingRequest}, or
+ * {@link CameraCaptureSession#setRepeatingBurst} methods.
*
* @see CameraManager#openCamera
*/
- public static abstract class StateListener {
+ public static abstract class StateCallback {
/**
* An error code that can be reported by {@link #onError}
* indicating that the camera device is in use already.
@@ -530,7 +530,7 @@
* of a removable camera device; or the camera being needed for a
* higher-priority use case.</p>
*
- * <p>There may still be capture listener callbacks that are called
+ * <p>There may still be capture callbacks that are invoked
* after this method is called, or new image buffers that are delivered
* to active outputs.</p>
*
@@ -539,7 +539,7 @@
*
* <p>You should clean up the camera with {@link CameraDevice#close} after
* this happens, as it is not recoverable until opening the camera again
- * after it becomes {@link CameraManager.AvailabilityListener#onCameraAvailable available}.
+ * after it becomes {@link CameraManager.AvailabilityCallback#onCameraAvailable available}.
* </p>
*
* @param camera the device that has been disconnected
@@ -558,7 +558,7 @@
* {@link CameraAccessException#CAMERA_ERROR CAMERA_ERROR} reason.
* </p>
*
- * <p>There may still be capture completion or camera stream listeners
+ * <p>There may still be capture completion or camera stream callbacks
* that will be called after this error is received.</p>
*
* <p>You should clean up the camera with {@link CameraDevice#close} after
@@ -566,7 +566,7 @@
*
* @param camera The device reporting the error
* @param error The error code, one of the
- * {@code StateListener.ERROR_*} values.
+ * {@code StateCallback.ERROR_*} values.
*
* @see #ERROR_CAMERA_DEVICE
* @see #ERROR_CAMERA_SERVICE
@@ -577,6 +577,13 @@
}
/**
+ * Temporary for migrating to Callback naming
+ * @hide
+ */
+ public static abstract class StateListener extends StateCallback {
+ }
+
+ /**
* To be inherited by android.hardware.camera2.* code only.
* @hide
*/
diff --git a/core/java/android/hardware/camera2/CameraManager.java b/core/java/android/hardware/camera2/CameraManager.java
index a4a1559..9a9e4c2 100644
--- a/core/java/android/hardware/camera2/CameraManager.java
+++ b/core/java/android/hardware/camera2/CameraManager.java
@@ -69,8 +69,8 @@
private ArrayList<String> mDeviceIdList;
- private final ArrayMap<AvailabilityListener, Handler> mListenerMap =
- new ArrayMap<AvailabilityListener, Handler>();
+ private final ArrayMap<AvailabilityCallback, Handler> mCallbackMap =
+ new ArrayMap<AvailabilityCallback, Handler>();
private final Context mContext;
private final Object mLock = new Object();
@@ -108,19 +108,19 @@
}
/**
- * Register a listener to be notified about camera device availability.
+ * Register a callback to be notified about camera device availability.
*
- * <p>Registering the same listener again will replace the handler with the
+ * <p>Registering the same callback again will replace the handler with the
* new one provided.</p>
*
- * <p>The first time a listener is registered, it is immediately called
+ * <p>The first time a callback is registered, it is immediately called
* with the availability status of all currently known camera devices.</p>
*
- * @param listener The new listener to send camera availability notices to
- * @param handler The handler on which the listener should be invoked, or
+ * @param callback the new callback to send camera availability notices to
+ * @param handler The handler on which the callback should be invoked, or
* {@code null} to use the current thread's {@link android.os.Looper looper}.
*/
- public void addAvailabilityListener(AvailabilityListener listener, Handler handler) {
+ public void registerAvailabilityCallback(AvailabilityCallback callback, Handler handler) {
if (handler == null) {
Looper looper = Looper.myLooper();
if (looper == null) {
@@ -131,25 +131,25 @@
}
synchronized (mLock) {
- Handler oldHandler = mListenerMap.put(listener, handler);
- // For new listeners, provide initial availability information
+ Handler oldHandler = mCallbackMap.put(callback, handler);
+ // For new callbacks, provide initial availability information
if (oldHandler == null) {
- mServiceListener.updateListenerLocked(listener, handler);
+ mServiceListener.updateCallbackLocked(callback, handler);
}
}
}
/**
- * Remove a previously-added listener; the listener will no longer receive
- * connection and disconnection callbacks.
+ * Remove a previously-added callback; the callback will no longer receive connection and
+ * disconnection callbacks.
*
- * <p>Removing a listener that isn't registered has no effect.</p>
+ * <p>Removing a callback that isn't registered has no effect.</p>
*
- * @param listener The listener to remove from the notification list
+ * @param callback The callback to remove from the notification list
*/
- public void removeAvailabilityListener(AvailabilityListener listener) {
+ public void unregisterAvailabilityCallback(AvailabilityCallback callback) {
synchronized (mLock) {
- mListenerMap.remove(listener);
+ mCallbackMap.remove(callback);
}
}
@@ -228,8 +228,8 @@
* Helper for openning a connection to a camera with the given ID.
*
* @param cameraId The unique identifier of the camera device to open
- * @param listener The listener for the camera. Must not be null.
- * @param handler The handler to call the listener on. Must not be null.
+ * @param callback The callback for the camera. Must not be null.
+ * @param handler The handler to invoke the callback on. Must not be null.
*
* @throws CameraAccessException if the camera is disabled by device policy,
* or too many camera devices are already open, or the cameraId does not match
@@ -237,14 +237,14 @@
*
* @throws SecurityException if the application does not have permission to
* access the camera
- * @throws IllegalArgumentException if listener or handler is null.
+ * @throws IllegalArgumentException if callback or handler is null.
* @return A handle to the newly-created camera device.
*
* @see #getCameraIdList
* @see android.app.admin.DevicePolicyManager#setCameraDisabled
*/
private CameraDevice openCameraDeviceUserAsync(String cameraId,
- CameraDevice.StateListener listener, Handler handler)
+ CameraDevice.StateCallback callback, Handler handler)
throws CameraAccessException {
CameraCharacteristics characteristics = getCameraCharacteristics(cameraId);
CameraDevice device = null;
@@ -257,7 +257,7 @@
android.hardware.camera2.impl.CameraDeviceImpl deviceImpl =
new android.hardware.camera2.impl.CameraDeviceImpl(
cameraId,
- listener,
+ callback,
handler,
characteristics);
@@ -313,7 +313,7 @@
throw ce.asChecked();
}
- // TODO: factor out listener to be non-nested, then move setter to constructor
+ // TODO: factor out callback to be non-nested, then move setter to constructor
// For now, calling setRemoteDevice will fire initial
// onOpened/onUnconfigured callbacks.
deviceImpl.setRemoteDevice(cameraUser);
@@ -337,7 +337,7 @@
* is disconnected between the calls to {@link #getCameraIdList} and
* {@link #openCamera}.</p>
*
- * <p>Once the camera is successfully opened, {@link CameraDevice.StateListener#onOpened} will
+ * <p>Once the camera is successfully opened, {@link CameraDevice.StateCallback#onOpened} will
* be invoked with the newly opened {@link CameraDevice}. The camera device can then be set up
* for operation by calling {@link CameraDevice#createCaptureSession} and
* {@link CameraDevice#createCaptureRequest}</p>
@@ -345,31 +345,31 @@
* <!--
* <p>Since the camera device will be opened asynchronously, any asynchronous operations done
* on the returned CameraDevice instance will be queued up until the device startup has
- * completed and the listener's {@link CameraDevice.StateListener#onOpened onOpened} method is
+ * completed and the callback's {@link CameraDevice.StateCallback#onOpened onOpened} method is
* called. The pending operations are then processed in order.</p>
* -->
* <p>If the camera becomes disconnected during initialization
* after this function call returns,
- * {@link CameraDevice.StateListener#onDisconnected} with a
+ * {@link CameraDevice.StateCallback#onDisconnected} with a
* {@link CameraDevice} in the disconnected state (and
- * {@link CameraDevice.StateListener#onOpened} will be skipped).</p>
+ * {@link CameraDevice.StateCallback#onOpened} will be skipped).</p>
*
- * <p>If opening the camera device fails, then the device listener's
- * {@link CameraDevice.StateListener#onError onError} method will be called, and subsequent
+ * <p>If opening the camera device fails, then the device callback's
+ * {@link CameraDevice.StateCallback#onError onError} method will be called, and subsequent
* calls on the camera device will throw a {@link CameraAccessException}.</p>
*
* @param cameraId
* The unique identifier of the camera device to open
- * @param listener
- * The listener which is invoked once the camera is opened
+ * @param callback
+ * The callback which is invoked once the camera is opened
* @param handler
- * The handler on which the listener should be invoked, or
+ * The handler on which the callback should be invoked, or
* {@code null} to use the current thread's {@link android.os.Looper looper}.
*
* @throws CameraAccessException if the camera is disabled by device policy,
* or the camera has become or was disconnected.
*
- * @throws IllegalArgumentException if cameraId or the listener was null,
+ * @throws IllegalArgumentException if cameraId or the callback was null,
* or the cameraId does not match any currently or previously available
* camera device.
*
@@ -379,14 +379,14 @@
* @see #getCameraIdList
* @see android.app.admin.DevicePolicyManager#setCameraDisabled
*/
- public void openCamera(String cameraId, final CameraDevice.StateListener listener,
+ public void openCamera(String cameraId, final CameraDevice.StateCallback callback,
Handler handler)
throws CameraAccessException {
if (cameraId == null) {
throw new IllegalArgumentException("cameraId was null");
- } else if (listener == null) {
- throw new IllegalArgumentException("listener was null");
+ } else if (callback == null) {
+ throw new IllegalArgumentException("callback was null");
} else if (handler == null) {
if (Looper.myLooper() != null) {
handler = new Handler();
@@ -396,11 +396,11 @@
}
}
- openCameraDeviceUserAsync(cameraId, listener, handler);
+ openCameraDeviceUserAsync(cameraId, callback, handler);
}
/**
- * A listener for camera devices becoming available or
+ * A callback for camera devices becoming available or
* unavailable to open.
*
* <p>Cameras become available when they are no longer in use, or when a new
@@ -408,13 +408,13 @@
* application or service starts using a camera, or when a removable camera
* is disconnected.</p>
*
- * <p>Extend this listener and pass an instance of the subclass to
- * {@link CameraManager#addAvailabilityListener} to be notified of such availability
+ * <p>Extend this callback and pass an instance of the subclass to
+ * {@link CameraManager#registerAvailabilityCallback} to be notified of such availability
* changes.</p>
*
- * @see addAvailabilityListener
+ * @see registerAvailabilityCallback
*/
- public static abstract class AvailabilityListener {
+ public static abstract class AvailabilityCallback {
/**
* A new camera has become available to use.
@@ -432,7 +432,7 @@
*
* <p>If an application had an active CameraDevice instance for the
* now-disconnected camera, that application will receive a
- * {@link CameraDevice.StateListener#onDisconnected disconnection error}.</p>
+ * {@link CameraDevice.StateCallback#onDisconnected disconnection error}.</p>
*
* <p>The default implementation of this method does nothing.</p>
*
@@ -444,6 +444,13 @@
}
/**
+ * Temporary for migrating to Callback naming
+ * @hide
+ */
+ public static abstract class AvailabilityListener extends AvailabilityCallback {
+ }
+
+ /**
* Return or create the list of currently connected camera devices.
*
* <p>In case of errors connecting to the camera service, will return an empty list.</p>
@@ -707,14 +714,14 @@
}
}
- private void postSingleUpdate(final AvailabilityListener listener, final Handler handler,
+ private void postSingleUpdate(final AvailabilityCallback callback, final Handler handler,
final String id, final int status) {
if (isAvailable(status)) {
handler.post(
new Runnable() {
@Override
public void run() {
- listener.onCameraAvailable(id);
+ callback.onCameraAvailable(id);
}
});
} else {
@@ -722,7 +729,7 @@
new Runnable() {
@Override
public void run() {
- listener.onCameraUnavailable(id);
+ callback.onCameraUnavailable(id);
}
});
}
@@ -732,11 +739,11 @@
* Send the state of all known cameras to the provided listener, to initialize
* the listener's knowledge of camera state.
*/
- public void updateListenerLocked(AvailabilityListener listener, Handler handler) {
+ public void updateCallbackLocked(AvailabilityCallback callback, Handler handler) {
for (int i = 0; i < mDeviceStatus.size(); i++) {
String id = mDeviceStatus.keyAt(i);
Integer status = mDeviceStatus.valueAt(i);
- postSingleUpdate(listener, handler, id, status);
+ postSingleUpdate(callback, handler, id, status);
}
}
@@ -795,12 +802,12 @@
return;
}
- final int listenerCount = mListenerMap.size();
- for (int i = 0; i < listenerCount; i++) {
- Handler handler = mListenerMap.valueAt(i);
- final AvailabilityListener listener = mListenerMap.keyAt(i);
+ final int callbackCount = mCallbackMap.size();
+ for (int i = 0; i < callbackCount; i++) {
+ Handler handler = mCallbackMap.valueAt(i);
+ final AvailabilityCallback callback = mCallbackMap.keyAt(i);
- postSingleUpdate(listener, handler, id, status);
+ postSingleUpdate(callback, handler, id, status);
}
} // onStatusChangedLocked
diff --git a/core/java/android/hardware/camera2/CaptureFailure.java b/core/java/android/hardware/camera2/CaptureFailure.java
index b6d3b08..c168ff1 100644
--- a/core/java/android/hardware/camera2/CaptureFailure.java
+++ b/core/java/android/hardware/camera2/CaptureFailure.java
@@ -65,12 +65,12 @@
* Get the request associated with this failed capture.
*
* <p>Whenever a request is unsuccessfully captured, with
- * {@link CameraCaptureSession.CaptureListener#onCaptureFailed},
+ * {@link CameraCaptureSession.CaptureCallback#onCaptureFailed},
* the {@code failed capture}'s {@code getRequest()} will return that {@code request}.
* </p>
*
* <p>In particular,
- * <code><pre>cameraDevice.capture(someRequest, new CaptureListener() {
+ * <code><pre>cameraDevice.capture(someRequest, new CaptureCallback() {
* {@literal @}Override
* void onCaptureFailed(CaptureRequest myRequest, CaptureFailure myFailure) {
* assert(myFailure.getRequest.equals(myRequest) == true);
@@ -135,7 +135,7 @@
*
* @return int The ID for the sequence of requests that this capture failure is the result of
*
- * @see CameraDevice.CaptureListener#onCaptureSequenceCompleted
+ * @see CameraDevice.CaptureCallback#onCaptureSequenceCompleted
*/
public int getSequenceId() {
return mSequenceId;
diff --git a/core/java/android/hardware/camera2/CaptureRequest.java b/core/java/android/hardware/camera2/CaptureRequest.java
index bcdcd62..6d0d505 100644
--- a/core/java/android/hardware/camera2/CaptureRequest.java
+++ b/core/java/android/hardware/camera2/CaptureRequest.java
@@ -245,7 +245,7 @@
* <p>This tag is not used for anything by the camera device, but can be
* used by an application to easily identify a CaptureRequest when it is
* returned by
- * {@link CameraCaptureSession.CaptureListener#onCaptureCompleted CaptureListener.onCaptureCompleted}
+ * {@link CameraCaptureSession.CaptureCallback#onCaptureCompleted CaptureCallback.onCaptureCompleted}
* </p>
*
* @return the last tag Object set on this request, or {@code null} if
@@ -435,7 +435,7 @@
* <p>This tag is not used for anything by the camera device, but can be
* used by an application to easily identify a CaptureRequest when it is
* returned by
- * {@link CameraCaptureSession.CaptureListener#onCaptureCompleted CaptureListener.onCaptureCompleted}
+ * {@link CameraCaptureSession.CaptureCallback#onCaptureCompleted CaptureCallback.onCaptureCompleted}
*
* @param tag an arbitrary Object to store with this request
* @see CaptureRequest#getTag
diff --git a/core/java/android/hardware/camera2/CaptureResult.java b/core/java/android/hardware/camera2/CaptureResult.java
index f9c4df4..754d83e 100644
--- a/core/java/android/hardware/camera2/CaptureResult.java
+++ b/core/java/android/hardware/camera2/CaptureResult.java
@@ -268,13 +268,13 @@
* Get the request associated with this result.
*
* <p>Whenever a request has been fully or partially captured, with
- * {@link CameraCaptureSession.CaptureListener#onCaptureCompleted} or
- * {@link CameraCaptureSession.CaptureListener#onCaptureProgressed}, the {@code result}'s
+ * {@link CameraCaptureSession.CaptureCallback#onCaptureCompleted} or
+ * {@link CameraCaptureSession.CaptureCallback#onCaptureProgressed}, the {@code result}'s
* {@code getRequest()} will return that {@code request}.
* </p>
*
* <p>For example,
- * <code><pre>cameraDevice.capture(someRequest, new CaptureListener() {
+ * <code><pre>cameraDevice.capture(someRequest, new CaptureCallback() {
* {@literal @}Override
* void onCaptureCompleted(CaptureRequest myRequest, CaptureResult myResult) {
* assert(myResult.getRequest.equals(myRequest) == true);
@@ -314,8 +314,8 @@
*
* @return int The ID for the sequence of requests that this capture result is a part of
*
- * @see CameraDevice.CaptureListener#onCaptureSequenceCompleted
- * @see CameraDevice.CaptureListener#onCaptureSequenceAborted
+ * @see CameraDevice.CaptureCallback#onCaptureSequenceCompleted
+ * @see CameraDevice.CaptureCallback#onCaptureSequenceAborted
*/
public int getSequenceId() {
return mSequenceId;
diff --git a/core/java/android/hardware/camera2/TotalCaptureResult.java b/core/java/android/hardware/camera2/TotalCaptureResult.java
index 0895fe3..6f7dd78 100644
--- a/core/java/android/hardware/camera2/TotalCaptureResult.java
+++ b/core/java/android/hardware/camera2/TotalCaptureResult.java
@@ -45,7 +45,7 @@
*
* <p>{@link TotalCaptureResult} objects are immutable.</p>
*
- * @see CameraDevice.CaptureListener#onCaptureCompleted
+ * @see CameraDevice.CaptureCallback#onCaptureCompleted
*/
public final class TotalCaptureResult extends CaptureResult {
@@ -88,7 +88,7 @@
*
* <p>The list size will be inclusive between {@code 0} and
* {@link CameraCharacteristics#REQUEST_PARTIAL_RESULT_COUNT}, with elements in ascending order
- * of when {@link CameraCaptureSession.CaptureListener#onCaptureProgressed} was invoked.</p>
+ * of when {@link CameraCaptureSession.CaptureCallback#onCaptureProgressed} was invoked.</p>
*
* @return unmodifiable list of partial results
*/
diff --git a/core/java/android/hardware/camera2/impl/ListenerProxies.java b/core/java/android/hardware/camera2/impl/CallbackProxies.java
similarity index 84%
rename from core/java/android/hardware/camera2/impl/ListenerProxies.java
rename to core/java/android/hardware/camera2/impl/CallbackProxies.java
index f44f9ad..e5ddb7a 100644
--- a/core/java/android/hardware/camera2/impl/ListenerProxies.java
+++ b/core/java/android/hardware/camera2/impl/CallbackProxies.java
@@ -27,22 +27,22 @@
import static com.android.internal.util.Preconditions.*;
/**
- * Proxy out invocations to the camera2 API listeners into a {@link Dispatchable}.
+ * Proxy out invocations to the camera2 API callbacks into a {@link Dispatchable}.
*
* <p>Since abstract classes do not support Java's dynamic {@code Proxy}, we have to
* to use our own proxy mechanism.</p>
*/
-public class ListenerProxies {
+public class CallbackProxies {
// TODO: replace with codegen
- public static class DeviceStateListenerProxy extends CameraDeviceImpl.StateListenerKK {
- private final MethodNameInvoker<CameraDeviceImpl.StateListenerKK> mProxy;
+ public static class DeviceStateCallbackProxy extends CameraDeviceImpl.StateCallbackKK {
+ private final MethodNameInvoker<CameraDeviceImpl.StateCallbackKK> mProxy;
- public DeviceStateListenerProxy(
- Dispatchable<CameraDeviceImpl.StateListenerKK> dispatchTarget) {
+ public DeviceStateCallbackProxy(
+ Dispatchable<CameraDeviceImpl.StateCallbackKK> dispatchTarget) {
dispatchTarget = checkNotNull(dispatchTarget, "dispatchTarget must not be null");
- mProxy = new MethodNameInvoker<>(dispatchTarget, CameraDeviceImpl.StateListenerKK.class);
+ mProxy = new MethodNameInvoker<>(dispatchTarget, CameraDeviceImpl.StateCallbackKK.class);
}
@Override
@@ -87,13 +87,13 @@
}
@SuppressWarnings("deprecation")
- public static class DeviceCaptureListenerProxy extends CameraDeviceImpl.CaptureListener {
- private final MethodNameInvoker<CameraDeviceImpl.CaptureListener> mProxy;
+ public static class DeviceCaptureCallbackProxy extends CameraDeviceImpl.CaptureCallback {
+ private final MethodNameInvoker<CameraDeviceImpl.CaptureCallback> mProxy;
- public DeviceCaptureListenerProxy(
- Dispatchable<CameraDeviceImpl.CaptureListener> dispatchTarget) {
+ public DeviceCaptureCallbackProxy(
+ Dispatchable<CameraDeviceImpl.CaptureCallback> dispatchTarget) {
dispatchTarget = checkNotNull(dispatchTarget, "dispatchTarget must not be null");
- mProxy = new MethodNameInvoker<>(dispatchTarget, CameraDeviceImpl.CaptureListener.class);
+ mProxy = new MethodNameInvoker<>(dispatchTarget, CameraDeviceImpl.CaptureCallback.class);
}
@Override
@@ -139,15 +139,15 @@
}
}
- public static class SessionStateListenerProxy
- extends CameraCaptureSession.StateListener {
- private final MethodNameInvoker<CameraCaptureSession.StateListener> mProxy;
+ public static class SessionStateCallbackProxy
+ extends CameraCaptureSession.StateCallback {
+ private final MethodNameInvoker<CameraCaptureSession.StateCallback> mProxy;
- public SessionStateListenerProxy(
- Dispatchable<CameraCaptureSession.StateListener> dispatchTarget) {
+ public SessionStateCallbackProxy(
+ Dispatchable<CameraCaptureSession.StateCallback> dispatchTarget) {
dispatchTarget = checkNotNull(dispatchTarget, "dispatchTarget must not be null");
mProxy = new MethodNameInvoker<>(dispatchTarget,
- CameraCaptureSession.StateListener.class);
+ CameraCaptureSession.StateCallback.class);
}
@Override
@@ -177,7 +177,7 @@
}
}
- private ListenerProxies() {
+ private CallbackProxies() {
throw new AssertionError();
}
}
diff --git a/core/java/android/hardware/camera2/impl/CameraCaptureSessionImpl.java b/core/java/android/hardware/camera2/impl/CameraCaptureSessionImpl.java
index 9ca1fba..843f117 100644
--- a/core/java/android/hardware/camera2/impl/CameraCaptureSessionImpl.java
+++ b/core/java/android/hardware/camera2/impl/CameraCaptureSessionImpl.java
@@ -45,11 +45,11 @@
/** User-specified set of surfaces used as the configuration outputs */
private final List<Surface> mOutputs;
/**
- * User-specified state listener, used for outgoing events; calls to this object will be
+ * User-specified state callback, used for outgoing events; calls to this object will be
* automatically {@link Handler#post(Runnable) posted} to {@code mStateHandler}.
*/
- private final CameraCaptureSession.StateListener mStateListener;
- /** User-specified state handler used for outgoing state listener events */
+ private final CameraCaptureSession.StateCallback mStateCallback;
+ /** User-specified state handler used for outgoing state callback events */
private final Handler mStateHandler;
/** Internal camera device; used to translate calls into existing deprecated API */
@@ -84,28 +84,28 @@
* (e.g. no pending captures, no repeating requests, no flush).</p>
*/
CameraCaptureSessionImpl(List<Surface> outputs,
- CameraCaptureSession.StateListener listener, Handler stateHandler,
+ CameraCaptureSession.StateCallback callback, Handler stateHandler,
android.hardware.camera2.impl.CameraDeviceImpl deviceImpl,
Handler deviceStateHandler, boolean configureSuccess) {
if (outputs == null || outputs.isEmpty()) {
throw new IllegalArgumentException("outputs must be a non-null, non-empty list");
- } else if (listener == null) {
- throw new IllegalArgumentException("listener must not be null");
+ } else if (callback == null) {
+ throw new IllegalArgumentException("callback must not be null");
}
// TODO: extra verification of outputs
mOutputs = outputs;
mStateHandler = checkHandler(stateHandler);
- mStateListener = createUserStateListenerProxy(mStateHandler, listener);
+ mStateCallback = createUserStateCallbackProxy(mStateHandler, callback);
mDeviceHandler = checkNotNull(deviceStateHandler, "deviceStateHandler must not be null");
mDeviceImpl = checkNotNull(deviceImpl, "deviceImpl must not be null");
/*
- * Use the same handler as the device's StateListener for all the internal coming events
+ * Use the same handler as the device's StateCallback for all the internal coming events
*
- * This ensures total ordering between CameraDevice.StateListener and
- * CameraDeviceImpl.CaptureListener events.
+ * This ensures total ordering between CameraDevice.StateCallback and
+ * CameraDeviceImpl.CaptureCallback events.
*/
mSequenceDrainer = new TaskDrainer<>(mDeviceHandler, new SequenceDrainListener(),
/*name*/"seq");
@@ -119,11 +119,11 @@
// CameraDevice should call configureOutputs and have it finish before constructing us
if (configureSuccess) {
- mStateListener.onConfigured(this);
+ mStateCallback.onConfigured(this);
if (VERBOSE) Log.v(TAG, "ctor - Created session successfully");
mConfigureSuccess = true;
} else {
- mStateListener.onConfigureFailed(this);
+ mStateCallback.onConfigureFailed(this);
mClosed = true; // do not fire any other callbacks, do not allow any other work
Log.e(TAG, "Failed to create capture session; configuration failed");
mConfigureSuccess = false;
@@ -136,7 +136,7 @@
}
@Override
- public synchronized int capture(CaptureRequest request, CaptureListener listener,
+ public synchronized int capture(CaptureRequest request, CaptureCallback callback,
Handler handler) throws CameraAccessException {
if (request == null) {
throw new IllegalArgumentException("request must not be null");
@@ -145,19 +145,19 @@
checkNotClosed();
checkLegalToCapture();
- handler = checkHandler(handler, listener);
+ handler = checkHandler(handler, callback);
if (VERBOSE) {
- Log.v(TAG, "capture - request " + request + ", listener " + listener + " handler" +
+ Log.v(TAG, "capture - request " + request + ", callback " + callback + " handler" +
" " + handler);
}
return addPendingSequence(mDeviceImpl.capture(request,
- createCaptureListenerProxy(handler, listener), mDeviceHandler));
+ createCaptureCallbackProxy(handler, callback), mDeviceHandler));
}
@Override
- public synchronized int captureBurst(List<CaptureRequest> requests, CaptureListener listener,
+ public synchronized int captureBurst(List<CaptureRequest> requests, CaptureCallback callback,
Handler handler) throws CameraAccessException {
if (requests == null) {
throw new IllegalArgumentException("requests must not be null");
@@ -168,20 +168,20 @@
checkNotClosed();
checkLegalToCapture();
- handler = checkHandler(handler, listener);
+ handler = checkHandler(handler, callback);
if (VERBOSE) {
CaptureRequest[] requestArray = requests.toArray(new CaptureRequest[0]);
- Log.v(TAG, "captureBurst - requests " + Arrays.toString(requestArray) + ", listener " +
- listener + " handler" + "" + handler);
+ Log.v(TAG, "captureBurst - requests " + Arrays.toString(requestArray) + ", callback " +
+ callback + " handler" + "" + handler);
}
return addPendingSequence(mDeviceImpl.captureBurst(requests,
- createCaptureListenerProxy(handler, listener), mDeviceHandler));
+ createCaptureCallbackProxy(handler, callback), mDeviceHandler));
}
@Override
- public synchronized int setRepeatingRequest(CaptureRequest request, CaptureListener listener,
+ public synchronized int setRepeatingRequest(CaptureRequest request, CaptureCallback callback,
Handler handler) throws CameraAccessException {
if (request == null) {
throw new IllegalArgumentException("request must not be null");
@@ -190,20 +190,20 @@
checkNotClosed();
checkLegalToCapture();
- handler = checkHandler(handler, listener);
+ handler = checkHandler(handler, callback);
if (VERBOSE) {
- Log.v(TAG, "setRepeatingRequest - request " + request + ", listener " + listener +
+ Log.v(TAG, "setRepeatingRequest - request " + request + ", callback " + callback +
" handler" + " " + handler);
}
return addPendingSequence(mDeviceImpl.setRepeatingRequest(request,
- createCaptureListenerProxy(handler, listener), mDeviceHandler));
+ createCaptureCallbackProxy(handler, callback), mDeviceHandler));
}
@Override
public synchronized int setRepeatingBurst(List<CaptureRequest> requests,
- CaptureListener listener, Handler handler) throws CameraAccessException {
+ CaptureCallback callback, Handler handler) throws CameraAccessException {
if (requests == null) {
throw new IllegalArgumentException("requests must not be null");
} else if (requests.isEmpty()) {
@@ -213,16 +213,16 @@
checkNotClosed();
checkLegalToCapture();
- handler = checkHandler(handler, listener);
+ handler = checkHandler(handler, callback);
if (VERBOSE) {
CaptureRequest[] requestArray = requests.toArray(new CaptureRequest[0]);
Log.v(TAG, "setRepeatingBurst - requests " + Arrays.toString(requestArray) +
- ", listener " + listener + " handler" + "" + handler);
+ ", callback " + callback + " handler" + "" + handler);
}
return addPendingSequence(mDeviceImpl.setRepeatingBurst(requests,
- createCaptureListenerProxy(handler, listener), mDeviceHandler));
+ createCaptureCallbackProxy(handler, callback), mDeviceHandler));
}
@Override
@@ -331,8 +331,8 @@
// or just suppress the ISE only and rely onClosed.
// Also skip any of the draining work if this is already closed.
- // Short-circuit; queue listener immediately and return
- mStateListener.onClosed(this);
+ // Short-circuit; queue callback immediately and return
+ mStateCallback.onClosed(this);
return;
} catch (CameraAccessException e) {
// OK: close does not throw checked exceptions.
@@ -360,30 +360,30 @@
}
/**
- * Post calls into a CameraCaptureSession.StateListener to the user-specified {@code handler}.
+ * Post calls into a CameraCaptureSession.StateCallback to the user-specified {@code handler}.
*/
- private StateListener createUserStateListenerProxy(Handler handler, StateListener listener) {
- InvokeDispatcher<StateListener> userListenerSink = new InvokeDispatcher<>(listener);
- HandlerDispatcher<StateListener> handlerPassthrough =
- new HandlerDispatcher<>(userListenerSink, handler);
+ private StateCallback createUserStateCallbackProxy(Handler handler, StateCallback callback) {
+ InvokeDispatcher<StateCallback> userCallbackSink = new InvokeDispatcher<>(callback);
+ HandlerDispatcher<StateCallback> handlerPassthrough =
+ new HandlerDispatcher<>(userCallbackSink, handler);
- return new ListenerProxies.SessionStateListenerProxy(handlerPassthrough);
+ return new CallbackProxies.SessionStateCallbackProxy(handlerPassthrough);
}
/**
* Forward callbacks from
- * CameraDeviceImpl.CaptureListener to the CameraCaptureSession.CaptureListener.
+ * CameraDeviceImpl.CaptureCallback to the CameraCaptureSession.CaptureCallback.
*
* <p>In particular, all calls are automatically split to go both to our own
- * internal listener, and to the user-specified listener (by transparently posting
+ * internal callback, and to the user-specified callback (by transparently posting
* to the user-specified handler).</p>
*
* <p>When a capture sequence finishes, update the pending checked sequences set.</p>
*/
@SuppressWarnings("deprecation")
- private CameraDeviceImpl.CaptureListener createCaptureListenerProxy(
- Handler handler, CaptureListener listener) {
- CameraDeviceImpl.CaptureListener localListener = new CameraDeviceImpl.CaptureListener() {
+ private CameraDeviceImpl.CaptureCallback createCaptureCallbackProxy(
+ Handler handler, CaptureCallback callback) {
+ CameraDeviceImpl.CaptureCallback localCallback = new CameraDeviceImpl.CaptureCallback() {
@Override
public void onCaptureSequenceCompleted(CameraDevice camera,
int sequenceId, long frameNumber) {
@@ -398,43 +398,43 @@
};
/*
- * Split the calls from the device listener into local listener and the following chain:
+ * Split the calls from the device callback into local callback and the following chain:
* - replace the first CameraDevice arg with a CameraCaptureSession
- * - duck type from device listener to session listener
+ * - duck type from device callback to session callback
* - then forward the call to a handler
- * - then finally invoke the destination method on the session listener object
+ * - then finally invoke the destination method on the session callback object
*/
- if (listener == null) {
- // OK: API allows the user to not specify a listener, and the handler may
+ if (callback == null) {
+ // OK: API allows the user to not specify a callback, and the handler may
// also be null in that case. Collapse whole dispatch chain to only call the local
- // listener
- return localListener;
+ // callback
+ return localCallback;
}
- InvokeDispatcher<CameraDeviceImpl.CaptureListener> localSink =
- new InvokeDispatcher<>(localListener);
+ InvokeDispatcher<CameraDeviceImpl.CaptureCallback> localSink =
+ new InvokeDispatcher<>(localCallback);
- InvokeDispatcher<CaptureListener> userListenerSink =
- new InvokeDispatcher<>(listener);
- HandlerDispatcher<CaptureListener> handlerPassthrough =
- new HandlerDispatcher<>(userListenerSink, handler);
- DuckTypingDispatcher<CameraDeviceImpl.CaptureListener, CaptureListener> duckToSession
- = new DuckTypingDispatcher<>(handlerPassthrough, CaptureListener.class);
- ArgumentReplacingDispatcher<CameraDeviceImpl.CaptureListener, CameraCaptureSessionImpl>
+ InvokeDispatcher<CaptureCallback> userCallbackSink =
+ new InvokeDispatcher<>(callback);
+ HandlerDispatcher<CaptureCallback> handlerPassthrough =
+ new HandlerDispatcher<>(userCallbackSink, handler);
+ DuckTypingDispatcher<CameraDeviceImpl.CaptureCallback, CaptureCallback> duckToSession
+ = new DuckTypingDispatcher<>(handlerPassthrough, CaptureCallback.class);
+ ArgumentReplacingDispatcher<CameraDeviceImpl.CaptureCallback, CameraCaptureSessionImpl>
replaceDeviceWithSession = new ArgumentReplacingDispatcher<>(duckToSession,
/*argumentIndex*/0, this);
- BroadcastDispatcher<CameraDeviceImpl.CaptureListener> broadcaster =
- new BroadcastDispatcher<CameraDeviceImpl.CaptureListener>(
+ BroadcastDispatcher<CameraDeviceImpl.CaptureCallback> broadcaster =
+ new BroadcastDispatcher<CameraDeviceImpl.CaptureCallback>(
replaceDeviceWithSession,
localSink);
- return new ListenerProxies.DeviceCaptureListenerProxy(broadcaster);
+ return new CallbackProxies.DeviceCaptureCallbackProxy(broadcaster);
}
/**
*
- * Create an internal state listener, to be invoked on the mDeviceHandler
+ * Create an internal state callback, to be invoked on the mDeviceHandler
*
* <p>It has a few behaviors:
* <ul>
@@ -443,10 +443,10 @@
* </ul>
* </p>
* */
- CameraDeviceImpl.StateListenerKK getDeviceStateListener() {
+ CameraDeviceImpl.StateCallbackKK getDeviceStateCallback() {
final CameraCaptureSession session = this;
- return new CameraDeviceImpl.StateListenerKK() {
+ return new CameraDeviceImpl.StateCallbackKK() {
private boolean mBusy = false;
private boolean mActive = false;
@@ -471,7 +471,7 @@
mIdleDrainer.taskStarted();
mActive = true;
- mStateListener.onActive(session);
+ mStateCallback.onActive(session);
}
@Override
@@ -507,7 +507,7 @@
mBusy = false;
mActive = false;
- mStateListener.onReady(session);
+ mStateCallback.onReady(session);
}
@Override
@@ -629,7 +629,7 @@
// Fast path: A new capture session has replaced this one; don't unconfigure.
if (mSkipUnconfigure) {
- mStateListener.onClosed(CameraCaptureSessionImpl.this);
+ mStateCallback.onClosed(CameraCaptureSessionImpl.this);
return;
}
@@ -655,7 +655,7 @@
public void onDrained() {
synchronized (CameraCaptureSessionImpl.this) {
// The device has finished unconfiguring. It's now fully closed.
- mStateListener.onClosed(CameraCaptureSessionImpl.this);
+ mStateCallback.onClosed(CameraCaptureSessionImpl.this);
}
}
}
diff --git a/core/java/android/hardware/camera2/impl/CameraDeviceImpl.java b/core/java/android/hardware/camera2/impl/CameraDeviceImpl.java
index f5666bf..d454092 100644
--- a/core/java/android/hardware/camera2/impl/CameraDeviceImpl.java
+++ b/core/java/android/hardware/camera2/impl/CameraDeviceImpl.java
@@ -64,17 +64,17 @@
private final Object mInterfaceLock = new Object();
private final CameraDeviceCallbacks mCallbacks = new CameraDeviceCallbacks();
- private final StateListener mDeviceListener;
- private volatile StateListenerKK mSessionStateListener;
+ private final StateCallback mDeviceCallback;
+ private volatile StateCallbackKK mSessionStateCallback;
private final Handler mDeviceHandler;
private volatile boolean mClosing = false;
private boolean mInError = false;
private boolean mIdle = true;
- /** map request IDs to listener/request data */
- private final SparseArray<CaptureListenerHolder> mCaptureListenerMap =
- new SparseArray<CaptureListenerHolder>();
+ /** map request IDs to callback/request data */
+ private final SparseArray<CaptureCallbackHolder> mCaptureCallbackMap =
+ new SparseArray<CaptureCallbackHolder>();
private int mRepeatingRequestId = REQUEST_ID_NONE;
private final ArrayList<Integer> mRepeatingRequestIdDeletedList = new ArrayList<Integer>();
@@ -106,30 +106,30 @@
private final Runnable mCallOnOpened = new Runnable() {
@Override
public void run() {
- StateListenerKK sessionListener = null;
+ StateCallbackKK sessionCallback = null;
synchronized(mInterfaceLock) {
if (mRemoteDevice == null) return; // Camera already closed
- sessionListener = mSessionStateListener;
+ sessionCallback = mSessionStateCallback;
}
- if (sessionListener != null) {
- sessionListener.onOpened(CameraDeviceImpl.this);
+ if (sessionCallback != null) {
+ sessionCallback.onOpened(CameraDeviceImpl.this);
}
- mDeviceListener.onOpened(CameraDeviceImpl.this);
+ mDeviceCallback.onOpened(CameraDeviceImpl.this);
}
};
private final Runnable mCallOnUnconfigured = new Runnable() {
@Override
public void run() {
- StateListenerKK sessionListener = null;
+ StateCallbackKK sessionCallback = null;
synchronized(mInterfaceLock) {
if (mRemoteDevice == null) return; // Camera already closed
- sessionListener = mSessionStateListener;
+ sessionCallback = mSessionStateCallback;
}
- if (sessionListener != null) {
- sessionListener.onUnconfigured(CameraDeviceImpl.this);
+ if (sessionCallback != null) {
+ sessionCallback.onUnconfigured(CameraDeviceImpl.this);
}
}
};
@@ -137,14 +137,14 @@
private final Runnable mCallOnActive = new Runnable() {
@Override
public void run() {
- StateListenerKK sessionListener = null;
+ StateCallbackKK sessionCallback = null;
synchronized(mInterfaceLock) {
if (mRemoteDevice == null) return; // Camera already closed
- sessionListener = mSessionStateListener;
+ sessionCallback = mSessionStateCallback;
}
- if (sessionListener != null) {
- sessionListener.onActive(CameraDeviceImpl.this);
+ if (sessionCallback != null) {
+ sessionCallback.onActive(CameraDeviceImpl.this);
}
}
};
@@ -152,14 +152,14 @@
private final Runnable mCallOnBusy = new Runnable() {
@Override
public void run() {
- StateListenerKK sessionListener = null;
+ StateCallbackKK sessionCallback = null;
synchronized(mInterfaceLock) {
if (mRemoteDevice == null) return; // Camera already closed
- sessionListener = mSessionStateListener;
+ sessionCallback = mSessionStateCallback;
}
- if (sessionListener != null) {
- sessionListener.onBusy(CameraDeviceImpl.this);
+ if (sessionCallback != null) {
+ sessionCallback.onBusy(CameraDeviceImpl.this);
}
}
};
@@ -172,14 +172,14 @@
if (mClosedOnce) {
throw new AssertionError("Don't post #onClosed more than once");
}
- StateListenerKK sessionListener = null;
+ StateCallbackKK sessionCallback = null;
synchronized(mInterfaceLock) {
- sessionListener = mSessionStateListener;
+ sessionCallback = mSessionStateCallback;
}
- if (sessionListener != null) {
- sessionListener.onClosed(CameraDeviceImpl.this);
+ if (sessionCallback != null) {
+ sessionCallback.onClosed(CameraDeviceImpl.this);
}
- mDeviceListener.onClosed(CameraDeviceImpl.this);
+ mDeviceCallback.onClosed(CameraDeviceImpl.this);
mClosedOnce = true;
}
};
@@ -187,14 +187,14 @@
private final Runnable mCallOnIdle = new Runnable() {
@Override
public void run() {
- StateListenerKK sessionListener = null;
+ StateCallbackKK sessionCallback = null;
synchronized(mInterfaceLock) {
if (mRemoteDevice == null) return; // Camera already closed
- sessionListener = mSessionStateListener;
+ sessionCallback = mSessionStateCallback;
}
- if (sessionListener != null) {
- sessionListener.onIdle(CameraDeviceImpl.this);
+ if (sessionCallback != null) {
+ sessionCallback.onIdle(CameraDeviceImpl.this);
}
}
};
@@ -202,26 +202,26 @@
private final Runnable mCallOnDisconnected = new Runnable() {
@Override
public void run() {
- StateListenerKK sessionListener = null;
+ StateCallbackKK sessionCallback = null;
synchronized(mInterfaceLock) {
if (mRemoteDevice == null) return; // Camera already closed
- sessionListener = mSessionStateListener;
+ sessionCallback = mSessionStateCallback;
}
- if (sessionListener != null) {
- sessionListener.onDisconnected(CameraDeviceImpl.this);
+ if (sessionCallback != null) {
+ sessionCallback.onDisconnected(CameraDeviceImpl.this);
}
- mDeviceListener.onDisconnected(CameraDeviceImpl.this);
+ mDeviceCallback.onDisconnected(CameraDeviceImpl.this);
}
};
- public CameraDeviceImpl(String cameraId, StateListener listener, Handler handler,
+ public CameraDeviceImpl(String cameraId, StateCallback callback, Handler handler,
CameraCharacteristics characteristics) {
- if (cameraId == null || listener == null || handler == null || characteristics == null) {
+ if (cameraId == null || callback == null || handler == null || characteristics == null) {
throw new IllegalArgumentException("Null argument given");
}
mCameraId = cameraId;
- mDeviceListener = listener;
+ mDeviceCallback = callback;
mDeviceHandler = handler;
mCharacteristics = characteristics;
@@ -263,28 +263,28 @@
/**
* Call to indicate failed connection to a remote camera device.
*
- * <p>This places the camera device in the error state and informs the listener.
+ * <p>This places the camera device in the error state and informs the callback.
* Use in place of setRemoteDevice() when startup fails.</p>
*/
public void setRemoteFailure(final CameraRuntimeException failure) {
- int failureCode = StateListener.ERROR_CAMERA_DEVICE;
+ int failureCode = StateCallback.ERROR_CAMERA_DEVICE;
boolean failureIsError = true;
switch (failure.getReason()) {
case CameraAccessException.CAMERA_IN_USE:
- failureCode = StateListener.ERROR_CAMERA_IN_USE;
+ failureCode = StateCallback.ERROR_CAMERA_IN_USE;
break;
case CameraAccessException.MAX_CAMERAS_IN_USE:
- failureCode = StateListener.ERROR_MAX_CAMERAS_IN_USE;
+ failureCode = StateCallback.ERROR_MAX_CAMERAS_IN_USE;
break;
case CameraAccessException.CAMERA_DISABLED:
- failureCode = StateListener.ERROR_CAMERA_DISABLED;
+ failureCode = StateCallback.ERROR_CAMERA_DISABLED;
break;
case CameraAccessException.CAMERA_DISCONNECTED:
failureIsError = false;
break;
case CameraAccessException.CAMERA_ERROR:
- failureCode = StateListener.ERROR_CAMERA_DEVICE;
+ failureCode = StateCallback.ERROR_CAMERA_DEVICE;
break;
default:
Log.wtf(TAG, "Unknown failure in opening camera device: " + failure.getReason());
@@ -298,9 +298,9 @@
@Override
public void run() {
if (isError) {
- mDeviceListener.onError(CameraDeviceImpl.this, code);
+ mDeviceCallback.onError(CameraDeviceImpl.this, code);
} else {
- mDeviceListener.onDisconnected(CameraDeviceImpl.this);
+ mDeviceCallback.onDisconnected(CameraDeviceImpl.this);
}
}
});
@@ -415,7 +415,7 @@
@Override
public void createCaptureSession(List<Surface> outputs,
- CameraCaptureSession.StateListener listener, Handler handler)
+ CameraCaptureSession.StateCallback callback, Handler handler)
throws CameraAccessException {
synchronized(mInterfaceLock) {
if (DEBUG) {
@@ -445,7 +445,7 @@
// Fire onConfigured if configureOutputs succeeded, fire onConfigureFailed otherwise.
CameraCaptureSessionImpl newSession =
- new CameraCaptureSessionImpl(outputs, listener, handler, this, mDeviceHandler,
+ new CameraCaptureSessionImpl(outputs, callback, handler, this, mDeviceHandler,
configureSuccess);
// TODO: wait until current session closes, then create the new session
@@ -455,16 +455,16 @@
throw pendingException;
}
- mSessionStateListener = mCurrentSession.getDeviceStateListener();
+ mSessionStateCallback = mCurrentSession.getDeviceStateCallback();
}
}
/**
* For use by backwards-compatibility code only.
*/
- public void setSessionListener(StateListenerKK sessionListener) {
+ public void setSessionListener(StateCallbackKK sessionCallback) {
synchronized(mInterfaceLock) {
- mSessionStateListener = sessionListener;
+ mSessionStateCallback = sessionCallback;
}
}
@@ -492,22 +492,22 @@
}
}
- public int capture(CaptureRequest request, CaptureListener listener, Handler handler)
+ public int capture(CaptureRequest request, CaptureCallback callback, Handler handler)
throws CameraAccessException {
if (DEBUG) {
Log.d(TAG, "calling capture");
}
List<CaptureRequest> requestList = new ArrayList<CaptureRequest>();
requestList.add(request);
- return submitCaptureRequest(requestList, listener, handler, /*streaming*/false);
+ return submitCaptureRequest(requestList, callback, handler, /*streaming*/false);
}
- public int captureBurst(List<CaptureRequest> requests, CaptureListener listener,
+ public int captureBurst(List<CaptureRequest> requests, CaptureCallback callback,
Handler handler) throws CameraAccessException {
if (requests == null || requests.isEmpty()) {
throw new IllegalArgumentException("At least one request must be given");
}
- return submitCaptureRequest(requests, listener, handler, /*streaming*/false);
+ return submitCaptureRequest(requests, callback, handler, /*streaming*/false);
}
/**
@@ -527,12 +527,12 @@
final int requestId, final long lastFrameNumber) {
// lastFrameNumber being equal to NO_FRAMES_CAPTURED means that the request
// was never sent to HAL. Should trigger onCaptureSequenceAborted immediately.
- if (lastFrameNumber == CaptureListener.NO_FRAMES_CAPTURED) {
- final CaptureListenerHolder holder;
- int index = mCaptureListenerMap.indexOfKey(requestId);
- holder = (index >= 0) ? mCaptureListenerMap.valueAt(index) : null;
+ if (lastFrameNumber == CaptureCallback.NO_FRAMES_CAPTURED) {
+ final CaptureCallbackHolder holder;
+ int index = mCaptureCallbackMap.indexOfKey(requestId);
+ holder = (index >= 0) ? mCaptureCallbackMap.valueAt(index) : null;
if (holder != null) {
- mCaptureListenerMap.removeAt(index);
+ mCaptureCallbackMap.removeAt(index);
if (DEBUG) {
Log.v(TAG, String.format(
"remove holder for requestId %d, "
@@ -560,7 +560,7 @@
|| lastFrameNumber > Integer.MAX_VALUE) {
throw new AssertionError(lastFrameNumber + " cannot be cast to int");
}
- holder.getListener().onCaptureSequenceAborted(
+ holder.getCallback().onCaptureSequenceAborted(
CameraDeviceImpl.this,
requestId);
}
@@ -569,7 +569,7 @@
holder.getHandler().post(resultDispatch);
} else {
Log.w(TAG, String.format(
- "did not register listener to request %d",
+ "did not register callback to request %d",
requestId));
}
} else {
@@ -579,12 +579,12 @@
}
}
- private int submitCaptureRequest(List<CaptureRequest> requestList, CaptureListener listener,
+ private int submitCaptureRequest(List<CaptureRequest> requestList, CaptureCallback callback,
Handler handler, boolean repeating) throws CameraAccessException {
// Need a valid handler, or current thread needs to have a looper, if
- // listener is valid
- handler = checkHandler(handler, listener);
+ // callback is valid
+ handler = checkHandler(handler, callback);
// Make sure that there all requests have at least 1 surface; all surfaces are non-null
for (CaptureRequest request : requestList) {
@@ -622,8 +622,8 @@
return -1;
}
- if (listener != null) {
- mCaptureListenerMap.put(requestId, new CaptureListenerHolder(listener,
+ if (callback != null) {
+ mCaptureCallbackMap.put(requestId, new CaptureCallbackHolder(callback,
requestList, handler, repeating));
} else {
if (DEBUG) {
@@ -652,19 +652,19 @@
}
}
- public int setRepeatingRequest(CaptureRequest request, CaptureListener listener,
+ public int setRepeatingRequest(CaptureRequest request, CaptureCallback callback,
Handler handler) throws CameraAccessException {
List<CaptureRequest> requestList = new ArrayList<CaptureRequest>();
requestList.add(request);
- return submitCaptureRequest(requestList, listener, handler, /*streaming*/true);
+ return submitCaptureRequest(requestList, callback, handler, /*streaming*/true);
}
- public int setRepeatingBurst(List<CaptureRequest> requests, CaptureListener listener,
+ public int setRepeatingBurst(List<CaptureRequest> requests, CaptureCallback callback,
Handler handler) throws CameraAccessException {
if (requests == null || requests.isEmpty()) {
throw new IllegalArgumentException("At least one request must be given");
}
- return submitCaptureRequest(requests, listener, handler, /*streaming*/true);
+ return submitCaptureRequest(requests, callback, handler, /*streaming*/true);
}
public void stopRepeating() throws CameraAccessException {
@@ -677,7 +677,7 @@
mRepeatingRequestId = REQUEST_ID_NONE;
// Queue for deletion after in-flight requests finish
- if (mCaptureListenerMap.get(requestId) != null) {
+ if (mCaptureCallbackMap.get(requestId) != null) {
mRepeatingRequestIdDeletedList.add(requestId);
}
@@ -782,11 +782,11 @@
}
/**
- * <p>A listener for tracking the progress of a {@link CaptureRequest}
+ * <p>A callback for tracking the progress of a {@link CaptureRequest}
* submitted to the camera device.</p>
*
*/
- public static abstract class CaptureListener {
+ public static abstract class CaptureCallback {
/**
* This constant is used to indicate that no images were captured for
@@ -848,9 +848,9 @@
}
/**
- * This method is called independently of the others in CaptureListener,
+ * This method is called independently of the others in CaptureCallback,
* when a capture sequence finishes and all {@link CaptureResult}
- * or {@link CaptureFailure} for it have been returned via this listener.
+ * or {@link CaptureFailure} for it have been returned via this callback.
*/
public void onCaptureSequenceCompleted(CameraDevice camera,
int sequenceId, long frameNumber) {
@@ -858,9 +858,9 @@
}
/**
- * This method is called independently of the others in CaptureListener,
+ * This method is called independently of the others in CaptureCallback,
* when a capture sequence aborts before any {@link CaptureResult}
- * or {@link CaptureFailure} for it have been returned via this listener.
+ * or {@link CaptureFailure} for it have been returned via this callback.
*/
public void onCaptureSequenceAborted(CameraDevice camera,
int sequenceId) {
@@ -869,10 +869,10 @@
}
/**
- * A listener for notifications about the state of a camera device, adding in the callbacks that
+ * A callback for notifications about the state of a camera device, adding in the callbacks that
* were part of the earlier KK API design, but now only used internally.
*/
- public static abstract class StateListenerKK extends StateListener {
+ public static abstract class StateCallbackKK extends StateCallback {
/**
* The method called when a camera device has no outputs configured.
*
@@ -908,31 +908,31 @@
}
}
- static class CaptureListenerHolder {
+ static class CaptureCallbackHolder {
private final boolean mRepeating;
- private final CaptureListener mListener;
+ private final CaptureCallback mCallback;
private final List<CaptureRequest> mRequestList;
private final Handler mHandler;
- CaptureListenerHolder(CaptureListener listener, List<CaptureRequest> requestList,
+ CaptureCallbackHolder(CaptureCallback callback, List<CaptureRequest> requestList,
Handler handler, boolean repeating) {
- if (listener == null || handler == null) {
+ if (callback == null || handler == null) {
throw new UnsupportedOperationException(
- "Must have a valid handler and a valid listener");
+ "Must have a valid handler and a valid callback");
}
mRepeating = repeating;
mHandler = handler;
mRequestList = new ArrayList<CaptureRequest>(requestList);
- mListener = listener;
+ mCallback = callback;
}
public boolean isRepeating() {
return mRepeating;
}
- public CaptureListener getListener() {
- return mListener;
+ public CaptureCallback getCallback() {
+ return mCallback;
}
public CaptureRequest getRequest(int subsequenceId) {
@@ -1071,20 +1071,20 @@
final SimpleEntry<Long, Integer> frameNumberRequestPair = iter.next();
if (frameNumberRequestPair.getKey() <= completedFrameNumber) {
- // remove request from mCaptureListenerMap
+ // remove request from mCaptureCallbackMap
final int requestId = frameNumberRequestPair.getValue();
- final CaptureListenerHolder holder;
+ final CaptureCallbackHolder holder;
synchronized(mInterfaceLock) {
if (mRemoteDevice == null) {
Log.w(TAG, "Camera closed while checking sequences");
return;
}
- int index = mCaptureListenerMap.indexOfKey(requestId);
- holder = (index >= 0) ? mCaptureListenerMap.valueAt(index)
+ int index = mCaptureCallbackMap.indexOfKey(requestId);
+ holder = (index >= 0) ? mCaptureCallbackMap.valueAt(index)
: null;
if (holder != null) {
- mCaptureListenerMap.removeAt(index);
+ mCaptureCallbackMap.removeAt(index);
if (DEBUG) {
Log.v(TAG, String.format(
"remove holder for requestId %d, "
@@ -1114,7 +1114,7 @@
throw new AssertionError(lastFrameNumber
+ " cannot be cast to int");
}
- holder.getListener().onCaptureSequenceCompleted(
+ holder.getCallback().onCaptureSequenceCompleted(
CameraDeviceImpl.this,
requestId,
lastFrameNumber);
@@ -1146,13 +1146,13 @@
/**
* Camera has encountered a device-level error
- * Matches CameraDevice.StateListener#ERROR_CAMERA_DEVICE
+ * Matches CameraDevice.StateCallback#ERROR_CAMERA_DEVICE
*/
static final int ERROR_CAMERA_DEVICE = 1;
/**
* Camera has encountered a service-level error
- * Matches CameraDevice.StateListener#ERROR_CAMERA_SERVICE
+ * Matches CameraDevice.StateCallback#ERROR_CAMERA_SERVICE
*/
static final int ERROR_CAMERA_SERVICE = 2;
@@ -1204,7 +1204,7 @@
@Override
public void run() {
if (!CameraDeviceImpl.this.isClosed()) {
- mDeviceListener.onError(CameraDeviceImpl.this, errorCode);
+ mDeviceCallback.onError(CameraDeviceImpl.this, errorCode);
}
}
};
@@ -1240,13 +1240,13 @@
if (DEBUG) {
Log.d(TAG, "Capture started for id " + requestId);
}
- final CaptureListenerHolder holder;
+ final CaptureCallbackHolder holder;
synchronized(mInterfaceLock) {
if (mRemoteDevice == null) return; // Camera already closed
- // Get the listener for this frame ID, if there is one
- holder = CameraDeviceImpl.this.mCaptureListenerMap.get(requestId);
+ // Get the callback for this frame ID, if there is one
+ holder = CameraDeviceImpl.this.mCaptureCallbackMap.get(requestId);
if (holder == null) {
return;
@@ -1260,7 +1260,7 @@
@Override
public void run() {
if (!CameraDeviceImpl.this.isClosed()) {
- holder.getListener().onCaptureStarted(
+ holder.getCallback().onCaptureStarted(
CameraDeviceImpl.this,
holder.getRequest(resultExtras.getSubsequenceId()),
timestamp);
@@ -1290,13 +1290,13 @@
result.set(CameraCharacteristics.LENS_INFO_SHADING_MAP_SIZE,
getCharacteristics().get(CameraCharacteristics.LENS_INFO_SHADING_MAP_SIZE));
- final CaptureListenerHolder holder =
- CameraDeviceImpl.this.mCaptureListenerMap.get(requestId);
+ final CaptureCallbackHolder holder =
+ CameraDeviceImpl.this.mCaptureCallbackMap.get(requestId);
boolean isPartialResult =
(resultExtras.getPartialResultCount() < mTotalPartialCount);
- // Check if we have a listener for this
+ // Check if we have a callback for this
if (holder == null) {
if (DEBUG) {
Log.d(TAG,
@@ -1336,7 +1336,7 @@
@Override
public void run() {
if (!CameraDeviceImpl.this.isClosed()){
- holder.getListener().onCaptureProgressed(
+ holder.getCallback().onCaptureProgressed(
CameraDeviceImpl.this,
request,
resultAsCapture);
@@ -1357,7 +1357,7 @@
@Override
public void run() {
if (!CameraDeviceImpl.this.isClosed()){
- holder.getListener().onCaptureCompleted(
+ holder.getCallback().onCaptureCompleted(
CameraDeviceImpl.this,
request,
resultAsCapture);
@@ -1388,8 +1388,8 @@
final int requestId = resultExtras.getRequestId();
final int subsequenceId = resultExtras.getSubsequenceId();
final long frameNumber = resultExtras.getFrameNumber();
- final CaptureListenerHolder holder =
- CameraDeviceImpl.this.mCaptureListenerMap.get(requestId);
+ final CaptureCallbackHolder holder =
+ CameraDeviceImpl.this.mCaptureCallbackMap.get(requestId);
final CaptureRequest request = holder.getRequest(subsequenceId);
@@ -1420,7 +1420,7 @@
@Override
public void run() {
if (!CameraDeviceImpl.this.isClosed()){
- holder.getListener().onCaptureFailed(
+ holder.getCallback().onCaptureFailed(
CameraDeviceImpl.this,
request,
failure);
@@ -1460,12 +1460,12 @@
}
/**
- * Default handler management, conditional on there being a listener.
+ * Default handler management, conditional on there being a callback.
*
- * <p>If the listener isn't null, check the handler, otherwise pass it through.</p>
+ * <p>If the callback isn't null, check the handler, otherwise pass it through.</p>
*/
- static <T> Handler checkHandler(Handler handler, T listener) {
- if (listener != null) {
+ static <T> Handler checkHandler(Handler handler, T callback) {
+ if (callback != null) {
return checkHandler(handler);
}
return handler;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/SecureCameraLaunchManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/SecureCameraLaunchManager.java
index 562f550..3f5cf3f 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/SecureCameraLaunchManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/SecureCameraLaunchManager.java
@@ -85,12 +85,12 @@
private KeyguardBottomAreaView mKeyguardBottomArea;
private CameraManager mCameraManager;
- private CameraAvailabilityListener mCameraAvailabilityListener;
+ private CameraAvailabilityCallback mCameraAvailabilityCallback;
private Map<String, Boolean> mCameraAvailabilityMap;
private boolean mWaitingToLaunchSecureCamera;
private Runnable mLaunchCameraRunnable;
- private class CameraAvailabilityListener extends CameraManager.AvailabilityListener {
+ private class CameraAvailabilityCallback extends CameraManager.AvailabilityCallback {
@Override
public void onCameraUnavailable(String cameraId) {
if (DEBUG) Log.d(TAG, "onCameraUnavailble(" + cameraId + ")");
@@ -123,10 +123,10 @@
mKeyguardBottomArea = keyguardBottomArea;
mCameraManager = (CameraManager) context.getSystemService(Context.CAMERA_SERVICE);
- mCameraAvailabilityListener = new CameraAvailabilityListener();
+ mCameraAvailabilityCallback = new CameraAvailabilityCallback();
// An onCameraAvailable() or onCameraUnavailable() callback will be received for each camera
- // when the availability listener is registered, thus initializing the map.
+ // when the availability callback is registered, thus initializing the map.
//
// Keeping track of the state of all cameras using the onCameraAvailable() and
// onCameraUnavailable() callbacks can get messy when dealing with hot-pluggable cameras.
@@ -150,14 +150,14 @@
* Initializes the SecureCameraManager and starts listening for camera availability.
*/
public void create() {
- mCameraManager.addAvailabilityListener(mCameraAvailabilityListener, mHandler);
+ mCameraManager.registerAvailabilityCallback(mCameraAvailabilityCallback, mHandler);
}
/**
* Stops listening for camera availability and cleans up the SecureCameraManager.
*/
public void destroy() {
- mCameraManager.removeAvailabilityListener(mCameraAvailabilityListener);
+ mCameraManager.unregisterAvailabilityCallback(mCameraAvailabilityCallback);
}
/**
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/FlashlightController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/FlashlightController.java
index 70eaa5c..6f021ac 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/FlashlightController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/FlashlightController.java
@@ -81,7 +81,7 @@
if (mCameraId != null) {
ensureHandler();
- mCameraManager.addAvailabilityListener(mAvailabilityListener, mHandler);
+ mCameraManager.registerAvailabilityCallback(mAvailabilityCallback, mHandler);
}
}
@@ -339,8 +339,8 @@
}
};
- private final CameraManager.AvailabilityListener mAvailabilityListener =
- new CameraManager.AvailabilityListener() {
+ private final CameraManager.AvailabilityCallback mAvailabilityCallback =
+ new CameraManager.AvailabilityCallback() {
@Override
public void onCameraAvailable(String cameraId) {
if (DEBUG) Log.d(TAG, "onCameraAvailable(" + cameraId + ")");
diff --git a/tests/Camera2Tests/CameraToo/src/com/example/android/camera2/cameratoo/CameraTooActivity.java b/tests/Camera2Tests/CameraToo/src/com/example/android/camera2/cameratoo/CameraTooActivity.java
index c630bad..d513f44 100644
--- a/tests/Camera2Tests/CameraToo/src/com/example/android/camera2/cameratoo/CameraTooActivity.java
+++ b/tests/Camera2Tests/CameraToo/src/com/example/android/camera2/cameratoo/CameraTooActivity.java
@@ -290,14 +290,14 @@
// Open the camera device
try {
- mCameraManager.openCamera(mCameraId, mCameraStateListener,
+ mCameraManager.openCamera(mCameraId, mCameraStateCallback,
mBackgroundHandler);
} catch (CameraAccessException ex) {
Log.e(TAG, "Failed to configure output surface", ex);
}
mGotSecondCallback = true;
- // Control flow continues in mCameraStateListener.onOpened()
+ // Control flow continues in mCameraStateCallback.onOpened()
}
}};
@@ -305,8 +305,8 @@
* Calledbacks invoked upon state changes in our {@code CameraDevice}. <p>These are run on
* {@code mBackgroundThread}.</p>
*/
- final CameraDevice.StateListener mCameraStateListener =
- new CameraDevice.StateListener() {
+ final CameraDevice.StateCallback mCameraStateCallback =
+ new CameraDevice.StateCallback() {
@Override
public void onOpened(CameraDevice camera) {
Log.i(TAG, "Successfully opened camera");
@@ -337,8 +337,8 @@
* Callbacks invoked upon state changes in our {@code CameraCaptureSession}. <p>These are run on
* {@code mBackgroundThread}.</p>
*/
- final CameraCaptureSession.StateListener mCaptureSessionListener =
- new CameraCaptureSession.StateListener() {
+ final CameraCaptureSession.StateCallback mCaptureSessionListener =
+ new CameraCaptureSession.StateCallback() {
@Override
public void onConfigured(CameraCaptureSession session) {
Log.i(TAG, "Finished configuring camera outputs");
diff --git a/tests/Camera2Tests/SmartCamera/SimpleCamera/src/androidx/media/filterfw/samples/simplecamera/Camera2Source.java b/tests/Camera2Tests/SmartCamera/SimpleCamera/src/androidx/media/filterfw/samples/simplecamera/Camera2Source.java
index 05057f2..07dfb54 100644
--- a/tests/Camera2Tests/SmartCamera/SimpleCamera/src/androidx/media/filterfw/samples/simplecamera/Camera2Source.java
+++ b/tests/Camera2Tests/SmartCamera/SimpleCamera/src/androidx/media/filterfw/samples/simplecamera/Camera2Source.java
@@ -38,7 +38,7 @@
import android.view.Surface;
import com.android.ex.camera2.blocking.BlockingCameraManager;
import com.android.ex.camera2.blocking.BlockingCameraManager.BlockingOpenException;
-import com.android.ex.camera2.blocking.BlockingSessionListener;
+import com.android.ex.camera2.blocking.BlockingSessionCallback;
import androidx.media.filterfw.Filter;
import androidx.media.filterfw.Frame;
import androidx.media.filterfw.FrameImage2D;
@@ -72,7 +72,7 @@
private static final long SESSION_TIMEOUT_MS = 2000;
- class MyCameraListener extends CameraManager.AvailabilityListener {
+ class MyCameraListener extends CameraManager.AvailabilityCallback {
@Override
public void onCameraAvailable(String cameraId) {
@@ -88,7 +88,7 @@
}
- class MyCaptureListener extends CameraCaptureSession.CaptureListener {
+ class MyCaptureCallback extends CameraCaptureSession.CaptureCallback {
@Override
public void onCaptureCompleted(CameraCaptureSession camera, CaptureRequest request,
@@ -189,7 +189,7 @@
surfaces.add(mSurface);
CaptureRequest.Builder mCaptureRequest = null;
try {
- BlockingSessionListener blkSession = new BlockingSessionListener();
+ BlockingSessionCallback blkSession = new BlockingSessionCallback();
mCamera.createCaptureSession(surfaces, blkSession, mHandler);
mCaptureRequest = mCamera.createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW);
@@ -203,7 +203,7 @@
}
try {
- mCameraSession.setRepeatingRequest(mCaptureRequest.build(), new MyCaptureListener(),
+ mCameraSession.setRepeatingRequest(mCaptureRequest.build(), new MyCaptureCallback(),
mHandler);
} catch (CameraAccessException e) {
e.printStackTrace();