Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b942b050 authored by Eino-Ville Talvala's avatar Eino-Ville Talvala
Browse files

Deprecate android.hardware.Camera

             __
             ||
             ||
             ||
             ||---____-----+
             ||    \_/     |
             ||   /. .\    |
             ||  ||---||   |
             ||   |___|    |
             ||    | |     |
             ||---____-----+
             ||
             ||
             ||
_____________||_________________

Replaced by android.hardware.camera2

- Also deprecate MediaRecorder#setCamera
- Also deprecate all Camera inner classes
- Update reference documentation in various classes to point to camera2
- Add note to camera API guide that it uses the old API
  (until a new guide is available)
- Remove old hidden raw sensor format; superceded by RAW_SENSOR.

Change-Id: I3d839765fc9b9aae906751ee32d6956ef40451ce
parent bc2b9d30
Loading
Loading
Loading
Loading
+15 −15
Original line number Diff line number Diff line
@@ -11857,7 +11857,7 @@ package android.graphics.pdf {
package android.hardware {
  public class Camera {
  public deprecated class Camera {
    method public final void addCallbackBuffer(byte[]);
    method public final void autoFocus(android.hardware.Camera.AutoFocusCallback);
    method public final void cancelAutoFocus();
@@ -11896,21 +11896,21 @@ package android.hardware {
    field public static final int CAMERA_ERROR_UNKNOWN = 1; // 0x1
  }
  public static class Camera.Area {
  public static deprecated class Camera.Area {
    ctor public Camera.Area(android.graphics.Rect, int);
    field public android.graphics.Rect rect;
    field public int weight;
  }
  public static abstract interface Camera.AutoFocusCallback {
  public static abstract deprecated interface Camera.AutoFocusCallback {
    method public abstract void onAutoFocus(boolean, android.hardware.Camera);
  }
  public static abstract interface Camera.AutoFocusMoveCallback {
  public static abstract deprecated interface Camera.AutoFocusMoveCallback {
    method public abstract void onAutoFocusMoving(boolean, android.hardware.Camera);
  }
  public static class Camera.CameraInfo {
  public static deprecated class Camera.CameraInfo {
    ctor public Camera.CameraInfo();
    field public static final int CAMERA_FACING_BACK = 0; // 0x0
    field public static final int CAMERA_FACING_FRONT = 1; // 0x1
@@ -11919,11 +11919,11 @@ package android.hardware {
    field public int orientation;
  }
  public static abstract interface Camera.ErrorCallback {
  public static abstract deprecated interface Camera.ErrorCallback {
    method public abstract void onError(int, android.hardware.Camera);
  }
  public static class Camera.Face {
  public static deprecated class Camera.Face {
    ctor public Camera.Face();
    field public int id;
    field public android.graphics.Point leftEye;
@@ -11933,15 +11933,15 @@ package android.hardware {
    field public int score;
  }
  public static abstract interface Camera.FaceDetectionListener {
  public static abstract deprecated interface Camera.FaceDetectionListener {
    method public abstract void onFaceDetection(android.hardware.Camera.Face[], android.hardware.Camera);
  }
  public static abstract interface Camera.OnZoomChangeListener {
  public static abstract deprecated interface Camera.OnZoomChangeListener {
    method public abstract void onZoomChange(int, boolean, android.hardware.Camera);
  }
  public class Camera.Parameters {
  public deprecated class Camera.Parameters {
    method public java.lang.String flatten();
    method public java.lang.String get(java.lang.String);
    method public java.lang.String getAntibanding();
@@ -12091,19 +12091,19 @@ package android.hardware {
    field public static final java.lang.String WHITE_BALANCE_WARM_FLUORESCENT = "warm-fluorescent";
  }
  public static abstract interface Camera.PictureCallback {
  public static abstract deprecated interface Camera.PictureCallback {
    method public abstract void onPictureTaken(byte[], android.hardware.Camera);
  }
  public static abstract interface Camera.PreviewCallback {
  public static abstract deprecated interface Camera.PreviewCallback {
    method public abstract void onPreviewFrame(byte[], android.hardware.Camera);
  }
  public static abstract interface Camera.ShutterCallback {
  public static abstract deprecated interface Camera.ShutterCallback {
    method public abstract void onShutter();
  }
  public class Camera.Size {
  public deprecated class Camera.Size {
    ctor public Camera.Size(int, int);
    field public int height;
    field public int width;
@@ -14970,7 +14970,7 @@ package android.media {
    method public void setAudioEncodingBitRate(int);
    method public void setAudioSamplingRate(int);
    method public void setAudioSource(int) throws java.lang.IllegalStateException;
    method public void setCamera(android.hardware.Camera);
    method public deprecated void setCamera(android.hardware.Camera);
    method public void setCaptureRate(double);
    method public void setLocation(float, float);
    method public void setMaxDuration(int) throws java.lang.IllegalArgumentException;
+52 −1
Original line number Diff line number Diff line
@@ -133,7 +133,11 @@ import java.util.List;
 * <p>For more information about using cameras, read the
 * <a href="{@docRoot}guide/topics/media/camera.html">Camera</a> developer guide.</p>
 * </div>
 *
 * @deprecated We recommend using the new {@link android.hardware.camera2} API for new
 *             applications.
 */
@Deprecated
public class Camera {
    private static final String TAG = "Camera";

@@ -247,7 +251,11 @@ public class Camera {

    /**
     * Information about a camera
     *
     * @deprecated We recommend using the new {@link android.hardware.camera2} API for new
     *             applications.
     */
    @Deprecated
    public static class CameraInfo {
        /**
         * The facing of the camera is opposite to that of the screen.
@@ -675,7 +683,11 @@ public class Camera {
     * @see #setOneShotPreviewCallback(Camera.PreviewCallback)
     * @see #setPreviewCallbackWithBuffer(Camera.PreviewCallback)
     * @see #startPreview()
     *
     * @deprecated We recommend using the new {@link android.hardware.camera2} API for new
     *             applications.
     */
    @Deprecated
    public interface PreviewCallback
    {
        /**
@@ -1175,7 +1187,10 @@ public class Camera {
     * manifest element.</p>
     *
     * @see #autoFocus(AutoFocusCallback)
     * @deprecated We recommend using the new {@link android.hardware.camera2} API for new
     *             applications.
     */
    @Deprecated
    public interface AutoFocusCallback
    {
        /**
@@ -1286,7 +1301,11 @@ public class Camera {
     * Parameters#FOCUS_MODE_CONTINUOUS_VIDEO} and {@link
     * Parameters#FOCUS_MODE_CONTINUOUS_PICTURE}. Applications can show
     * autofocus animation based on this.</p>
     *
     * @deprecated We recommend using the new {@link android.hardware.camera2} API for new
     *             applications.
     */
    @Deprecated
    public interface AutoFocusMoveCallback
    {
        /**
@@ -1314,7 +1333,11 @@ public class Camera {
     * Callback interface used to signal the moment of actual image capture.
     *
     * @see #takePicture(ShutterCallback, PictureCallback, PictureCallback, PictureCallback)
     *
     * @deprecated We recommend using the new {@link android.hardware.camera2} API for new
     *             applications.
     */
    @Deprecated
    public interface ShutterCallback
    {
        /**
@@ -1331,7 +1354,11 @@ public class Camera {
     * Callback interface used to supply image data from a photo capture.
     *
     * @see #takePicture(ShutterCallback, PictureCallback, PictureCallback, PictureCallback)
     *
     * @deprecated We recommend using the new {@link android.hardware.camera2} API for new
     *             applications.
     */
    @Deprecated
    public interface PictureCallback {
        /**
         * Called when image data is available after a picture is taken.
@@ -1538,7 +1565,11 @@ public class Camera {
     *
     * @see #setZoomChangeListener(OnZoomChangeListener)
     * @see #startSmoothZoom(int)
     *
     * @deprecated We recommend using the new {@link android.hardware.camera2} API for new
     *             applications.
     */
    @Deprecated
    public interface OnZoomChangeListener
    {
        /**
@@ -1568,7 +1599,10 @@ public class Camera {
    /**
     * Callback interface for face detected in the preview frame.
     *
     * @deprecated We recommend using the new {@link android.hardware.camera2} API for new
     *             applications.
     */
    @Deprecated
    public interface FaceDetectionListener
    {
        /**
@@ -1652,7 +1686,10 @@ public class Camera {
     * list of face objects for use in focusing and metering.</p>
     *
     * @see FaceDetectionListener
     * @deprecated We recommend using the new {@link android.hardware.camera2} API for new
     *             applications.
     */
    @Deprecated
    public static class Face {
        /**
         * Create an empty face.
@@ -1766,7 +1803,11 @@ public class Camera {
     * Callback interface for camera error notification.
     *
     * @see #setErrorCallback(ErrorCallback)
     *
     * @deprecated We recommend using the new {@link android.hardware.camera2} API for new
     *             applications.
     */
    @Deprecated
    public interface ErrorCallback
    {
        /**
@@ -1864,7 +1905,10 @@ public class Camera {

    /**
     * Image size (width and height dimensions).
     * @deprecated We recommend using the new {@link android.hardware.camera2} API for new
     *             applications.
     */
    @Deprecated
    public class Size {
        /**
         * Sets the dimensions for pictures.
@@ -1931,7 +1975,11 @@ public class Camera {
     * @see Parameters#setMeteringAreas(List)
     * @see Parameters#getMeteringAreas()
     * @see Parameters#getMaxNumMeteringAreas()
     *
     * @deprecated We recommend using the new {@link android.hardware.camera2} API for new
     *             applications.
     */
    @Deprecated
    public static class Area {
        /**
         * Create an area with specified rectangle and weight.
@@ -2005,7 +2053,11 @@ public class Camera {
     * calling {@link Camera.Parameters#setColorEffect(String)}. If the
     * camera does not support color effects,
     * {@link Camera.Parameters#getSupportedColorEffects()} will return null.
     *
     * @deprecated We recommend using the new {@link android.hardware.camera2} API for new
     *             applications.
     */
    @Deprecated
    public class Parameters {
        // Parameter keys to communicate with the camera driver.
        private static final String KEY_PREVIEW_SIZE = "preview-size";
@@ -2960,7 +3012,6 @@ public class Camera {
            case ImageFormat.YV12:      return PIXEL_FORMAT_YUV420P;
            case ImageFormat.RGB_565:   return PIXEL_FORMAT_RGB565;
            case ImageFormat.JPEG:      return PIXEL_FORMAT_JPEG;
            case ImageFormat.BAYER_RGGB: return PIXEL_FORMAT_BAYER_RGGB;
            default:                    return null;
            }
        }
+6 −6
Original line number Diff line number Diff line
@@ -58,16 +58,16 @@ from a variety of classes, including {@link android.view.SurfaceView},
<p>Generally, camera preview images are sent to {@link
android.view.SurfaceView} or {@link android.view.TextureView} (via its
{@link android.graphics.SurfaceTexture}). Capture of JPEG images or
RAW buffers for {@link android.hardware.camera2.DngCreator} can be done
with {@link android.media.ImageReader} with the
{android.graphics.ImageFormat#JPEG} and
{android.graphics.ImageFormat#RAW_SENSOR} formats.  Application-driven
RAW buffers for {@link android.hardware.camera2.DngCreator} can be
done with {@link android.media.ImageReader} with the {@link
android.graphics.ImageFormat#JPEG} and {@link
android.graphics.ImageFormat#RAW_SENSOR} formats.  Application-driven
processing of camera data in RenderScript, OpenGL ES, or directly in
managed or native code is best done through {@link
android.renderscript.Allocation} with a YUV {@link
android.renderscript.Type}, {@link android.graphics.SurfaceTexture},
and {@link android.media.ImageReader} with a
{android.graphics.ImageFormat#YUV_420_888} format, respectively.</p>
and {@link android.media.ImageReader} with a {@link
android.graphics.ImageFormat#YUV_420_888} format, respectively.</p>

<p>The application then needs to construct a {@link
android.hardware.camera2.CaptureRequest}, which defines all the
+10 −3
Original line number Diff line number Diff line
@@ -86,14 +86,17 @@ see how to implement these options.</li>

<h2 id="basics">The Basics</h2>
<p>The Android framework supports capturing images and video through the
{@link android.hardware.Camera} API or camera {@link android.content.Intent}. Here are the relevant
{@link android.hardware.camera2} API or camera {@link android.content.Intent}. Here are the relevant
classes:</p>

<dl>
  <dt>{@link android.hardware.Camera}</dt>
  <dd>This class is the primary API for controlling device cameras. This class is used to take
  <dt>{@link android.hardware.camera2}</dt>
  <dd>This package is the primary API for controlling device cameras. It can be used to take
pictures or videos when you are building a camera application.</dd>

  <dt>{@link android.hardware.Camera}</dt>
  <dd>This class is the older deprecated API for controlling device cameras.</dd>

  <dt>{@link android.view.SurfaceView}</dt>
  <dd>This class is used to present a live camera preview to the user.</dd>

@@ -354,6 +357,10 @@ application or provides special features. Creating a customized camera activity
code than <a href="#intents">using an intent</a>, but it can provide a more compelling experience
for your users.</p>

<p><strong> Note: The following guide is for the older, deprecated {@link android.hardware.Camera}
API. For new or advanced camera applications, the newer {@link android.hardware.camera2} API is
recommended.</strong></p>

<p>The general steps for creating a custom camera interface for your application are as follows:</p>

<ul>
+34 −25
Original line number Diff line number Diff line
@@ -54,9 +54,12 @@ public class ImageFormat {
     * cr_offset = y_size
     * cb_offset = y_size + c_size</pre>
     *
     * <p>This format is guaranteed to be supported for camera preview images since
     * API level 12; for earlier API versions, check
     * {@link android.hardware.Camera.Parameters#getSupportedPreviewFormats()}.
     * <p>For the {@link android.hardware.camera2} API, the {@link #YUV_420_888} format is
     * recommended for YUV output instead.</p>
     *
     * <p>For the older camera API, this format is guaranteed to be supported for
     * {@link android.hardware.Camera} preview images since API level 12; for earlier API versions,
     * check {@link android.hardware.Camera.Parameters#getSupportedPreviewFormats()}.
     *
     * <p>Note that for camera preview callback use (see
     * {@link android.hardware.Camera#setPreviewCallback}), the
@@ -133,29 +136,47 @@ public class ImageFormat {
    public static final int Y16 = 0x20363159;

    /**
     * YCbCr format, used for video. Whether this format is supported by the
     * camera hardware can be determined by
     * {@link android.hardware.Camera.Parameters#getSupportedPreviewFormats()}.
     * YCbCr format, used for video.
     *
     * <p>For the {@link android.hardware.camera2} API, the {@link #YUV_420_888} format is
     * recommended for YUV output instead.</p>
     *
     * <p>Whether this format is supported by the old camera API can be determined by
     * {@link android.hardware.Camera.Parameters#getSupportedPreviewFormats()}.</p>
     *
     */
    public static final int NV16 = 0x10;

    /**
     * YCrCb format used for images, which uses the NV21 encoding format. This
     * is the default format for camera preview images, when not otherwise set
     * with {@link android.hardware.Camera.Parameters#setPreviewFormat(int)}.
     * YCrCb format used for images, which uses the NV21 encoding format.
     *
     * <p>This is the default format
     * for {@link android.hardware.Camera} preview images, when not otherwise set with
     * {@link android.hardware.Camera.Parameters#setPreviewFormat(int)}.</p>
     *
     * <p>For the {@link android.hardware.camera2} API, the {@link #YUV_420_888} format is
     * recommended for YUV output instead.</p>
     */
    public static final int NV21 = 0x11;

    /**
     * YCbCr format used for images, which uses YUYV (YUY2) encoding format.
     * This is an alternative format for camera preview images. Whether this
     * format is supported by the camera hardware can be determined by
     * {@link android.hardware.Camera.Parameters#getSupportedPreviewFormats()}.
     *
     * <p>For the {@link android.hardware.camera2} API, the {@link #YUV_420_888} format is
     * recommended for YUV output instead.</p>
     *
     * <p>This is an alternative format for {@link android.hardware.Camera} preview images. Whether
     * this format is supported by the camera hardware can be determined by
     * {@link android.hardware.Camera.Parameters#getSupportedPreviewFormats()}.</p>
     */
    public static final int YUY2 = 0x14;

    /**
     * Encoded formats. These are not necessarily supported by the hardware.
     * Compressed JPEG format.
     *
     * <p>This format is always supported as an output format for the
     * {@link android.hardware.camera2} API, and as a picture format for the older
     * {@link android.hardware.Camera} API</p>
     */
    public static final int JPEG = 0x100;

@@ -331,16 +352,6 @@ public class ImageFormat {
     */
    public static final int RAW10 = 0x25;

    /**
     * Raw bayer format used for images, which is 10 bit precision samples
     * stored in 16 bit words. The filter pattern is RGGB. Whether this format
     * is supported by the camera hardware can be determined by
     * {@link android.hardware.Camera.Parameters#getSupportedPreviewFormats()}.
     *
     * @hide
     */
    public static final int BAYER_RGGB = 0x200;

    /**
     * Use this function to retrieve the number of bits per pixel of an
     * ImageFormat.
@@ -369,8 +380,6 @@ public class ImageFormat {
                return 12;
            case RAW_SENSOR:
                return 16;
            case BAYER_RGGB:
                return 16;
            case RAW10:
                return 10;
        }
Loading