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

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

Merge changes I183dd47d,I29864a5d

* changes:
  Initial camera device implementation
  Partial CameraManager implementation
parents dee987c9 59bc67c7
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -125,6 +125,8 @@ 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 \
+18 −16
Original line number Diff line number Diff line
@@ -10653,7 +10653,7 @@ package android.hardware.location {
package android.hardware.photography {
  public class CameraAccessException extends java.lang.Exception {
  public class CameraAccessException extends android.util.AndroidException {
    ctor public CameraAccessException(int);
    ctor public CameraAccessException(int, java.lang.String);
    ctor public CameraAccessException(int, java.lang.String, java.lang.Throwable);
@@ -10665,19 +10665,18 @@ package android.hardware.photography {
    field public static final int MAX_CAMERAS_IN_USE = 2; // 0x2
  }
  public final class CameraDevice implements java.lang.AutoCloseable {
    ctor public CameraDevice();
    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;
  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;
    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
@@ -10710,10 +10709,12 @@ package android.hardware.photography {
    method public abstract void onCameraUnavailable(java.lang.String);
  }
  public class CameraMetadata implements android.os.Parcelable {
  public class CameraMetadata implements java.lang.AutoCloseable 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;
@@ -10742,9 +10743,10 @@ 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 {
  public final class CaptureRequest extends android.hardware.photography.CameraMetadata implements android.os.Parcelable {
    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;
  }
+3 −3
Original line number Diff line number Diff line
@@ -549,9 +549,9 @@ class ContextImpl extends Context {
                return new AppOpsManager(ctx, service);
            }});

        registerService(CAMERA_SERVICE, new StaticServiceFetcher() {
            public Object createStaticService() {
                return new CameraManager();
        registerService(CAMERA_SERVICE, new ServiceFetcher() {
            public Object createService(ContextImpl ctx) {
                return new CameraManager(ctx);
            }
        });

+6 −0
Original line number Diff line number Diff line
@@ -20,6 +20,8 @@ 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;

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

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

    int addListener(ICameraServiceListener listener);
    int removeListener(ICameraServiceListener listener);
}
+27 −3
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package android.hardware.photography;

import android.util.AndroidException;

/**
 * <p><code>CameraAccessException</code> is thrown if a camera device could not
 * be queried or opened by the {@link CameraManager}, or if the connection to an
@@ -24,7 +26,7 @@ package android.hardware.photography;
 * @see CameraManager
 * @see CameraDevice
 */
public class CameraAccessException extends Exception {
public class CameraAccessException extends AndroidException {
    /**
     * The camera device is in use already
     */
@@ -51,7 +53,10 @@ public class CameraAccessException extends Exception {
     */
    public static final int CAMERA_DISCONNECTED = 4;

    private int mReason;
    // Make the eclipse warning about serializable exceptions go away
    private static final long serialVersionUID = 5630338637471475675L; // randomly generated

    private final int mReason;

    /**
     * The reason for the failure to access the camera.
@@ -66,6 +71,7 @@ public class CameraAccessException extends Exception {
    }

    public CameraAccessException(int problem) {
        super(getDefaultMessage(problem));
        mReason = problem;
    }

@@ -80,7 +86,25 @@ public class CameraAccessException extends Exception {
    }

    public CameraAccessException(int problem, Throwable cause) {
        super(cause);
        super(getDefaultMessage(problem), cause);
        mReason = problem;
    }

    private static String getDefaultMessage(int problem) {
        switch (problem) {
            case CAMERA_IN_USE:
                return "The camera device is in use already";
            case MAX_CAMERAS_IN_USE:
                return "The system-wide limit for number of open cameras has been reached, " +
                       "and more camera devices cannot be opened until previous instances " +
                       "are closed.";
            case CAMERA_DISABLED:
                return "The camera is disabled due to a device policy, and cannot be opened.";
            case CAMERA_DISCONNECTED:
                return "The camera device is removable and has been disconnected from the Android" +
                       " device, or the camera service has shut down the connection due to a " +
                       "higher-priority access request for the camera device.";
        }
        return null;
    }
}
Loading