Loading core/java/android/hardware/Camera.java +44 −5 Original line number Original line Diff line number Diff line Loading @@ -169,6 +169,10 @@ public class Camera { private boolean mFaceDetectionRunning = false; private boolean mFaceDetectionRunning = false; private Object mAutoFocusCallbackLock = new Object(); private Object mAutoFocusCallbackLock = new Object(); private static final int NO_ERROR = 0; private static final int EACCESS = -13; private static final int ENODEV = -19; /** /** * Broadcast Action: A new picture is taken by the camera, and the entry of * Broadcast Action: A new picture is taken by the camera, and the entry of * the picture has been added to the media store. * the picture has been added to the media store. Loading Loading @@ -328,6 +332,24 @@ public class Camera { } } Camera(int cameraId) { Camera(int cameraId) { int err = cameraInit(cameraId); if (checkInitErrors(err)) { switch(err) { case EACCESS: throw new RuntimeException("Fail to connect to camera service"); case ENODEV: throw new RuntimeException("Camera initialization failed"); default: // Should never hit this. throw new RuntimeException("Unknown camera error"); } } } /** * @hide */ public int cameraInit(int cameraId) { mShutterCallback = null; mShutterCallback = null; mRawImageCallback = null; mRawImageCallback = null; mJpegCallback = null; mJpegCallback = null; Loading @@ -347,7 +369,21 @@ public class Camera { String packageName = ActivityThread.currentPackageName(); String packageName = ActivityThread.currentPackageName(); native_setup(new WeakReference<Camera>(this), cameraId, packageName); return native_setup(new WeakReference<Camera>(this), cameraId, packageName); } /** * @hide */ public static boolean checkInitErrors(int err) { return err != NO_ERROR; } /** * @hide */ public static Camera openUninitialized() { return new Camera(); } } /** /** Loading @@ -360,7 +396,7 @@ public class Camera { release(); release(); } } private native final void native_setup(Object camera_this, int cameraId, private native final int native_setup(Object camera_this, int cameraId, String packageName); String packageName); private native final void native_release(); private native final void native_release(); Loading Loading @@ -458,13 +494,16 @@ public class Camera { */ */ public final void setPreviewDisplay(SurfaceHolder holder) throws IOException { public final void setPreviewDisplay(SurfaceHolder holder) throws IOException { if (holder != null) { if (holder != null) { setPreviewDisplay(holder.getSurface()); setPreviewSurface(holder.getSurface()); } else { } else { setPreviewDisplay((Surface)null); setPreviewSurface((Surface)null); } } } } private native final void setPreviewDisplay(Surface surface) throws IOException; /** * @hide */ public native final void setPreviewSurface(Surface surface) throws IOException; /** /** * Sets the {@link SurfaceTexture} to be used for live preview. * Sets the {@link SurfaceTexture} to be used for live preview. Loading core/java/android/hardware/camera2/CameraManager.java +18 −5 Original line number Original line Diff line number Diff line Loading @@ -20,6 +20,7 @@ import android.content.Context; import android.hardware.ICameraService; import android.hardware.ICameraService; import android.hardware.ICameraServiceListener; import android.hardware.ICameraServiceListener; import android.hardware.camera2.impl.CameraMetadataNative; import android.hardware.camera2.impl.CameraMetadataNative; import android.hardware.camera2.legacy.CameraDeviceUserShim; import android.hardware.camera2.utils.CameraBinderDecorator; import android.hardware.camera2.utils.CameraBinderDecorator; import android.hardware.camera2.utils.CameraRuntimeException; import android.hardware.camera2.utils.CameraRuntimeException; import android.hardware.camera2.utils.BinderHolder; import android.hardware.camera2.utils.BinderHolder; Loading Loading @@ -194,7 +195,6 @@ public final class CameraManager { // impossible // impossible return null; return null; } } return new CameraCharacteristics(info); return new CameraCharacteristics(info); } } Loading Loading @@ -236,10 +236,23 @@ public final class CameraManager { handler); handler); BinderHolder holder = new BinderHolder(); BinderHolder holder = new BinderHolder(); mCameraService.connectDevice(device.getCallbacks(), Integer.parseInt(cameraId), ICameraDeviceCallbacks callbacks = device.getCallbacks(); mContext.getPackageName(), USE_CALLING_UID, holder); int id = Integer.parseInt(cameraId); try { mCameraService.connectDevice(callbacks, id, mContext.getPackageName(), USE_CALLING_UID, holder); cameraUser = ICameraDeviceUser.Stub.asInterface(holder.getBinder()); cameraUser = ICameraDeviceUser.Stub.asInterface(holder.getBinder()); } catch (CameraRuntimeException e) { if (e.getReason() == CameraAccessException.CAMERA_DEPRECATED_HAL) { // Use legacy camera implementation for HAL1 devices Log.i(TAG, "Using legacy camera HAL."); cameraUser = CameraDeviceUserShim.connectBinderShim(callbacks, id); } else { // Rethrow otherwise throw e; } } // TODO: factor out listener to be non-nested, then move setter to constructor // TODO: factor out listener to be non-nested, then move setter to constructor // For now, calling setRemoteDevice will fire initial // For now, calling setRemoteDevice will fire initial Loading core/java/android/hardware/camera2/CaptureRequest.java +16 −0 Original line number Original line Diff line number Diff line Loading @@ -22,6 +22,8 @@ import android.os.Parcelable; import android.util.Rational; import android.util.Rational; import android.view.Surface; import android.view.Surface; import java.util.Collection; import java.util.Collections; import java.util.HashSet; import java.util.HashSet; import java.util.Objects; import java.util.Objects; Loading Loading @@ -198,6 +200,20 @@ public final class CaptureRequest extends CameraMetadata implements Parcelable { dest.writeParcelableArray(mSurfaceSet.toArray(new Surface[mSurfaceSet.size()]), flags); dest.writeParcelableArray(mSurfaceSet.toArray(new Surface[mSurfaceSet.size()]), flags); } } /** * @hide */ public boolean containsTarget(Surface surface) { return mSurfaceSet.contains(surface); } /** * @hide */ public Collection<Surface> getTargets() { return Collections.unmodifiableCollection(mSurfaceSet); } /** /** * A builder for capture requests. * A builder for capture requests. * * Loading core/java/android/hardware/camera2/ICameraDeviceUser.aidl +23 −1 Original line number Original line Diff line number Diff line Loading @@ -26,7 +26,8 @@ import android.hardware.camera2.utils.LongParcelable; interface ICameraDeviceUser interface ICameraDeviceUser { { /** /** * Keep up-to-date with frameworks/av/include/camera/camera2/ICameraDeviceUser.h * Keep up-to-date with frameworks/av/include/camera/camera2/ICameraDeviceUser.h and * frameworks/base/core/java/android/hardware/camera2/legacy/CameraDeviceUserShim.java */ */ void disconnect(); void disconnect(); Loading @@ -41,6 +42,27 @@ interface ICameraDeviceUser int cancelRequest(int requestId, out LongParcelable lastFrameNumber); int cancelRequest(int requestId, out LongParcelable lastFrameNumber); /** * Begin the device configuration. * * <p> * beginConfigure must be called before any call to deleteStream, createStream, * or endConfigure. It is not valid to call this when the device is not idle. * <p> */ int beginConfigure(); /** * End the device configuration. * * <p> * endConfigure must be called after stream configuration is complete (i.e. after * a call to beginConfigure and subsequent createStream/deleteStream calls). This * must be called before any requests can be submitted. * <p> */ int endConfigure(); int deleteStream(int streamId); int deleteStream(int streamId); // non-negative value is the stream ID. negative value is status_t // non-negative value is the stream ID. negative value is status_t Loading core/java/android/hardware/camera2/impl/CameraDevice.java +2 −2 Original line number Original line Diff line number Diff line Loading @@ -216,7 +216,7 @@ public class CameraDevice implements android.hardware.camera2.CameraDevice { try { try { waitUntilIdle(); waitUntilIdle(); // TODO: mRemoteDevice.beginConfigure mRemoteDevice.beginConfigure(); // Delete all streams first (to free up HW resources) // Delete all streams first (to free up HW resources) for (Integer streamId : deleteList) { for (Integer streamId : deleteList) { mRemoteDevice.deleteStream(streamId); mRemoteDevice.deleteStream(streamId); Loading @@ -231,7 +231,7 @@ public class CameraDevice implements android.hardware.camera2.CameraDevice { mConfiguredOutputs.put(streamId, s); mConfiguredOutputs.put(streamId, s); } } // TODO: mRemoteDevice.endConfigure mRemoteDevice.endConfigure(); } catch (CameraRuntimeException e) { } catch (CameraRuntimeException e) { if (e.getReason() == CAMERA_IN_USE) { if (e.getReason() == CAMERA_IN_USE) { throw new IllegalStateException("The camera is currently busy." + throw new IllegalStateException("The camera is currently busy." + Loading Loading
core/java/android/hardware/Camera.java +44 −5 Original line number Original line Diff line number Diff line Loading @@ -169,6 +169,10 @@ public class Camera { private boolean mFaceDetectionRunning = false; private boolean mFaceDetectionRunning = false; private Object mAutoFocusCallbackLock = new Object(); private Object mAutoFocusCallbackLock = new Object(); private static final int NO_ERROR = 0; private static final int EACCESS = -13; private static final int ENODEV = -19; /** /** * Broadcast Action: A new picture is taken by the camera, and the entry of * Broadcast Action: A new picture is taken by the camera, and the entry of * the picture has been added to the media store. * the picture has been added to the media store. Loading Loading @@ -328,6 +332,24 @@ public class Camera { } } Camera(int cameraId) { Camera(int cameraId) { int err = cameraInit(cameraId); if (checkInitErrors(err)) { switch(err) { case EACCESS: throw new RuntimeException("Fail to connect to camera service"); case ENODEV: throw new RuntimeException("Camera initialization failed"); default: // Should never hit this. throw new RuntimeException("Unknown camera error"); } } } /** * @hide */ public int cameraInit(int cameraId) { mShutterCallback = null; mShutterCallback = null; mRawImageCallback = null; mRawImageCallback = null; mJpegCallback = null; mJpegCallback = null; Loading @@ -347,7 +369,21 @@ public class Camera { String packageName = ActivityThread.currentPackageName(); String packageName = ActivityThread.currentPackageName(); native_setup(new WeakReference<Camera>(this), cameraId, packageName); return native_setup(new WeakReference<Camera>(this), cameraId, packageName); } /** * @hide */ public static boolean checkInitErrors(int err) { return err != NO_ERROR; } /** * @hide */ public static Camera openUninitialized() { return new Camera(); } } /** /** Loading @@ -360,7 +396,7 @@ public class Camera { release(); release(); } } private native final void native_setup(Object camera_this, int cameraId, private native final int native_setup(Object camera_this, int cameraId, String packageName); String packageName); private native final void native_release(); private native final void native_release(); Loading Loading @@ -458,13 +494,16 @@ public class Camera { */ */ public final void setPreviewDisplay(SurfaceHolder holder) throws IOException { public final void setPreviewDisplay(SurfaceHolder holder) throws IOException { if (holder != null) { if (holder != null) { setPreviewDisplay(holder.getSurface()); setPreviewSurface(holder.getSurface()); } else { } else { setPreviewDisplay((Surface)null); setPreviewSurface((Surface)null); } } } } private native final void setPreviewDisplay(Surface surface) throws IOException; /** * @hide */ public native final void setPreviewSurface(Surface surface) throws IOException; /** /** * Sets the {@link SurfaceTexture} to be used for live preview. * Sets the {@link SurfaceTexture} to be used for live preview. Loading
core/java/android/hardware/camera2/CameraManager.java +18 −5 Original line number Original line Diff line number Diff line Loading @@ -20,6 +20,7 @@ import android.content.Context; import android.hardware.ICameraService; import android.hardware.ICameraService; import android.hardware.ICameraServiceListener; import android.hardware.ICameraServiceListener; import android.hardware.camera2.impl.CameraMetadataNative; import android.hardware.camera2.impl.CameraMetadataNative; import android.hardware.camera2.legacy.CameraDeviceUserShim; import android.hardware.camera2.utils.CameraBinderDecorator; import android.hardware.camera2.utils.CameraBinderDecorator; import android.hardware.camera2.utils.CameraRuntimeException; import android.hardware.camera2.utils.CameraRuntimeException; import android.hardware.camera2.utils.BinderHolder; import android.hardware.camera2.utils.BinderHolder; Loading Loading @@ -194,7 +195,6 @@ public final class CameraManager { // impossible // impossible return null; return null; } } return new CameraCharacteristics(info); return new CameraCharacteristics(info); } } Loading Loading @@ -236,10 +236,23 @@ public final class CameraManager { handler); handler); BinderHolder holder = new BinderHolder(); BinderHolder holder = new BinderHolder(); mCameraService.connectDevice(device.getCallbacks(), Integer.parseInt(cameraId), ICameraDeviceCallbacks callbacks = device.getCallbacks(); mContext.getPackageName(), USE_CALLING_UID, holder); int id = Integer.parseInt(cameraId); try { mCameraService.connectDevice(callbacks, id, mContext.getPackageName(), USE_CALLING_UID, holder); cameraUser = ICameraDeviceUser.Stub.asInterface(holder.getBinder()); cameraUser = ICameraDeviceUser.Stub.asInterface(holder.getBinder()); } catch (CameraRuntimeException e) { if (e.getReason() == CameraAccessException.CAMERA_DEPRECATED_HAL) { // Use legacy camera implementation for HAL1 devices Log.i(TAG, "Using legacy camera HAL."); cameraUser = CameraDeviceUserShim.connectBinderShim(callbacks, id); } else { // Rethrow otherwise throw e; } } // TODO: factor out listener to be non-nested, then move setter to constructor // TODO: factor out listener to be non-nested, then move setter to constructor // For now, calling setRemoteDevice will fire initial // For now, calling setRemoteDevice will fire initial Loading
core/java/android/hardware/camera2/CaptureRequest.java +16 −0 Original line number Original line Diff line number Diff line Loading @@ -22,6 +22,8 @@ import android.os.Parcelable; import android.util.Rational; import android.util.Rational; import android.view.Surface; import android.view.Surface; import java.util.Collection; import java.util.Collections; import java.util.HashSet; import java.util.HashSet; import java.util.Objects; import java.util.Objects; Loading Loading @@ -198,6 +200,20 @@ public final class CaptureRequest extends CameraMetadata implements Parcelable { dest.writeParcelableArray(mSurfaceSet.toArray(new Surface[mSurfaceSet.size()]), flags); dest.writeParcelableArray(mSurfaceSet.toArray(new Surface[mSurfaceSet.size()]), flags); } } /** * @hide */ public boolean containsTarget(Surface surface) { return mSurfaceSet.contains(surface); } /** * @hide */ public Collection<Surface> getTargets() { return Collections.unmodifiableCollection(mSurfaceSet); } /** /** * A builder for capture requests. * A builder for capture requests. * * Loading
core/java/android/hardware/camera2/ICameraDeviceUser.aidl +23 −1 Original line number Original line Diff line number Diff line Loading @@ -26,7 +26,8 @@ import android.hardware.camera2.utils.LongParcelable; interface ICameraDeviceUser interface ICameraDeviceUser { { /** /** * Keep up-to-date with frameworks/av/include/camera/camera2/ICameraDeviceUser.h * Keep up-to-date with frameworks/av/include/camera/camera2/ICameraDeviceUser.h and * frameworks/base/core/java/android/hardware/camera2/legacy/CameraDeviceUserShim.java */ */ void disconnect(); void disconnect(); Loading @@ -41,6 +42,27 @@ interface ICameraDeviceUser int cancelRequest(int requestId, out LongParcelable lastFrameNumber); int cancelRequest(int requestId, out LongParcelable lastFrameNumber); /** * Begin the device configuration. * * <p> * beginConfigure must be called before any call to deleteStream, createStream, * or endConfigure. It is not valid to call this when the device is not idle. * <p> */ int beginConfigure(); /** * End the device configuration. * * <p> * endConfigure must be called after stream configuration is complete (i.e. after * a call to beginConfigure and subsequent createStream/deleteStream calls). This * must be called before any requests can be submitted. * <p> */ int endConfigure(); int deleteStream(int streamId); int deleteStream(int streamId); // non-negative value is the stream ID. negative value is status_t // non-negative value is the stream ID. negative value is status_t Loading
core/java/android/hardware/camera2/impl/CameraDevice.java +2 −2 Original line number Original line Diff line number Diff line Loading @@ -216,7 +216,7 @@ public class CameraDevice implements android.hardware.camera2.CameraDevice { try { try { waitUntilIdle(); waitUntilIdle(); // TODO: mRemoteDevice.beginConfigure mRemoteDevice.beginConfigure(); // Delete all streams first (to free up HW resources) // Delete all streams first (to free up HW resources) for (Integer streamId : deleteList) { for (Integer streamId : deleteList) { mRemoteDevice.deleteStream(streamId); mRemoteDevice.deleteStream(streamId); Loading @@ -231,7 +231,7 @@ public class CameraDevice implements android.hardware.camera2.CameraDevice { mConfiguredOutputs.put(streamId, s); mConfiguredOutputs.put(streamId, s); } } // TODO: mRemoteDevice.endConfigure mRemoteDevice.endConfigure(); } catch (CameraRuntimeException e) { } catch (CameraRuntimeException e) { if (e.getReason() == CAMERA_IN_USE) { if (e.getReason() == CAMERA_IN_USE) { throw new IllegalStateException("The camera is currently busy." + throw new IllegalStateException("The camera is currently busy." + Loading