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

Commit 0c5e010e authored by Igor Murashkin's avatar Igor Murashkin Committed by Android (Google) Code Review
Browse files

Merge "Revert "Initial camera device implementation""

parents e981c516 36483e96
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -125,8 +125,6 @@ LOCAL_SRC_FILES += \
	core/java/android/hardware/ICameraClient.aidl \
	core/java/android/hardware/IProCameraUser.aidl \
	core/java/android/hardware/IProCameraCallbacks.aidl \
	core/java/android/hardware/photography/ICameraDeviceUser.aidl \
	core/java/android/hardware/photography/ICameraDeviceCallbacks.aidl \
	core/java/android/hardware/ISerialManager.aidl \
	core/java/android/hardware/display/IDisplayManager.aidl \
	core/java/android/hardware/display/IDisplayManagerCallback.aidl \
+14 −17
Original line number Diff line number Diff line
@@ -10665,18 +10665,18 @@ package android.hardware.photography {
    field public static final int MAX_CAMERAS_IN_USE = 2; // 0x2
  }
  public abstract interface CameraDevice implements java.lang.AutoCloseable {
    method public abstract void capture(android.hardware.photography.CaptureRequest, android.hardware.photography.CameraDevice.CaptureListener) throws android.hardware.photography.CameraAccessException;
    method public abstract void captureBurst(java.util.List<android.hardware.photography.CaptureRequest>, android.hardware.photography.CameraDevice.CaptureListener) throws android.hardware.photography.CameraAccessException;
    method public abstract void close() throws java.lang.Exception;
    method public abstract void configureOutputs(java.util.List<android.view.Surface>) throws android.hardware.photography.CameraAccessException;
    method public abstract android.hardware.photography.CaptureRequest createCaptureRequest(int) throws android.hardware.photography.CameraAccessException;
    method public abstract android.hardware.photography.CameraProperties getProperties() throws android.hardware.photography.CameraAccessException;
    method public abstract void setErrorListener(android.hardware.photography.CameraDevice.ErrorListener);
    method public abstract void setRepeatingBurst(java.util.List<android.hardware.photography.CaptureRequest>, android.hardware.photography.CameraDevice.CaptureListener) throws android.hardware.photography.CameraAccessException;
    method public abstract void setRepeatingRequest(android.hardware.photography.CaptureRequest, android.hardware.photography.CameraDevice.CaptureListener) throws android.hardware.photography.CameraAccessException;
    method public abstract void stopRepeating() throws android.hardware.photography.CameraAccessException;
    method public abstract void waitUntilIdle() throws android.hardware.photography.CameraAccessException;
  public final class CameraDevice implements java.lang.AutoCloseable {
    method public void capture(android.hardware.photography.CaptureRequest, android.hardware.photography.CameraDevice.CaptureListener) throws android.hardware.photography.CameraAccessException;
    method public void captureBurst(java.util.List<android.hardware.photography.CaptureRequest>, android.hardware.photography.CameraDevice.CaptureListener) throws android.hardware.photography.CameraAccessException;
    method public void close();
    method public void configureOutputs(java.util.List<android.view.Surface>);
    method public android.hardware.photography.CaptureRequest createCaptureRequest(int) throws android.hardware.photography.CameraAccessException;
    method public android.hardware.photography.CameraProperties getProperties() throws android.hardware.photography.CameraAccessException;
    method public void setErrorListener(android.hardware.photography.CameraDevice.ErrorListener);
    method public void setRepeatingBurst(java.util.List<android.hardware.photography.CaptureRequest>, android.hardware.photography.CameraDevice.CaptureListener) throws android.hardware.photography.CameraAccessException;
    method public void setRepeatingRequest(android.hardware.photography.CaptureRequest, android.hardware.photography.CameraDevice.CaptureListener) throws android.hardware.photography.CameraAccessException;
    method public void stopRepeating() throws android.hardware.photography.CameraAccessException;
    method public void waitUntilIdle() throws android.hardware.photography.CameraAccessException;
    field public static final int TEMPLATE_MANUAL = 5; // 0x5
    field public static final int TEMPLATE_PREVIEW = 1; // 0x1
    field public static final int TEMPLATE_RECORD = 2; // 0x2
@@ -10709,12 +10709,10 @@ package android.hardware.photography {
    method public abstract void onCameraUnavailable(java.lang.String);
  }
  public class CameraMetadata implements java.lang.AutoCloseable android.os.Parcelable {
  public class CameraMetadata implements android.os.Parcelable {
    ctor public CameraMetadata();
    method public void close() throws java.lang.Exception;
    method public int describeContents();
    method public T get(android.hardware.photography.CameraMetadata.Key<T>);
    method public void readFromParcel(android.os.Parcel);
    method public void set(android.hardware.photography.CameraMetadata.Key<T>, T);
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator CREATOR;
@@ -10743,10 +10741,9 @@ package android.hardware.photography {
    field public static final android.hardware.photography.CameraMetadata.Key SENSOR_PIXEL_ARRAY_SIZE;
  }
  public final class CaptureRequest extends android.hardware.photography.CameraMetadata implements android.os.Parcelable {
  public final class CaptureRequest extends android.hardware.photography.CameraMetadata {
    method public void addTarget(android.view.Surface);
    method public void removeTarget(android.view.Surface);
    field public static final android.os.Parcelable.Creator CREATOR;
    field public static final android.hardware.photography.CameraMetadata.Key SENSOR_EXPOSURE_TIME;
    field public static final android.hardware.photography.CameraMetadata.Key SENSOR_SENSITIVITY;
  }
+0 −6
Original line number Diff line number Diff line
@@ -20,8 +20,6 @@ import android.hardware.ICamera;
import android.hardware.ICameraClient;
import android.hardware.IProCameraUser;
import android.hardware.IProCameraCallbacks;
import android.hardware.photography.ICameraDeviceUser;
import android.hardware.photography.ICameraDeviceCallbacks;
import android.hardware.ICameraServiceListener;
import android.hardware.CameraInfo;

@@ -45,10 +43,6 @@ interface ICameraService
                              String clientPackageName,
                              int clientUid);

    ICameraDeviceUser connectDevice(ICameraDeviceCallbacks callbacks, int cameraId,
                              String clientPackageName,
                              int clientUid);

    int addListener(ICameraServiceListener listener);
    int removeListener(ICameraServiceListener listener);
}
+41 −14
Original line number Diff line number Diff line
@@ -16,6 +16,11 @@

package android.hardware.photography;

import android.graphics.ImageFormat;
import android.os.IBinder;
import android.renderscript.Allocation;
import android.renderscript.RenderScript;
import android.util.Log;
import android.view.Surface;

import java.lang.AutoCloseable;
@@ -44,7 +49,7 @@ import java.util.List;
 * @see CameraManager#openCamera
 * @see android.Manifest.permission#CAMERA
 */
public interface CameraDevice extends AutoCloseable {
public final class CameraDevice implements AutoCloseable {

    /**
     * Create a request suitable for a camera preview window. Specifically, this
@@ -98,6 +103,8 @@ public interface CameraDevice extends AutoCloseable {
     */
    public static final int TEMPLATE_MANUAL = 5;

    private static final String TAG = "CameraDevice";

    /**
     * Get the static properties for this camera. These are identical to the
     * properties returned by {@link CameraManager#getCameraProperties}.
@@ -108,7 +115,10 @@ public interface CameraDevice extends AutoCloseable {
     *
     * @see CameraManager#getCameraProperties
     */
    public CameraProperties getProperties() throws CameraAccessException;
    public CameraProperties getProperties() throws CameraAccessException {
        return null;
    }

    /**
     * <p>Set up a new output set of Surfaces for the camera device.</p>
     *
@@ -190,7 +200,8 @@ public interface CameraDevice extends AutoCloseable {
     * @throws IllegalStateException if the camera device is not idle, or has
     * encountered a fatal error
     */
    public void configureOutputs(List<Surface> outputs) throws CameraAccessException;
    public void configureOutputs(List<Surface> outputs) {
    }

    /**
     * <p>Create a {@link CaptureRequest} initialized with template for a target
@@ -216,7 +227,9 @@ public interface CameraDevice extends AutoCloseable {
     * @see #TEMPLATE_MANUAL
     */
    public CaptureRequest createCaptureRequest(int templateType)
            throws CameraAccessException;
            throws CameraAccessException {
        return null;
    }

    /**
     * <p>Submit a request for an image to be captured by this CameraDevice.</p>
@@ -248,7 +261,8 @@ public interface CameraDevice extends AutoCloseable {
     * @see #setRepeatingBurst
     */
    public void capture(CaptureRequest request, CaptureListener listener)
            throws CameraAccessException;
            throws CameraAccessException {
    }

    /**
     * <p>Submit a list of requests to be captured in sequence as a burst. The
@@ -279,7 +293,8 @@ public interface CameraDevice extends AutoCloseable {
     * @see #setRepeatingBurst
     */
    public void captureBurst(List<CaptureRequest> requests,
            CaptureListener listener) throws CameraAccessException;
            CaptureListener listener) throws CameraAccessException {
    }

    /**
     * <p>Request endlessly repeating capture of images by this
@@ -321,7 +336,8 @@ public interface CameraDevice extends AutoCloseable {
     * @see #setRepeatingBurst
     */
    public void setRepeatingRequest(CaptureRequest request, CaptureListener listener)
            throws CameraAccessException;
            throws CameraAccessException {
    }

    /**
     * <p>Request endlessly repeating capture of a sequence of images by this
@@ -365,7 +381,8 @@ public interface CameraDevice extends AutoCloseable {
     * @see #setRepeatingRequest
     */
    public void setRepeatingBurst(List<CaptureRequest> requests, CaptureListener listener)
            throws CameraAccessException;
            throws CameraAccessException {
    }

    /**
     * <p>Cancel any ongoing repeating capture set by either
@@ -391,7 +408,8 @@ public interface CameraDevice extends AutoCloseable {
     * device has encountered a fatal error, or if there is an active repeating
     * request or burst.
     */
    public void stopRepeating() throws CameraAccessException;
    public void stopRepeating() throws CameraAccessException {
    }

    /**
     * <p>Wait until all the submitted requests have finished processing</p>
@@ -416,7 +434,8 @@ public interface CameraDevice extends AutoCloseable {
     * device has encountered a fatal error, or if there is an active repeating
     * request or burst.
     */
    public void waitUntilIdle() throws CameraAccessException;
    public void waitUntilIdle() throws CameraAccessException {
    }

    /**
     * Set the error listener object to call when an asynchronous error
@@ -428,17 +447,17 @@ public interface CameraDevice extends AutoCloseable {
     * notifications to. Setting this to null will stop notifications about
     * asynchronous errors.
     */
    public void setErrorListener(ErrorListener listener);
    public void setErrorListener(ErrorListener listener) {
    }

    /**
     * Close the connection to this camera device. After this call, all calls to
     * the camera device interface will throw a {@link IllegalStateException},
     * except for calls to close().
     * @throws Exception
     */
    @Override
    public void close() throws Exception;
    // TODO: We should decide on the behavior of in-flight requests should be on close.
    public void close() {
    }

    /**
     * A listener for receiving metadata about completed image captures. The
@@ -537,4 +556,12 @@ public interface CameraDevice extends AutoCloseable {
         */
        public void onCameraDeviceError(CameraDevice camera, int error);
    }

    /**
     * @hide
     */
    public CameraDevice(IBinder binder) {
        Log.e(TAG, "CameraDevice constructor not implemented yet");
    }

}
+6 −27
Original line number Diff line number Diff line
@@ -94,13 +94,7 @@ public final class CameraManager {
     */
    public String[] getDeviceIdList() throws CameraAccessException {
        synchronized (mLock) {
            try {
                return getOrCreateDeviceIdListLocked().toArray(new String[0]);
            } catch(CameraAccessException e) {
                // this should almost never happen, except if mediaserver crashes
                throw new IllegalStateException(
                        "Failed to query camera service for device ID list", e);
            }
            return (String[]) getOrCreateDeviceIdListLocked().toArray();
        }
    }

@@ -185,32 +179,17 @@ public final class CameraManager {
    public CameraDevice openCamera(String cameraId) throws CameraAccessException {

        try {
            IProCameraUser cameraUser;

            synchronized (mLock) {

                ICameraDeviceUser cameraUser;

                android.hardware.photography.impl.CameraDevice device =
                        new android.hardware.photography.impl.CameraDevice(cameraId);

                cameraUser = mCameraService.connectDevice(device.getCallbacks(),
                // TODO: Use ICameraDevice or some such instead of this...
                cameraUser = mCameraService.connectPro(null,
                        Integer.parseInt(cameraId),
                        mContext.getPackageName(), USE_CALLING_UID);

                // TODO: change ICameraService#connectDevice to return status_t
                if (cameraUser == null) {
                    // TEMPORARY CODE.
                    // catch-all exception since we aren't yet getting the actual error code
                    throw new IllegalStateException("Failed to open camera device");
                }

                // TODO: factor out listener to be non-nested, then move setter to constructor
                device.setRemoteDevice(cameraUser);

                return device;

            }

            return new CameraDevice(cameraUser.asBinder());
        } catch (NumberFormatException e) {
            throw new IllegalArgumentException("Expected cameraId to be numeric, but it was: "
                    + cameraId);
@@ -327,7 +306,7 @@ public final class CameraManager {

        @Override
        public void onStatusChanged(int status, int cameraId) throws RemoteException {
            synchronized(CameraManager.this.mLock) {
            synchronized(CameraManager.this) {

                Log.v(TAG,
                        String.format("Camera id %d has status changed to 0x%x", cameraId, status));
Loading