Camera2: Hide all the deprecated methods and interfaces
Leave them in for now until bundled clients complete updating
Change-Id: Ibd0fc971258ce6b649000c48dd7a6716f1ab91d4
diff --git a/api/current.txt b/api/current.txt
index f9eebfe..8d07c0f 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -12400,17 +12400,10 @@
}
public abstract class CameraDevice implements java.lang.AutoCloseable {
- method public abstract deprecated int capture(android.hardware.camera2.CaptureRequest, android.hardware.camera2.CameraDevice.CaptureListener, android.os.Handler) throws android.hardware.camera2.CameraAccessException;
- method public abstract deprecated int captureBurst(java.util.List<android.hardware.camera2.CaptureRequest>, android.hardware.camera2.CameraDevice.CaptureListener, android.os.Handler) throws android.hardware.camera2.CameraAccessException;
method public abstract void close();
- method public abstract deprecated void configureOutputs(java.util.List<android.view.Surface>) throws android.hardware.camera2.CameraAccessException;
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 deprecated void flush() throws android.hardware.camera2.CameraAccessException;
method public abstract java.lang.String getId();
- method public abstract deprecated int setRepeatingBurst(java.util.List<android.hardware.camera2.CaptureRequest>, android.hardware.camera2.CameraDevice.CaptureListener, android.os.Handler) throws android.hardware.camera2.CameraAccessException;
- method public abstract deprecated int setRepeatingRequest(android.hardware.camera2.CaptureRequest, android.hardware.camera2.CameraDevice.CaptureListener, android.os.Handler) throws android.hardware.camera2.CameraAccessException;
- method public abstract deprecated void stopRepeating() throws android.hardware.camera2.CameraAccessException;
field public static final int TEMPLATE_MANUAL = 6; // 0x6
field public static final int TEMPLATE_PREVIEW = 1; // 0x1
field public static final int TEMPLATE_RECORD = 3; // 0x3
@@ -12419,26 +12412,12 @@
field public static final int TEMPLATE_ZERO_SHUTTER_LAG = 5; // 0x5
}
- public static abstract deprecated class CameraDevice.CaptureListener {
- ctor public CameraDevice.CaptureListener();
- method public void onCaptureCompleted(android.hardware.camera2.CameraDevice, android.hardware.camera2.CaptureRequest, android.hardware.camera2.TotalCaptureResult);
- method public void onCaptureFailed(android.hardware.camera2.CameraDevice, android.hardware.camera2.CaptureRequest, android.hardware.camera2.CaptureFailure);
- method public void onCaptureProgressed(android.hardware.camera2.CameraDevice, android.hardware.camera2.CaptureRequest, android.hardware.camera2.CaptureResult);
- method public void onCaptureSequenceAborted(android.hardware.camera2.CameraDevice, int);
- method public void onCaptureSequenceCompleted(android.hardware.camera2.CameraDevice, int, long);
- method public void onCaptureStarted(android.hardware.camera2.CameraDevice, android.hardware.camera2.CaptureRequest, long);
- }
-
public static abstract class CameraDevice.StateListener {
ctor public CameraDevice.StateListener();
- method public deprecated void onActive(android.hardware.camera2.CameraDevice);
- method public deprecated void onBusy(android.hardware.camera2.CameraDevice);
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);
- method public deprecated void onIdle(android.hardware.camera2.CameraDevice);
method public abstract void onOpened(android.hardware.camera2.CameraDevice);
- method public deprecated void onUnconfigured(android.hardware.camera2.CameraDevice);
field public static final int ERROR_CAMERA_DEVICE = 4; // 0x4
field public static final int ERROR_CAMERA_DISABLED = 3; // 0x3
field public static final int ERROR_CAMERA_IN_USE = 1; // 0x1
diff --git a/core/java/android/hardware/camera2/CameraCaptureSession.java b/core/java/android/hardware/camera2/CameraCaptureSession.java
index d98bdc2..c6f98dc 100644
--- a/core/java/android/hardware/camera2/CameraCaptureSession.java
+++ b/core/java/android/hardware/camera2/CameraCaptureSession.java
@@ -660,8 +660,8 @@
*
* <p>Due to the asynchronous nature of the camera device, not all submitted captures
* are immediately processed. It is possible to clear out the pending requests
- * by a variety of operations such as {@link CameraDevice#stopRepeating} or
- * {@link CameraDevice#flush}. When such an event happens,
+ * by a variety of operations such as {@link CameraCaptureSession#stopRepeating} or
+ * {@link CameraCaptureSession#abortCaptures}. When such an event happens,
* {@link #onCaptureSequenceCompleted} will not be called.</p>
*
* <p>The default implementation does nothing.</p>
diff --git a/core/java/android/hardware/camera2/CameraDevice.java b/core/java/android/hardware/camera2/CameraDevice.java
index 1f89d33..c461511 100644
--- a/core/java/android/hardware/camera2/CameraDevice.java
+++ b/core/java/android/hardware/camera2/CameraDevice.java
@@ -133,6 +133,7 @@
* <p>Set up a new output set of Surfaces for the camera device.</p>
*
* @deprecated Use {@link #createCaptureSession} instead
+ * @hide
*/
@Deprecated
public abstract void configureOutputs(List<Surface> outputs) throws CameraAccessException;
@@ -278,6 +279,7 @@
* <p>Submit a request for an image to be captured by this CameraDevice.</p>
*
* @deprecated Use {@link CameraCaptureSession#capture} instead
+ * @hide
*/
@Deprecated
public abstract int capture(CaptureRequest request, CaptureListener listener, Handler handler)
@@ -287,6 +289,7 @@
* Submit a list of requests to be captured in sequence as a burst.
*
* @deprecated Use {@link CameraCaptureSession#captureBurst} instead
+ * @hide
*/
@Deprecated
public abstract int captureBurst(List<CaptureRequest> requests, CaptureListener listener,
@@ -296,6 +299,7 @@
* Request endlessly repeating capture of images by this CameraDevice.
*
* @deprecated Use {@link CameraCaptureSession#setRepeatingRequest} instead
+ * @hide
*/
@Deprecated
public abstract int setRepeatingRequest(CaptureRequest request, CaptureListener listener,
@@ -306,6 +310,7 @@
* CameraDevice.</p>
*
* @deprecated Use {@link CameraCaptureSession#setRepeatingBurst} instead
+ * @hide
*/
@Deprecated
public abstract int setRepeatingBurst(List<CaptureRequest> requests, CaptureListener listener,
@@ -317,6 +322,7 @@
* {@link #setRepeatingBurst}.
*
* @deprecated Use {@link CameraCaptureSession#stopRepeating} instead
+ * @hide
*/
@Deprecated
public abstract void stopRepeating() throws CameraAccessException;
@@ -326,6 +332,7 @@
* possible.
*
* @deprecated Use {@link CameraCaptureSession#abortCaptures} instead
+ * @hide
*/
@Deprecated
public abstract void flush() throws CameraAccessException;
@@ -353,6 +360,7 @@
* submitted to the camera device.</p>
*
* @deprecated Use {@link CameraCaptureSession.CaptureListener} instead
+ * @hide
*/
@Deprecated
public static abstract class CaptureListener {
@@ -537,6 +545,7 @@
* The method called when a camera device has no outputs configured.
*
* @deprecated Use {@link #onOpened} instead.
+ * @hide
*/
@Deprecated
public void onUnconfigured(CameraDevice camera) {
@@ -548,6 +557,7 @@
* {@link CaptureRequest capture requests}.
*
* @deprecated Use {@link CameraCaptureSession.StateListener#onActive} instead.
+ * @hide
*/
@Deprecated
public void onActive(CameraDevice camera) {
@@ -558,6 +568,7 @@
* The method called when a camera device is busy.
*
* @deprecated Use {@link CameraCaptureSession.StateListener#onConfigured} instead.
+ * @hide
*/
@Deprecated
public void onBusy(CameraDevice camera) {
@@ -584,6 +595,7 @@
* submitted capture requests and has reached an idle state.
*
* @deprecated Use {@link CameraCaptureSession.StateListener#onReady} instead.
+ * @hide
*/
@Deprecated
public void onIdle(CameraDevice camera) {
diff --git a/core/java/android/hardware/camera2/CaptureFailure.java b/core/java/android/hardware/camera2/CaptureFailure.java
index 35f9af1..2c505e5 100644
--- a/core/java/android/hardware/camera2/CaptureFailure.java
+++ b/core/java/android/hardware/camera2/CaptureFailure.java
@@ -36,7 +36,8 @@
public static final int REASON_ERROR = 0;
/**
- * The capture has failed due to a {@link CameraDevice#flush} call from the application.
+ * The capture has failed due to a {@link CameraCaptureSession#abortCaptures} call from the
+ * application.
*
* @see #getReason()
*/
@@ -64,7 +65,7 @@
* Get the request associated with this failed capture.
*
* <p>Whenever a request is unsuccessfully captured, with
- * {@link CameraDevice.CaptureListener#onCaptureFailed},
+ * {@link CameraCaptureSession.CaptureListener#onCaptureFailed},
* the {@code failed capture}'s {@code getRequest()} will return that {@code request}.
* </p>
*
@@ -127,7 +128,7 @@
/**
* The sequence ID for this failed capture that was returned by the
- * {@link CameraDevice#capture} family of functions.
+ * {@link CameraCaptureSession#capture} family of functions.
*
* <p>The sequence ID is a unique monotonically increasing value starting from 0,
* incremented every time a new group of requests is submitted to the CameraDevice.</p>
diff --git a/core/java/android/hardware/camera2/CaptureRequest.java b/core/java/android/hardware/camera2/CaptureRequest.java
index 91ff7fa..27f7e3a 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 CameraDevice.CaptureListener#onCaptureCompleted CaptureListener.onCaptureCompleted}
+ * {@link CameraCaptureSession.CaptureListener#onCaptureCompleted CaptureListener.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 CameraDevice.CaptureListener#onCaptureCompleted CaptureListener.onCaptureCompleted}
+ * {@link CameraCaptureSession.CaptureListener#onCaptureCompleted CaptureListener.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 be2d960..533ef5d 100644
--- a/core/java/android/hardware/camera2/CaptureResult.java
+++ b/core/java/android/hardware/camera2/CaptureResult.java
@@ -255,8 +255,8 @@
* Get the request associated with this result.
*
* <p>Whenever a request has been fully or partially captured, with
- * {@link CameraDevice.CaptureListener#onCaptureCompleted} or
- * {@link CameraDevice.CaptureListener#onCaptureProgressed}, the {@code result}'s
+ * {@link CameraCaptureSession.CaptureListener#onCaptureCompleted} or
+ * {@link CameraCaptureSession.CaptureListener#onCaptureProgressed}, the {@code result}'s
* {@code getRequest()} will return that {@code request}.
* </p>
*
@@ -295,7 +295,7 @@
/**
* The sequence ID for this failure that was returned by the
- * {@link CameraDevice#capture} family of functions.
+ * {@link CameraCaptureSession#capture} family of functions.
*
* <p>The sequence ID is a unique monotonically increasing value starting from 0,
* incremented every time a new group of requests is submitted to the CameraDevice.</p>
diff --git a/core/java/android/hardware/camera2/TotalCaptureResult.java b/core/java/android/hardware/camera2/TotalCaptureResult.java
index 2647959..226f09d 100644
--- a/core/java/android/hardware/camera2/TotalCaptureResult.java
+++ b/core/java/android/hardware/camera2/TotalCaptureResult.java
@@ -73,7 +73,7 @@
*
* <p>The list size will be inclusive between {@code 1} and
* {@link CameraCharacteristics#REQUEST_PARTIAL_RESULT_COUNT}, in ascending order
- * of when {@link CameraDevice.CaptureListener#onCaptureProgressed} was invoked.</p>
+ * of when {@link CameraCaptureSession.CaptureListener#onCaptureProgressed} was invoked.</p>
*
* @return unmodifiable list of partial results
*/
diff --git a/core/java/android/hardware/camera2/impl/CameraDeviceImpl.java b/core/java/android/hardware/camera2/impl/CameraDeviceImpl.java
index 2e59eee..f4901c6 100644
--- a/core/java/android/hardware/camera2/impl/CameraDeviceImpl.java
+++ b/core/java/android/hardware/camera2/impl/CameraDeviceImpl.java
@@ -299,7 +299,6 @@
return mCameraId;
}
- @Override
public void configureOutputs(List<Surface> outputs) throws CameraAccessException {
// Treat a null input the same an empty list
if (outputs == null) {
@@ -435,7 +434,6 @@
}
}
- @Override
public int capture(CaptureRequest request, CaptureListener listener, Handler handler)
throws CameraAccessException {
if (DEBUG) {
@@ -446,7 +444,6 @@
return submitCaptureRequest(requestList, listener, handler, /*streaming*/false);
}
- @Override
public int captureBurst(List<CaptureRequest> requests, CaptureListener listener,
Handler handler) throws CameraAccessException {
if (requests == null || requests.isEmpty()) {
@@ -585,7 +582,6 @@
}
}
- @Override
public int setRepeatingRequest(CaptureRequest request, CaptureListener listener,
Handler handler) throws CameraAccessException {
List<CaptureRequest> requestList = new ArrayList<CaptureRequest>();
@@ -593,7 +589,6 @@
return submitCaptureRequest(requestList, listener, handler, /*streaming*/true);
}
- @Override
public int setRepeatingBurst(List<CaptureRequest> requests, CaptureListener listener,
Handler handler) throws CameraAccessException {
if (requests == null || requests.isEmpty()) {
@@ -602,7 +597,6 @@
return submitCaptureRequest(requests, listener, handler, /*streaming*/true);
}
- @Override
public void stopRepeating() throws CameraAccessException {
try (ScopedLock scopedLock = mCloseLock.acquireExclusiveLock()) {
@@ -655,7 +649,6 @@
}
}
- @Override
public void flush() throws CameraAccessException {
try (ScopedLock scopedLock = mCloseLock.acquireExclusiveLock()) {
checkIfCameraClosedOrInError();
diff --git a/tests/Camera2Tests/SmartCamera/SimpleCamera/Android.mk b/tests/Camera2Tests/SmartCamera/SimpleCamera/Android.mk
index 801c81c..4e3675f 100644
--- a/tests/Camera2Tests/SmartCamera/SimpleCamera/Android.mk
+++ b/tests/Camera2Tests/SmartCamera/SimpleCamera/Android.mk
@@ -23,7 +23,7 @@
LOCAL_PROGUARD_ENABLED := disabled
# comment it out for now since we need use some hidden APIs
-# LOCAL_SDK_VERSION := current
+LOCAL_SDK_VERSION := current
LOCAL_STATIC_JAVA_LIBRARIES := android-ex-camera2
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 6876f5a..05057f2 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
@@ -22,6 +22,7 @@
import android.hardware.camera2.CameraAccessException;
import android.hardware.camera2.CameraCharacteristics;
import android.hardware.camera2.CameraDevice;
+import android.hardware.camera2.CameraCaptureSession;
import android.hardware.camera2.CameraManager;
import android.hardware.camera2.CaptureFailure;
import android.hardware.camera2.CaptureRequest;
@@ -37,6 +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 androidx.media.filterfw.Filter;
import androidx.media.filterfw.Frame;
import androidx.media.filterfw.FrameImage2D;
@@ -56,6 +58,7 @@
private static final String TAG = "Camera2Source";
private CameraManager mCameraManager;
private CameraDevice mCamera;
+ private CameraCaptureSession mCameraSession;
private RenderScript mRS;
private Surface mSurface;
private CameraCharacteristics mProperties;
@@ -67,6 +70,8 @@
private Allocation mAllocationOut;
private Bitmap mBitmap;
+ private static final long SESSION_TIMEOUT_MS = 2000;
+
class MyCameraListener extends CameraManager.AvailabilityListener {
@Override
@@ -83,10 +88,10 @@
}
- class MyCaptureListener extends CameraDevice.CaptureListener {
+ class MyCaptureListener extends CameraCaptureSession.CaptureListener {
@Override
- public void onCaptureCompleted(CameraDevice camera, CaptureRequest request,
+ public void onCaptureCompleted(CameraCaptureSession camera, CaptureRequest request,
TotalCaptureResult result) {
// TODO Auto-generated method stub
Log.v(TAG, "in onCaptureComplete");
@@ -94,7 +99,7 @@
}
@Override
- public void onCaptureFailed(CameraDevice camera, CaptureRequest request,
+ public void onCaptureFailed(CameraCaptureSession camera, CaptureRequest request,
CaptureFailure failure) {
// TODO Auto-generated method stub
Log.v(TAG, "onCaptureFailed is being called");
@@ -184,16 +189,21 @@
surfaces.add(mSurface);
CaptureRequest.Builder mCaptureRequest = null;
try {
- mCamera.configureOutputs(surfaces);
+ BlockingSessionListener blkSession = new BlockingSessionListener();
+
+ mCamera.createCaptureSession(surfaces, blkSession, mHandler);
mCaptureRequest = mCamera.createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW);
mCaptureRequest.addTarget(mSurface);
+
+ mCameraSession = blkSession.waitAndGetSession(SESSION_TIMEOUT_MS);
+
} catch (CameraAccessException e) {
e.printStackTrace();
throw new RuntimeException(e);
}
try {
- mCamera.setRepeatingRequest(mCaptureRequest.build(), new MyCaptureListener(),
+ mCameraSession.setRepeatingRequest(mCaptureRequest.build(), new MyCaptureListener(),
mHandler);
} catch (CameraAccessException e) {
e.printStackTrace();