summaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
authorSol Boucher <solb@google.com>2014-06-17 14:05:08 -0700
committerSol Boucher <solb@google.com>2014-06-18 11:31:53 -0700
commit5a344964cb003525727c31d295ca3a592c245606 (patch)
tree74cb5248f99ae56cfce68a39eca734973d74f56a /src/com
parent1ec930eb7cc0ef2b02e997833b712bd8b768bdf9 (diff)
downloadandroid_packages_apps_Camera2-5a344964cb003525727c31d295ca3a592c245606.tar.gz
android_packages_apps_Camera2-5a344964cb003525727c31d295ca3a592c245606.tar.bz2
android_packages_apps_Camera2-5a344964cb003525727c31d295ca3a592c245606.zip
Remove cameradevice subpackage and point references at ex library
This code is being relocated into frameworks/ex for availability to other apps. Change-Id: Icada261ac7a795b08dd8b187dfd17077077b37c3
Diffstat (limited to 'src/com')
-rw-r--r--src/com/android/camera/CameraActivity.java28
-rw-r--r--src/com/android/camera/CameraErrorCallback.java6
-rw-r--r--src/com/android/camera/CameraModule.java2
-rw-r--r--src/com/android/camera/CameraTestDevice.java2
-rw-r--r--src/com/android/camera/FocusOverlayManager.java4
-rw-r--r--src/com/android/camera/PhotoModule.java18
-rw-r--r--src/com/android/camera/PhotoUI.java10
-rw-r--r--src/com/android/camera/VideoModule.java20
-rw-r--r--src/com/android/camera/VideoUI.java4
-rw-r--r--src/com/android/camera/app/CameraController.java42
-rw-r--r--src/com/android/camera/app/CameraProvider.java2
-rw-r--r--src/com/android/camera/cameradevice/AndroidCameraCapabilities.java488
-rw-r--r--src/com/android/camera/cameradevice/AndroidCameraManagerImpl.java1354
-rw-r--r--src/com/android/camera/cameradevice/AndroidCameraSettings.java47
-rw-r--r--src/com/android/camera/cameradevice/CameraActions.java55
-rw-r--r--src/com/android/camera/cameradevice/CameraCapabilities.java681
-rw-r--r--src/com/android/camera/cameradevice/CameraCapabilitiesFactory.java34
-rw-r--r--src/com/android/camera/cameradevice/CameraDeviceInfo.java35
-rw-r--r--src/com/android/camera/cameradevice/CameraManager.java581
-rw-r--r--src/com/android/camera/cameradevice/CameraManagerFactory.java52
-rw-r--r--src/com/android/camera/cameradevice/CameraSettings.java377
-rw-r--r--src/com/android/camera/cameradevice/CameraStateHolder.java123
-rw-r--r--src/com/android/camera/cameradevice/DispatchThread.java155
-rw-r--r--src/com/android/camera/cameradevice/HistoryHandler.java58
-rw-r--r--src/com/android/camera/cameradevice/Size.java151
-rw-r--r--src/com/android/camera/debug/DebugCameraProxy.java38
-rw-r--r--src/com/android/camera/hardware/HardwareSpecImpl.java4
-rw-r--r--src/com/android/camera/module/ModuleController.java4
-rw-r--r--src/com/android/camera/settings/CameraPictureSizesCacher.java2
-rw-r--r--src/com/android/camera/settings/CameraSettingsActivity.java2
-rw-r--r--src/com/android/camera/settings/ResolutionUtil.java2
-rw-r--r--src/com/android/camera/settings/SettingsManager.java2
-rw-r--r--src/com/android/camera/settings/SettingsUtil.java8
-rw-r--r--src/com/android/camera/util/CameraUtil.java6
34 files changed, 103 insertions, 4294 deletions
diff --git a/src/com/android/camera/CameraActivity.java b/src/com/android/camera/CameraActivity.java
index 37fb2638d..2576571b8 100644
--- a/src/com/android/camera/CameraActivity.java
+++ b/src/com/android/camera/CameraActivity.java
@@ -81,9 +81,6 @@ import com.android.camera.app.ModuleManagerImpl;
import com.android.camera.app.MotionManager;
import com.android.camera.app.OrientationManager;
import com.android.camera.app.OrientationManagerImpl;
-import com.android.camera.cameradevice.CameraManager;
-import com.android.camera.cameradevice.CameraManagerFactory;
-import com.android.camera.cameradevice.CameraSettings;
import com.android.camera.data.CameraDataAdapter;
import com.android.camera.data.FixedLastDataAdapter;
import com.android.camera.data.LocalData;
@@ -132,6 +129,9 @@ import com.android.camera.util.UsageStatistics;
import com.android.camera.widget.FilmstripView;
import com.android.camera.widget.Preloader;
import com.android.camera2.R;
+import com.android.ex.camera2.portability.CameraAgent;
+import com.android.ex.camera2.portability.CameraAgentFactory;
+import com.android.ex.camera2.portability.CameraSettings;
import com.bumptech.glide.Glide;
import com.bumptech.glide.resize.ImageManager;
import com.google.common.logging.eventprotos;
@@ -149,7 +149,7 @@ import java.util.List;
import java.util.concurrent.Executors;
public class CameraActivity extends Activity
- implements AppController, CameraManager.CameraOpenCallback,
+ implements AppController, CameraAgent.CameraOpenCallback,
ActionBar.OnMenuVisibilityListener, ShareActionProvider.OnShareTargetSelectedListener,
OrientationManager.OnOrientationChangeListener {
@@ -446,7 +446,7 @@ public class CameraActivity extends Activity
};
@Override
- public void onCameraOpened(CameraManager.CameraProxy camera) {
+ public void onCameraOpened(CameraAgent.CameraProxy camera) {
if (mPaused) {
return;
}
@@ -484,7 +484,7 @@ public class CameraActivity extends Activity
mCameraAppUI.onChangeCamera();
}
- private void resetExposureCompensationToDefault(CameraManager.CameraProxy camera) {
+ private void resetExposureCompensationToDefault(CameraAgent.CameraProxy camera) {
// Reset the exposure compensation before handing the camera to module.
CameraSettings cameraSettings = camera.getSettings();
cameraSettings.setExposureCompensationIndex(0);
@@ -514,7 +514,7 @@ public class CameraActivity extends Activity
}
@Override
- public void onReconnectionFailure(CameraManager mgr, String info) {
+ public void onReconnectionFailure(CameraAgent mgr, String info) {
UsageStatistics.instance().cameraFailure(
eventprotos.CameraFailure.FailureReason.RECONNECT_FAILURE, null);
Log.w(TAG, "Camera reconnection failure:" + info);
@@ -962,9 +962,9 @@ public class CameraActivity extends Activity
@Override
public void setupOneShotPreviewListener() {
mCameraController.setOneShotPreviewCallback(mMainHandler,
- new CameraManager.CameraPreviewDataCallback() {
+ new CameraAgent.CameraPreviewDataCallback() {
@Override
- public void onPreviewFrame(byte[] data, CameraManager.CameraProxy camera) {
+ public void onPreviewFrame(byte[] data, CameraAgent.CameraProxy camera) {
mCurrentModule.onPreviewInitialDataReceived();
mCameraAppUI.onNewPreviewFrame();
}
@@ -1200,8 +1200,8 @@ public class CameraActivity extends Activity
}
}
- private final CameraManager.CameraExceptionCallback mCameraDefaultExceptionCallback
- = new CameraManager.CameraExceptionCallback() {
+ private final CameraAgent.CameraExceptionCallback mCameraDefaultExceptionCallback
+ = new CameraAgent.CameraExceptionCallback() {
@Override
public void onCameraException(RuntimeException e) {
Log.e(TAG, "Camera Exception", e);
@@ -1234,7 +1234,7 @@ public class CameraActivity extends Activity
mMainHandler = new MainHandler(this, getMainLooper());
mCameraController =
new CameraController(mAppContext, this, mMainHandler,
- CameraManagerFactory.getAndroidCameraManager());
+ CameraAgentFactory.getAndroidCameraAgent());
mCameraController.setCameraDefaultExceptionCallback(mCameraDefaultExceptionCallback,
mMainHandler);
@@ -1742,7 +1742,7 @@ public class CameraActivity extends Activity
mCameraAppUI = null;
mOrientationManager = null;
mButtonManager = null;
- CameraManagerFactory.recycle();
+ CameraAgentFactory.recycle();
super.onDestroy();
}
@@ -2312,7 +2312,7 @@ public class CameraActivity extends Activity
((VideoModule) mCurrentModule).isRecording() : false;
}
- public CameraManager.CameraOpenCallback getCameraOpenErrorCallback() {
+ public CameraAgent.CameraOpenCallback getCameraOpenErrorCallback() {
return mCameraController;
}
diff --git a/src/com/android/camera/CameraErrorCallback.java b/src/com/android/camera/CameraErrorCallback.java
index 187a3519e..5f69332c4 100644
--- a/src/com/android/camera/CameraErrorCallback.java
+++ b/src/com/android/camera/CameraErrorCallback.java
@@ -16,15 +16,15 @@
package com.android.camera;
-import com.android.camera.cameradevice.CameraManager;
import com.android.camera.debug.Log;
+import com.android.ex.camera2.portability.CameraAgent;
public class CameraErrorCallback
- implements CameraManager.CameraErrorCallback {
+ implements CameraAgent.CameraErrorCallback {
private static final Log.Tag TAG = new Log.Tag("CamErrCallback");
@Override
- public void onError(int error, CameraManager.CameraProxy camera) {
+ public void onError(int error, CameraAgent.CameraProxy camera) {
Log.e(TAG, "Got camera error callback. error=" + error);
if (error == android.hardware.Camera.CAMERA_ERROR_SERVER_DIED) {
// We are not sure about the current state of the app (in preview or
diff --git a/src/com/android/camera/CameraModule.java b/src/com/android/camera/CameraModule.java
index 25a911da9..5049cab51 100644
--- a/src/com/android/camera/CameraModule.java
+++ b/src/com/android/camera/CameraModule.java
@@ -72,7 +72,7 @@ public abstract class CameraModule implements ModuleController {
* This calls {@link
* com.android.camera.app.CameraProvider#requestCamera(int)}. The camera
* will be returned through {@link
- * #onCameraAvailable(com.android.camera.cameradevice.CameraManager.CameraProxy)}
+ * #onCameraAvailable(com.android.ex.camera2.portability.CameraAgent.CameraProxy)}
* when it's available. This is a no-op when there's no back camera
* available.
*/
diff --git a/src/com/android/camera/CameraTestDevice.java b/src/com/android/camera/CameraTestDevice.java
index ab9a114b9..efd83ad0b 100644
--- a/src/com/android/camera/CameraTestDevice.java
+++ b/src/com/android/camera/CameraTestDevice.java
@@ -18,7 +18,7 @@ package com.android.camera;
import android.hardware.Camera.CameraInfo;
-import com.android.camera.cameradevice.CameraManager.CameraProxy;
+import com.android.ex.camera2.portability.CameraAgent.CameraProxy;
/**
* The class is kept to make sure the tests can build.
diff --git a/src/com/android/camera/FocusOverlayManager.java b/src/com/android/camera/FocusOverlayManager.java
index 53d4d3389..db9072b8f 100644
--- a/src/com/android/camera/FocusOverlayManager.java
+++ b/src/com/android/camera/FocusOverlayManager.java
@@ -27,14 +27,14 @@ import android.os.Handler;
import android.os.Looper;
import android.os.Message;
-import com.android.camera.cameradevice.CameraCapabilities;
-import com.android.camera.cameradevice.CameraCapabilitiesFactory;
import com.android.camera.app.MotionManager;
import com.android.camera.debug.Log;
import com.android.camera.settings.SettingsManager;
import com.android.camera.ui.PreviewStatusListener;
import com.android.camera.util.CameraUtil;
import com.android.camera.util.UsageStatistics;
+import com.android.ex.camera2.portability.CameraCapabilities;
+import com.android.ex.camera2.portability.CameraCapabilitiesFactory;
import java.util.ArrayList;
import java.util.List;
diff --git a/src/com/android/camera/PhotoModule.java b/src/com/android/camera/PhotoModule.java
index a35a1ddb4..70346936e 100644
--- a/src/com/android/camera/PhotoModule.java
+++ b/src/com/android/camera/PhotoModule.java
@@ -57,15 +57,6 @@ import com.android.camera.app.MediaSaver;
import com.android.camera.app.MemoryManager;
import com.android.camera.app.MemoryManager.MemoryListener;
import com.android.camera.app.MotionManager;
-import com.android.camera.cameradevice.CameraCapabilities;
-import com.android.camera.cameradevice.CameraManager;
-import com.android.camera.cameradevice.CameraManager.CameraAFCallback;
-import com.android.camera.cameradevice.CameraManager.CameraAFMoveCallback;
-import com.android.camera.cameradevice.CameraManager.CameraPictureCallback;
-import com.android.camera.cameradevice.CameraManager.CameraProxy;
-import com.android.camera.cameradevice.CameraManager.CameraShutterCallback;
-import com.android.camera.cameradevice.CameraSettings;
-import com.android.camera.cameradevice.Size;
import com.android.camera.debug.Log;
import com.android.camera.exif.ExifInterface;
import com.android.camera.exif.ExifTag;
@@ -86,6 +77,15 @@ import com.android.camera.util.SessionStatsCollector;
import com.android.camera.util.UsageStatistics;
import com.android.camera.widget.AspectRatioSelector;
import com.android.camera2.R;
+import com.android.ex.camera2.portability.CameraCapabilities;
+import com.android.ex.camera2.portability.CameraAgent;
+import com.android.ex.camera2.portability.CameraAgent.CameraAFCallback;
+import com.android.ex.camera2.portability.CameraAgent.CameraAFMoveCallback;
+import com.android.ex.camera2.portability.CameraAgent.CameraPictureCallback;
+import com.android.ex.camera2.portability.CameraAgent.CameraProxy;
+import com.android.ex.camera2.portability.CameraAgent.CameraShutterCallback;
+import com.android.ex.camera2.portability.CameraSettings;
+import com.android.ex.camera2.portability.Size;
import com.google.common.logging.eventprotos;
import java.io.ByteArrayOutputStream;
diff --git a/src/com/android/camera/PhotoUI.java b/src/com/android/camera/PhotoUI.java
index 4b087d5d6..08f7536b2 100644
--- a/src/com/android/camera/PhotoUI.java
+++ b/src/com/android/camera/PhotoUI.java
@@ -34,9 +34,6 @@ import android.widget.FrameLayout;
import android.widget.ImageView;
import com.android.camera.FocusOverlayManager.FocusUI;
-import com.android.camera.cameradevice.CameraCapabilities;
-import com.android.camera.cameradevice.CameraManager;
-import com.android.camera.cameradevice.CameraSettings;
import com.android.camera.debug.Log;
import com.android.camera.ui.CountDownView;
import com.android.camera.ui.FaceView;
@@ -47,11 +44,14 @@ import com.android.camera.widget.AspectRatioDialogLayout;
import com.android.camera.widget.AspectRatioSelector;
import com.android.camera.widget.LocationDialogLayout;
import com.android.camera2.R;
+import com.android.ex.camera2.portability.CameraCapabilities;
+import com.android.ex.camera2.portability.CameraAgent;
+import com.android.ex.camera2.portability.CameraSettings;
import java.util.List;
public class PhotoUI implements PreviewStatusListener,
- CameraManager.CameraFaceDetectionCallback, PreviewStatusListener.PreviewAreaChangedListener {
+ CameraAgent.CameraFaceDetectionCallback, PreviewStatusListener.PreviewAreaChangedListener {
private static final Log.Tag TAG = new Log.Tag("PhotoUI");
private static final int DOWN_SAMPLE_FACTOR = 4;
@@ -561,7 +561,7 @@ public class PhotoUI implements PreviewStatusListener,
}
@Override
- public void onFaceDetection(Face[] faces, CameraManager.CameraProxy camera) {
+ public void onFaceDetection(Face[] faces, CameraAgent.CameraProxy camera) {
if (mFaceView != null) {
mFaceView.setFaces(faces);
}
diff --git a/src/com/android/camera/VideoModule.java b/src/com/android/camera/VideoModule.java
index f6e0e3116..de3b9ffb1 100644
--- a/src/com/android/camera/VideoModule.java
+++ b/src/com/android/camera/VideoModule.java
@@ -56,12 +56,6 @@ import com.android.camera.app.LocationManager;
import com.android.camera.app.MediaSaver;
import com.android.camera.app.MemoryManager;
import com.android.camera.app.MemoryManager.MemoryListener;
-import com.android.camera.cameradevice.CameraCapabilities;
-import com.android.camera.cameradevice.CameraManager;
-import com.android.camera.cameradevice.CameraManager.CameraPictureCallback;
-import com.android.camera.cameradevice.CameraManager.CameraProxy;
-import com.android.camera.cameradevice.CameraSettings;
-import com.android.camera.cameradevice.Size;
import com.android.camera.debug.Log;
import com.android.camera.exif.ExifInterface;
import com.android.camera.hardware.HardwareSpec;
@@ -73,6 +67,12 @@ import com.android.camera.util.ApiHelper;
import com.android.camera.util.CameraUtil;
import com.android.camera.util.UsageStatistics;
import com.android.camera2.R;
+import com.android.ex.camera2.portability.CameraCapabilities;
+import com.android.ex.camera2.portability.CameraAgent;
+import com.android.ex.camera2.portability.CameraAgent.CameraPictureCallback;
+import com.android.ex.camera2.portability.CameraAgent.CameraProxy;
+import com.android.ex.camera2.portability.CameraSettings;
+import com.android.ex.camera2.portability.Size;
import com.google.common.logging.eventprotos;
import java.io.File;
@@ -213,8 +213,8 @@ public class VideoModule extends CameraModule
private boolean mFocusAreaSupported;
private boolean mMeteringAreaSupported;
- private final CameraManager.CameraAFCallback mAutoFocusCallback =
- new CameraManager.CameraAFCallback() {
+ private final CameraAgent.CameraAFCallback mAutoFocusCallback =
+ new CameraAgent.CameraAFCallback() {
@Override
public void onAutoFocus(boolean focused, CameraProxy camera) {
if (mPaused) {
@@ -226,7 +226,7 @@ public class VideoModule extends CameraModule
private final Object mAutoFocusMoveCallback =
ApiHelper.HAS_AUTO_FOCUS_MOVE_CALLBACK
- ? new CameraManager.CameraAFMoveCallback() {
+ ? new CameraAgent.CameraAFMoveCallback() {
@Override
public void onAutoFocusMoving(boolean moving, CameraProxy camera) {
mFocusManager.onAutoFocusMoving(moving);
@@ -437,7 +437,7 @@ public class VideoModule extends CameraModule
if (mCameraSettings.getCurrentFocusMode() == CameraCapabilities.FocusMode.CONTINUOUS_PICTURE) {
mCameraDevice.setAutoFocusMoveCallback(mHandler,
- (CameraManager.CameraAFMoveCallback) mAutoFocusMoveCallback);
+ (CameraAgent.CameraAFMoveCallback) mAutoFocusMoveCallback);
} else {
mCameraDevice.setAutoFocusMoveCallback(null, null);
}
diff --git a/src/com/android/camera/VideoUI.java b/src/com/android/camera/VideoUI.java
index fbce6ccb0..1ce025ec4 100644
--- a/src/com/android/camera/VideoUI.java
+++ b/src/com/android/camera/VideoUI.java
@@ -27,8 +27,6 @@ import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
-import com.android.camera.cameradevice.CameraCapabilities;
-import com.android.camera.cameradevice.CameraSettings;
import com.android.camera.debug.Log;
import com.android.camera.ui.FocusOverlay;
import com.android.camera.ui.PreviewOverlay;
@@ -36,6 +34,8 @@ import com.android.camera.ui.PreviewStatusListener;
import com.android.camera.ui.RotateLayout;
import com.android.camera.widget.VideoRecordingHints;
import com.android.camera2.R;
+import com.android.ex.camera2.portability.CameraCapabilities;
+import com.android.ex.camera2.portability.CameraSettings;
import java.util.List;
diff --git a/src/com/android/camera/app/CameraController.java b/src/com/android/camera/app/CameraController.java
index f23cfaaa4..dcd80b410 100644
--- a/src/com/android/camera/app/CameraController.java
+++ b/src/com/android/camera/app/CameraController.java
@@ -21,27 +21,27 @@ import android.hardware.Camera;
import android.os.Handler;
import com.android.camera.CameraDisabledException;
-import com.android.camera.cameradevice.CameraDeviceInfo;
-import com.android.camera.cameradevice.CameraManager;
-import com.android.camera.cameradevice.CameraManager.CameraExceptionCallback;
import com.android.camera.debug.Log;
import com.android.camera.util.CameraUtil;
+import com.android.ex.camera2.portability.CameraDeviceInfo;
+import com.android.ex.camera2.portability.CameraAgent;
+import com.android.ex.camera2.portability.CameraAgent.CameraExceptionCallback;
/**
* A class which implements {@link com.android.camera.app.CameraProvider} used
* by {@link com.android.camera.CameraActivity}.
* TODO: Make this class package private.
*/
-public class CameraController implements CameraManager.CameraOpenCallback, CameraProvider {
+public class CameraController implements CameraAgent.CameraOpenCallback, CameraProvider {
private static final Log.Tag TAG = new Log.Tag("CameraController");
private static final int EMPTY_REQUEST = -1;
private final Context mContext;
- private CameraManager.CameraOpenCallback mCallbackReceiver;
+ private CameraAgent.CameraOpenCallback mCallbackReceiver;
private final Handler mCallbackHandler;
- private final CameraManager mCameraManager;
+ private final CameraAgent mCameraAgent;
private CameraDeviceInfo mInfo;
- private CameraManager.CameraProxy mCameraProxy;
+ private CameraAgent.CameraProxy mCameraProxy;
private int mRequestingCameraId = EMPTY_REQUEST;
/**
@@ -53,13 +53,13 @@ public class CameraController implements CameraManager.CameraOpenCallback, Camer
* callbacks to.
* @param cameraManager Used for camera open/close.
*/
- public CameraController(Context context, CameraManager.CameraOpenCallback callbackReceiver,
- Handler handler, CameraManager cameraManager) {
+ public CameraController(Context context, CameraAgent.CameraOpenCallback callbackReceiver,
+ Handler handler, CameraAgent cameraManager) {
mContext = context;
mCallbackReceiver = callbackReceiver;
mCallbackHandler = handler;
- mCameraManager = cameraManager;
- mInfo = mCameraManager.getCameraDeviceInfo();
+ mCameraAgent = cameraManager;
+ mInfo = mCameraAgent.getCameraDeviceInfo();
if (mInfo == null && mCallbackReceiver != null) {
mCallbackReceiver.onDeviceOpenFailure(-1, "GETTING_CAMERA_INFO");
}
@@ -68,7 +68,7 @@ public class CameraController implements CameraManager.CameraOpenCallback, Camer
@Override
public void setCameraDefaultExceptionCallback(CameraExceptionCallback callback,
Handler handler) {
- mCameraManager.setCameraDefaultExceptionCallback(callback, handler);
+ mCameraAgent.setCameraDefaultExceptionCallback(callback, handler);
}
@Override
@@ -128,7 +128,7 @@ public class CameraController implements CameraManager.CameraOpenCallback, Camer
}
@Override
- public void onCameraOpened(CameraManager.CameraProxy camera) {
+ public void onCameraOpened(CameraAgent.CameraProxy camera) {
Log.v(TAG, "onCameraOpened");
if (mRequestingCameraId != camera.getCameraId()) {
// Not requesting any camera or not waiting for this one.
@@ -163,7 +163,7 @@ public class CameraController implements CameraManager.CameraOpenCallback, Camer
}
@Override
- public void onReconnectionFailure(CameraManager mgr, String info) {
+ public void onReconnectionFailure(CameraAgent mgr, String info) {
if (mCallbackReceiver != null) {
mCallbackReceiver.onReconnectionFailure(mgr, info);
}
@@ -188,11 +188,11 @@ public class CameraController implements CameraManager.CameraOpenCallback, Camer
mRequestingCameraId = id;
if (mCameraProxy == null) {
// No camera yet.
- checkAndOpenCamera(mContext, mCameraManager, id, mCallbackHandler, this);
+ checkAndOpenCamera(mContext, mCameraAgent, id, mCallbackHandler, this);
} else if (mCameraProxy.getCameraId() != id) {
// Already has another camera opened.
- mCameraManager.closeCamera(mCameraProxy, false);
- checkAndOpenCamera(mContext, mCameraManager, id, mCallbackHandler, this);
+ mCameraAgent.closeCamera(mCameraProxy, false);
+ checkAndOpenCamera(mContext, mCameraAgent, id, mCallbackHandler, this);
} else {
// The same camera, just do a reconnect.
Log.v(TAG, "reconnecting to use the existing camera");
@@ -234,12 +234,12 @@ public class CameraController implements CameraManager.CameraOpenCallback, Camer
public void closeCamera(boolean synced) {
Log.v(TAG, "closing camera");
mCameraProxy = null;
- mCameraManager.closeCamera(mCameraProxy, synced);
+ mCameraAgent.closeCamera(mCameraProxy, synced);
mRequestingCameraId = EMPTY_REQUEST;
}
- private static void checkAndOpenCamera(Context context, CameraManager cameraManager,
- final int cameraId, Handler handler, final CameraManager.CameraOpenCallback cb) {
+ private static void checkAndOpenCamera(Context context, CameraAgent cameraManager,
+ final int cameraId, Handler handler, final CameraAgent.CameraOpenCallback cb) {
try {
CameraUtil.throwIfCameraDisabled(context);
cameraManager.openCamera(handler, cameraId, cb);
@@ -254,7 +254,7 @@ public class CameraController implements CameraManager.CameraOpenCallback, Camer
}
public void setOneShotPreviewCallback(Handler handler,
- CameraManager.CameraPreviewDataCallback cb) {
+ CameraAgent.CameraPreviewDataCallback cb) {
mCameraProxy.setOneShotPreviewCallback(handler, cb);
}
}
diff --git a/src/com/android/camera/app/CameraProvider.java b/src/com/android/camera/app/CameraProvider.java
index 34bc67614..9e51f3cb5 100644
--- a/src/com/android/camera/app/CameraProvider.java
+++ b/src/com/android/camera/app/CameraProvider.java
@@ -19,7 +19,7 @@ package com.android.camera.app;
import android.hardware.Camera;
import android.os.Handler;
-import com.android.camera.cameradevice.CameraManager.CameraExceptionCallback;
+import com.android.ex.camera2.portability.CameraAgent.CameraExceptionCallback;
/**
* An interface which defines the camera provider.
diff --git a/src/com/android/camera/cameradevice/AndroidCameraCapabilities.java b/src/com/android/camera/cameradevice/AndroidCameraCapabilities.java
deleted file mode 100644
index fed459735..000000000
--- a/src/com/android/camera/cameradevice/AndroidCameraCapabilities.java
+++ /dev/null
@@ -1,488 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.camera.cameradevice;
-
-import android.hardware.Camera;
-
-import com.android.camera.debug.Log;
-
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
-
-/**
- * The subclass of {@link CameraCapabilities} for Android Camera 1 API.
- */
-class AndroidCameraCapabilities extends CameraCapabilities {
-
- private static Log.Tag TAG = new Log.Tag("AndroidCameraCapabilities");
-
- private FpsComparator mFpsComparator = new FpsComparator();
- private SizeComparator mSizeComparator = new SizeComparator();
-
- AndroidCameraCapabilities(Camera.Parameters p) {
- super(new AndroidCameraCapabilityStringifier());
- mMaxExposureCompensation = p.getMaxExposureCompensation();
- mMinExposureCompensation = p.getMinExposureCompensation();
- mExposureCompensationStep = p.getExposureCompensationStep();
- mMaxNumOfFacesSupported = p.getMaxNumDetectedFaces();
- mMaxNumOfMeteringArea = p.getMaxNumMeteringAreas();
- mPreferredPreviewSizeForVideo = new Size(p.getPreferredPreviewSizeForVideo());
- mSupportedPreviewFormats.addAll(p.getSupportedPreviewFormats());
- mSupportedPhotoFormats.addAll(p.getSupportedPictureFormats());
- mMaxZoomIndex = p.getMaxZoom();
- mZoomRatioList.addAll(p.getZoomRatios());
- mMaxZoomRatio = mZoomRatioList.get(mMaxZoomIndex);
- buildPreviewFpsRange(p);
- buildPreviewSizes(p);
- buildVideoSizes(p);
- buildPictureSizes(p);
- buildSceneModes(p);
- buildFlashModes(p);
- buildFocusModes(p);
- buildWhiteBalances(p);
-
- if (p.isZoomSupported()) {
- mSupportedFeatures.add(Feature.ZOOM);
- }
- if (p.isVideoSnapshotSupported()) {
- mSupportedFeatures.add(Feature.VIDEO_SNAPSHOT);
- }
- if (p.isAutoExposureLockSupported()) {
- mSupportedFeatures.add(Feature.AUTO_EXPOSURE_LOCK);
- }
- if (p.isAutoWhiteBalanceLockSupported()) {
- mSupportedFeatures.add(Feature.AUTO_WHITE_BALANCE_LOCK);
- }
- if (supports(FocusMode.AUTO)) {
- mMaxNumOfFocusAreas = p.getMaxNumFocusAreas();
- if (mMaxNumOfFocusAreas > 0) {
- mSupportedFeatures.add(Feature.FOCUS_AREA);
- }
- }
- if (mMaxNumOfMeteringArea > 0) {
- mSupportedFeatures.add(Feature.METERING_AREA);
- }
- }
-
- AndroidCameraCapabilities(AndroidCameraCapabilities src) {
- super(src);
- }
-
- private void buildPreviewFpsRange(Camera.Parameters p) {
- List<int[]> supportedPreviewFpsRange = p.getSupportedPreviewFpsRange();
- if (supportedPreviewFpsRange != null) {
- mSupportedPreviewFpsRange.addAll(supportedPreviewFpsRange);
- }
- Collections.sort(mSupportedPreviewFpsRange, mFpsComparator);
- }
-
- private void buildPreviewSizes(Camera.Parameters p) {
- List<Camera.Size> supportedPreviewSizes = p.getSupportedPreviewSizes();
- if (supportedPreviewSizes != null) {
- for (Camera.Size s : supportedPreviewSizes) {
- mSupportedPreviewSizes.add(new Size(s.width, s.height));
- }
- }
- Collections.sort(mSupportedPreviewSizes, mSizeComparator);
- }
-
- private void buildVideoSizes(Camera.Parameters p) {
- List<Camera.Size> supportedVideoSizes = p.getSupportedVideoSizes();
- if (supportedVideoSizes != null) {
- for (Camera.Size s : supportedVideoSizes) {
- mSupportedVideoSizes.add(new Size(s.width, s.height));
- }
- }
- Collections.sort(mSupportedVideoSizes, mSizeComparator);
- }
-
- private void buildPictureSizes(Camera.Parameters p) {
- List<Camera.Size> supportedPictureSizes = p.getSupportedPictureSizes();
- if (supportedPictureSizes != null) {
- for (Camera.Size s : supportedPictureSizes) {
- mSupportedPhotoSizes.add(new Size(s.width, s.height));
- }
- }
- Collections.sort(mSupportedPhotoSizes, mSizeComparator);
-
- }
-
- private void buildSceneModes(Camera.Parameters p) {
- List<String> supportedSceneModes = p.getSupportedSceneModes();
- if (supportedSceneModes != null) {
- for (String scene : supportedSceneModes) {
- if (Camera.Parameters.SCENE_MODE_AUTO.equals(scene)) {
- mSupportedSceneModes.add(SceneMode.AUTO);
- } else if (Camera.Parameters.SCENE_MODE_ACTION.equals(scene)) {
- mSupportedSceneModes.add(SceneMode.ACTION);
- } else if (Camera.Parameters.SCENE_MODE_BARCODE.equals(scene)) {
- mSupportedSceneModes.add(SceneMode.BARCODE);
- } else if (Camera.Parameters.SCENE_MODE_BEACH.equals(scene)) {
- mSupportedSceneModes.add(SceneMode.BEACH);
- } else if (Camera.Parameters.SCENE_MODE_CANDLELIGHT.equals(scene)) {
- mSupportedSceneModes.add(SceneMode.CANDLELIGHT);
- } else if (Camera.Parameters.SCENE_MODE_FIREWORKS.equals(scene)) {
- mSupportedSceneModes.add(SceneMode.FIREWORKS);
- } else if (Camera.Parameters.SCENE_MODE_HDR.equals(scene)) {
- mSupportedSceneModes.add(SceneMode.HDR);
- } else if (Camera.Parameters.SCENE_MODE_LANDSCAPE.equals(scene)) {
- mSupportedSceneModes.add(SceneMode.LANDSCAPE);
- } else if (Camera.Parameters.SCENE_MODE_NIGHT.equals(scene)) {
- mSupportedSceneModes.add(SceneMode.NIGHT);
- } else if (Camera.Parameters.SCENE_MODE_NIGHT_PORTRAIT.equals(scene)) {
- mSupportedSceneModes.add(SceneMode.NIGHT_PORTRAIT);
- } else if (Camera.Parameters.SCENE_MODE_PARTY.equals(scene)) {
- mSupportedSceneModes.add(SceneMode.PARTY);
- } else if (Camera.Parameters.SCENE_MODE_PORTRAIT.equals(scene)) {
- mSupportedSceneModes.add(SceneMode.PORTRAIT);
- } else if (Camera.Parameters.SCENE_MODE_SNOW.equals(scene)) {
- mSupportedSceneModes.add(SceneMode.SNOW);
- } else if (Camera.Parameters.SCENE_MODE_SPORTS.equals(scene)) {
- mSupportedSceneModes.add(SceneMode.SPORTS);
- } else if (Camera.Parameters.SCENE_MODE_STEADYPHOTO.equals(scene)) {
- mSupportedSceneModes.add(SceneMode.STEADYPHOTO);
- } else if (Camera.Parameters.SCENE_MODE_SUNSET.equals(scene)) {
- mSupportedSceneModes.add(SceneMode.SUNSET);
- } else if (Camera.Parameters.SCENE_MODE_THEATRE.equals(scene)) {
- mSupportedSceneModes.add(SceneMode.THEATRE);
- }
- }
- }
- }
-
- private void buildFlashModes(Camera.Parameters p) {
- List<String> supportedFlashModes = p.getSupportedFlashModes();
- if (supportedFlashModes == null) {
- // Camera 1 will return NULL if no flash mode is supported.
- mSupportedFlashModes.add(FlashMode.NO_FLASH);
- } else {
- for (String flash : supportedFlashModes) {
- if (Camera.Parameters.FLASH_MODE_AUTO.equals(flash)) {
- mSupportedFlashModes.add(FlashMode.AUTO);
- } else if (Camera.Parameters.FLASH_MODE_OFF.equals(flash)) {
- mSupportedFlashModes.add(FlashMode.OFF);
- } else if (Camera.Parameters.FLASH_MODE_ON.equals(flash)) {
- mSupportedFlashModes.add(FlashMode.ON);
- } else if (Camera.Parameters.FLASH_MODE_RED_EYE.equals(flash)) {
- mSupportedFlashModes.add(FlashMode.RED_EYE);
- }
- }
- }
- }
-
- private void buildFocusModes(Camera.Parameters p) {
- List<String> supportedFocusModes = p.getSupportedFocusModes();
- if (supportedFocusModes != null) {
- for (String focus : supportedFocusModes) {
- if (Camera.Parameters.FOCUS_MODE_AUTO.equals(focus)) {
- mSupportedFocusModes.add(FocusMode.AUTO);
- } else if (Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE.equals(focus)) {
- mSupportedFocusModes.add(FocusMode.CONTINUOUS_PICTURE);
- } else if (Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO.equals(focus)) {
- mSupportedFocusModes.add(FocusMode.CONTINUOUS_VIDEO);
- } else if (Camera.Parameters.FOCUS_MODE_EDOF.equals(focus)) {
- mSupportedFocusModes.add(FocusMode.EXTENDED_DOF);
- } else if (Camera.Parameters.FOCUS_MODE_FIXED.equals(focus)) {
- mSupportedFocusModes.add(FocusMode.FIXED);
- } else if (Camera.Parameters.FOCUS_MODE_INFINITY.equals(focus)) {
- mSupportedFocusModes.add(FocusMode.INFINITY);
- } else if (Camera.Parameters.FOCUS_MODE_MACRO.equals(focus)) {
- mSupportedFocusModes.add(FocusMode.MACRO);
- }
- }
- }
- }
-
- private void buildWhiteBalances(Camera.Parameters p) {
- List<String> supportedWhiteBalances = p.getSupportedFocusModes();
- if (supportedWhiteBalances != null) {
- for (String wb : supportedWhiteBalances) {
- if (Camera.Parameters.WHITE_BALANCE_AUTO.equals(wb)) {
- mSupportedWhiteBalances.add(WhiteBalance.AUTO);
- } else if (Camera.Parameters.WHITE_BALANCE_CLOUDY_DAYLIGHT.equals(wb)) {
- mSupportedWhiteBalances.add(WhiteBalance.CLOUDY_DAYLIGHT);
- } else if (Camera.Parameters.WHITE_BALANCE_DAYLIGHT.equals(wb)) {
- mSupportedWhiteBalances.add(WhiteBalance.DAYLIGHT);
- } else if (Camera.Parameters.WHITE_BALANCE_FLUORESCENT.equals(wb)) {
- mSupportedWhiteBalances.add(WhiteBalance.FLUORESCENT);
- } else if (Camera.Parameters.WHITE_BALANCE_INCANDESCENT.equals(wb)) {
- mSupportedWhiteBalances.add(WhiteBalance.INCANDESCENT);
- } else if (Camera.Parameters.WHITE_BALANCE_SHADE.equals(wb)) {
- mSupportedWhiteBalances.add(WhiteBalance.SHADE);
- } else if (Camera.Parameters.WHITE_BALANCE_TWILIGHT.equals(wb)) {
- mSupportedWhiteBalances.add(WhiteBalance.TWILIGHT);
- } else if (Camera.Parameters.WHITE_BALANCE_WARM_FLUORESCENT.equals(wb)) {
- mSupportedWhiteBalances.add(WhiteBalance.WARM_FLUORESCENT);
- }
- }
- }
- }
-
- private static class FpsComparator implements Comparator<int[]> {
- @Override
- public int compare(int[] fps1, int[] fps2) {
- return (fps1[0] == fps2[0] ? fps1[1] - fps2[1] : fps1[0] - fps2[0]);
- }
- }
-
- private static class SizeComparator implements Comparator<Size> {
-
- @Override
- public int compare(Size size1, Size size2) {
- return (size1.width() == size2.width() ? size1.height() - size2.height() :
- size1.width() - size2.width());
- }
- }
-
- private static class AndroidCameraCapabilityStringifier implements Stringifier {
-
- @Override
- public String stringify(FocusMode focus) {
- if (focus == null) {
- return null;
- }
-
- switch (focus) {
- case AUTO:
- return Camera.Parameters.FOCUS_MODE_AUTO;
- case CONTINUOUS_PICTURE:
- return Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE;
- case CONTINUOUS_VIDEO:
- return Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO;
- case EXTENDED_DOF:
- return Camera.Parameters.FOCUS_MODE_EDOF;
- case FIXED:
- return Camera.Parameters.FOCUS_MODE_FIXED;
- case INFINITY:
- return Camera.Parameters.FOCUS_MODE_INFINITY;
- case MACRO:
- return Camera.Parameters.FOCUS_MODE_MACRO;
- }
- return null;
- }
-
- @Override
- public FocusMode focusModeFromString(String val) {
- if (val == null) {
- return null;
- }
-
- if (Camera.Parameters.FOCUS_MODE_AUTO.equals(val)) {
- return FocusMode.AUTO;
- } else if (Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE.equals(val)) {
- return FocusMode.CONTINUOUS_PICTURE;
- } else if (Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO.equals(val)) {
- return FocusMode.CONTINUOUS_VIDEO;
- } else if (Camera.Parameters.FOCUS_MODE_EDOF.equals(val)) {
- return FocusMode.EXTENDED_DOF;
- } else if (Camera.Parameters.FOCUS_MODE_FIXED.equals(val)) {
- return FocusMode.FIXED;
- } else if (Camera.Parameters.FOCUS_MODE_INFINITY.equals(val)) {
- return FocusMode.INFINITY;
- } else if (Camera.Parameters.FOCUS_MODE_MACRO.equals(val)) {
- return FocusMode.MACRO;
- } else {
- return null;
- }
- }
-
- @Override
- public String stringify(FlashMode flash) {
- if (flash == null) {
- return null;
- }
-
- switch (flash) {
- case NO_FLASH:
- return null;
- case AUTO:
- return Camera.Parameters.FLASH_MODE_AUTO;
- case OFF:
- return Camera.Parameters.FLASH_MODE_OFF;
- case ON:
- return Camera.Parameters.FLASH_MODE_ON;
- case TORCH:
- return Camera.Parameters.FLASH_MODE_TORCH;
- case RED_EYE:
- return Camera.Parameters.FLASH_MODE_RED_EYE;
- }
- return null;
- }
-
- @Override
- public FlashMode flashModeFromString(String val) {
- if (val == null) {
- return FlashMode.NO_FLASH;
- } else if (Camera.Parameters.FLASH_MODE_AUTO.equals(val)) {
- return FlashMode.AUTO;
- } else if (Camera.Parameters.FLASH_MODE_OFF.equals(val)) {
- return FlashMode.OFF;
- } else if (Camera.Parameters.FLASH_MODE_ON.equals(val)) {
- return FlashMode.ON;
- } else if (Camera.Parameters.FLASH_MODE_TORCH.equals(val)) {
- return FlashMode.TORCH;
- } else if (Camera.Parameters.FLASH_MODE_RED_EYE.equals(val)) {
- return FlashMode.RED_EYE;
- } else {
- return null;
- }
- }
-
- @Override
- public String stringify(SceneMode scene) {
- if (scene == null) {
- return null;
- }
-
- switch (scene) {
- case AUTO:
- return Camera.Parameters.SCENE_MODE_AUTO;
- case ACTION:
- return Camera.Parameters.SCENE_MODE_ACTION;
- case BARCODE:
- return Camera.Parameters.SCENE_MODE_BARCODE;
- case BEACH:
- return Camera.Parameters.SCENE_MODE_BEACH;
- case CANDLELIGHT:
- return Camera.Parameters.SCENE_MODE_CANDLELIGHT;
- case FIREWORKS:
- return Camera.Parameters.SCENE_MODE_FIREWORKS;
- case HDR:
- return Camera.Parameters.SCENE_MODE_HDR;
- case LANDSCAPE:
- return Camera.Parameters.SCENE_MODE_LANDSCAPE;
- case NIGHT:
- return Camera.Parameters.SCENE_MODE_NIGHT;
- case NIGHT_PORTRAIT:
- return Camera.Parameters.SCENE_MODE_NIGHT_PORTRAIT;
- case PARTY:
- return Camera.Parameters.SCENE_MODE_PARTY;
- case PORTRAIT:
- return Camera.Parameters.SCENE_MODE_PORTRAIT;
- case SNOW:
- return Camera.Parameters.SCENE_MODE_SNOW;
- case SPORTS:
- return Camera.Parameters.SCENE_MODE_SPORTS;
- case STEADYPHOTO:
- return Camera.Parameters.SCENE_MODE_STEADYPHOTO;
- case SUNSET:
- return Camera.Parameters.SCENE_MODE_SUNSET;
- case THEATRE:
- return Camera.Parameters.SCENE_MODE_THEATRE;
- }
- return null;
- }
-
- @Override
- public SceneMode sceneModeFromString(String val) {
- if (val == null) {
- return SceneMode.NO_SCENE_MODE;
- } else if (Camera.Parameters.SCENE_MODE_AUTO.equals(val)) {
- return SceneMode.AUTO;
- } else if (Camera.Parameters.SCENE_MODE_ACTION.equals(val)) {
- return SceneMode.ACTION;
- } else if (Camera.Parameters.SCENE_MODE_BARCODE.equals(val)) {
- return SceneMode.BARCODE;
- } else if (Camera.Parameters.SCENE_MODE_BEACH.equals(val)) {
- return SceneMode.BEACH;
- } else if (Camera.Parameters.SCENE_MODE_CANDLELIGHT.equals(val)) {
- return SceneMode.CANDLELIGHT;
- } else if (Camera.Parameters.SCENE_MODE_FIREWORKS.equals(val)) {
- return SceneMode.FIREWORKS;
- } else if (Camera.Parameters.SCENE_MODE_HDR.equals(val)) {
- return SceneMode.HDR;
- } else if (Camera.Parameters.SCENE_MODE_LANDSCAPE.equals(val)) {
- return SceneMode.LANDSCAPE;
- } else if (Camera.Parameters.SCENE_MODE_NIGHT.equals(val)) {
- return SceneMode.NIGHT;
- } else if (Camera.Parameters.SCENE_MODE_NIGHT_PORTRAIT.equals(val)) {
- return SceneMode.NIGHT_PORTRAIT;
- } else if (Camera.Parameters.SCENE_MODE_PARTY.equals(val)) {
- return SceneMode.PARTY;
- } else if (Camera.Parameters.SCENE_MODE_PORTRAIT.equals(val)) {
- return SceneMode.PORTRAIT;
- } else if (Camera.Parameters.SCENE_MODE_SNOW.equals(val)) {
- return SceneMode.SNOW;
- } else if (Camera.Parameters.SCENE_MODE_SPORTS.equals(val)) {
- return SceneMode.SPORTS;
- } else if (Camera.Parameters.SCENE_MODE_STEADYPHOTO.equals(val)) {
- return SceneMode.STEADYPHOTO;
- } else if (Camera.Parameters.SCENE_MODE_SUNSET.equals(val)) {
- return SceneMode.SUNSET;
- } else if (Camera.Parameters.SCENE_MODE_THEATRE.equals(val)) {
- return SceneMode.THEATRE;
- } else {
- return null;
- }
- }
-
- @Override
- public String stringify(WhiteBalance wb) {
- if (wb == null) {
- return null;
- }
-
- switch (wb) {
- case AUTO:
- return Camera.Parameters.WHITE_BALANCE_AUTO;
- case CLOUDY_DAYLIGHT:
- return Camera.Parameters.WHITE_BALANCE_CLOUDY_DAYLIGHT;
- case DAYLIGHT:
- return Camera.Parameters.WHITE_BALANCE_DAYLIGHT;
- case FLUORESCENT:
- return Camera.Parameters.WHITE_BALANCE_FLUORESCENT;
- case INCANDESCENT:
- return Camera.Parameters.WHITE_BALANCE_INCANDESCENT;
- case SHADE:
- return Camera.Parameters.WHITE_BALANCE_SHADE;
- case TWILIGHT:
- return Camera.Parameters.WHITE_BALANCE_TWILIGHT;
- case WARM_FLUORESCENT:
- return Camera.Parameters.WHITE_BALANCE_WARM_FLUORESCENT;
- }
- return null;
- }
-
- @Override
- public WhiteBalance whiteBalanceFromString(String val) {
- if (val == null) {
- return null;
- }
-
- if (Camera.Parameters.WHITE_BALANCE_AUTO.equals(val)) {
- return WhiteBalance.AUTO;
- } else if (Camera.Parameters.WHITE_BALANCE_CLOUDY_DAYLIGHT.equals(val)) {
- return WhiteBalance.CLOUDY_DAYLIGHT;
- } else if (Camera.Parameters.WHITE_BALANCE_DAYLIGHT.equals(val)) {
- return WhiteBalance.DAYLIGHT;
- } else if (Camera.Parameters.WHITE_BALANCE_FLUORESCENT.equals(val)) {
- return WhiteBalance.FLUORESCENT;
- } else if (Camera.Parameters.WHITE_BALANCE_INCANDESCENT.equals(val)) {
- return WhiteBalance.INCANDESCENT;
- } else if (Camera.Parameters.WHITE_BALANCE_SHADE.equals(val)) {
- return WhiteBalance.SHADE;
- } else if (Camera.Parameters.WHITE_BALANCE_TWILIGHT.equals(val)) {
- return WhiteBalance.TWILIGHT;
- } else if (Camera.Parameters.WHITE_BALANCE_WARM_FLUORESCENT.equals(val)) {
- return WhiteBalance.WARM_FLUORESCENT;
- } else {
- return null;
- }
- }
- }
-}
diff --git a/src/com/android/camera/cameradevice/AndroidCameraManagerImpl.java b/src/com/android/camera/cameradevice/AndroidCameraManagerImpl.java
deleted file mode 100644
index 20060f159..000000000
--- a/src/com/android/camera/cameradevice/AndroidCameraManagerImpl.java
+++ /dev/null
@@ -1,1354 +0,0 @@
-/*
- * Copyright (C) 2013 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.camera.cameradevice;
-
-import android.annotation.TargetApi;
-import android.graphics.SurfaceTexture;
-import android.hardware.Camera;
-import android.hardware.Camera.AutoFocusCallback;
-import android.hardware.Camera.AutoFocusMoveCallback;
-import android.hardware.Camera.ErrorCallback;
-import android.hardware.Camera.FaceDetectionListener;
-import android.hardware.Camera.OnZoomChangeListener;
-import android.hardware.Camera.Parameters;
-import android.hardware.Camera.PictureCallback;
-import android.hardware.Camera.PreviewCallback;
-import android.hardware.Camera.ShutterCallback;
-import android.os.Build;
-import android.os.Handler;
-import android.os.HandlerThread;
-import android.os.Looper;
-import android.os.Message;
-import android.view.SurfaceHolder;
-
-import com.android.camera.debug.Log;
-
-import java.io.IOException;
-
-/**
- * A class to implement {@link CameraManager} of the Android camera framework.
- */
-class AndroidCameraManagerImpl implements CameraManager {
- private static final Log.Tag TAG = new Log.Tag("AndroidCamMgrImpl");
-
- private Parameters mParameters;
- private boolean mParametersIsDirty;
- private AndroidCameraCapabilities mCapabilities;
-
- private final CameraHandler mCameraHandler;
- private final HandlerThread mCameraHandlerThread;
- private final CameraStateHolder mCameraState;
- private final DispatchThread mDispatchThread;
-
- private Handler mCameraExceptionCallbackHandler;
- private CameraExceptionCallback mCameraExceptionCallback =
- new CameraExceptionCallback() {
- @Override
- public void onCameraException(RuntimeException e) {
- throw e;
- }
- };
-
- AndroidCameraManagerImpl() {
- mCameraHandlerThread = new HandlerThread("Camera Handler Thread");
- mCameraHandlerThread.start();
- mCameraHandler = new CameraHandler(mCameraHandlerThread.getLooper());
- mCameraExceptionCallbackHandler = mCameraHandler;
- mCameraState = new CameraStateHolder();
- mDispatchThread = new DispatchThread(mCameraHandler, mCameraHandlerThread);
- mDispatchThread.start();
- }
-
- @Override
- public void setCameraDefaultExceptionCallback(CameraExceptionCallback callback,
- Handler handler) {
- synchronized (mCameraExceptionCallback) {
- mCameraExceptionCallback = callback;
- mCameraExceptionCallbackHandler = handler;
- }
- }
-
- @Override
- public void recycle() {
- closeCamera(null, true);
- mDispatchThread.end();
- }
-
- @Override
- public CameraDeviceInfo getCameraDeviceInfo() {
- return AndroidCameraDeviceInfo.create();
- }
-
- private static class AndroidCameraDeviceInfo implements CameraDeviceInfo {
- private final Camera.CameraInfo[] mCameraInfos;
- private final int mNumberOfCameras;
- private final int mFirstBackCameraId;
- private final int mFirstFrontCameraId;
-
- private AndroidCameraDeviceInfo(Camera.CameraInfo[] info, int numberOfCameras,
- int firstBackCameraId, int firstFrontCameraId) {
-
- mCameraInfos = info;
- mNumberOfCameras = numberOfCameras;
- mFirstBackCameraId = firstBackCameraId;
- mFirstFrontCameraId = firstFrontCameraId;
- }
-
- public static AndroidCameraDeviceInfo create() {
- int numberOfCameras;
- Camera.CameraInfo[] cameraInfos;
- try {
- numberOfCameras = Camera.getNumberOfCameras();
- cameraInfos = new Camera.CameraInfo[numberOfCameras];
- for (int i = 0; i < numberOfCameras; i++) {
- cameraInfos[i] = new Camera.CameraInfo();
- Camera.getCameraInfo(i, cameraInfos[i]);
- }
- } catch (RuntimeException ex) {
- return null;
- }
-
- int firstFront = NO_DEVICE;
- int firstBack = NO_DEVICE;
- // Get the first (smallest) back and first front camera id.
- for (int i = numberOfCameras - 1; i >= 0; i--) {
- if (cameraInfos[i].facing == Camera.CameraInfo.CAMERA_FACING_BACK) {
- firstBack = i;
- } else {
- if (cameraInfos[i].facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
- firstFront = i;
- }
- }
- }
-
- return new AndroidCameraDeviceInfo(cameraInfos, numberOfCameras, firstBack, firstFront);
- }
-
- @Override
- public Camera.CameraInfo[] getCameraInfos() {
- return mCameraInfos;
- }
-
- @Override
- public int getNumberOfCameras() {
- return mNumberOfCameras;
- }
-
- @Override
- public int getFirstBackCameraId() {
- return mFirstBackCameraId;
- }
-
- @Override
- public int getFirstFrontCameraId() {
- return mFirstFrontCameraId;
- }
- }
-
- /**
- * The handler on which the actual camera operations happen.
- */
- private class CameraHandler extends HistoryHandler {
-
- // Used to retain a copy of Parameters for setting parameters.
- private Parameters mParamsToSet;
- private Camera mCamera;
- private int mCameraId;
-
- private class CaptureCallbacks {
- public final ShutterCallback mShutter;
- public final PictureCallback mRaw;
- public final PictureCallback mPostView;
- public final PictureCallback mJpeg;
-
- CaptureCallbacks(ShutterCallback shutter, PictureCallback raw, PictureCallback postView,
- PictureCallback jpeg) {
- mShutter = shutter;
- mRaw = raw;
- mPostView = postView;
- mJpeg = jpeg;
- }
- }
-
- CameraHandler(Looper looper) {
- super(looper);
- }
-
- private void startFaceDetection() {
- mCamera.startFaceDetection();
- }
-
- private void stopFaceDetection() {
- mCamera.stopFaceDetection();
- }
-
- private void setFaceDetectionListener(FaceDetectionListener listener) {
- mCamera.setFaceDetectionListener(listener);
- }
-
- private void setPreviewTexture(Object surfaceTexture) {
- try {
- mCamera.setPreviewTexture((SurfaceTexture) surfaceTexture);
- } catch (IOException e) {
- Log.e(TAG, "Could not set preview texture", e);
- }
- }
-
- @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
- private void enableShutterSound(boolean enable) {
- mCamera.enableShutterSound(enable);
- }
-
- @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
- private void setAutoFocusMoveCallback(
- android.hardware.Camera camera, Object cb) {
- try {
- camera.setAutoFocusMoveCallback((AutoFocusMoveCallback) cb);
- } catch (RuntimeException ex) {
- Log.w(TAG, ex.getMessage());
- }
- }
-
- private void capture(final CaptureCallbacks cb) {
- try {
- mCamera.takePicture(cb.mShutter, cb.mRaw, cb.mPostView, cb.mJpeg);
- } catch (RuntimeException e) {
- // TODO: output camera state and focus state for debugging.
- Log.e(TAG, "take picture failed.");
- throw e;
- }
- }
-
- public void requestTakePicture(
- final ShutterCallback shutter,
- final PictureCallback raw,
- final PictureCallback postView,
- final PictureCallback jpeg) {
- final CaptureCallbacks callbacks = new CaptureCallbacks(shutter, raw, postView, jpeg);
- obtainMessage(CameraActions.CAPTURE_PHOTO, callbacks).sendToTarget();
- }
-
- /**
- * This method does not deal with the API level check. Everyone should
- * check first for supported operations before sending message to this handler.
- */
- @Override
- public void handleMessage(final Message msg) {
- super.handleMessage(msg);
- try {
- switch (msg.what) {
- case CameraActions.OPEN_CAMERA: {
- final CameraOpenCallback openCallback = (CameraOpenCallback) msg.obj;
- final int cameraId = msg.arg1;
- if (mCameraState.getState() != CameraStateHolder.CAMERA_UNOPENED) {
- openCallback.onDeviceOpenedAlready(cameraId, generateHistoryString(cameraId));
- break;
- }
-
- mCamera = android.hardware.Camera.open(cameraId);
- if (mCamera != null) {
- mCameraId = cameraId;
- mParametersIsDirty = true;
-
- // Get a instance of Camera.Parameters for later use.
- mParamsToSet = mCamera.getParameters();
- mCapabilities = new AndroidCameraCapabilities(mParamsToSet);
-
- mCameraState.setState(CameraStateHolder.CAMERA_IDLE);
- if (openCallback != null) {
- openCallback.onCameraOpened(
- new AndroidCameraProxyImpl(cameraId, mCamera,
- mCapabilities));
- }
- } else {
- if (openCallback != null) {
- openCallback.onDeviceOpenFailure(cameraId, generateHistoryString(cameraId));
- }
- }
- break;
- }
-
- case CameraActions.RELEASE: {
- if (mCamera != null) {
- mCamera.release();
- mCameraState.setState(CameraStateHolder.CAMERA_UNOPENED);
- mCamera = null;
- } else {
- Log.w(TAG, "Releasing camera without any camera opened.");
- }
- break;
- }
-
- case CameraActions.RECONNECT: {
- final CameraOpenCallbackForward cbForward =
- (CameraOpenCallbackForward) msg.obj;
- final int cameraId = msg.arg1;
- try {
- mCamera.reconnect();
- } catch (IOException ex) {
- if (cbForward != null) {
- cbForward.onReconnectionFailure(AndroidCameraManagerImpl.this,
- generateHistoryString(mCameraId));
- }
- break;
- }
-
- mCameraState.setState(CameraStateHolder.CAMERA_IDLE);
- if (cbForward != null) {
- cbForward.onCameraOpened(
- new AndroidCameraProxyImpl(cameraId, mCamera, mCapabilities));
- }
- break;
- }
-
- case CameraActions.UNLOCK: {
- mCamera.unlock();
- mCameraState.setState(CameraStateHolder.CAMERA_UNLOCKED);
- break;
- }
-
- case CameraActions.LOCK: {
- mCamera.lock();
- mCameraState.setState(CameraStateHolder.CAMERA_IDLE);
- break;
- }
-
- case CameraActions.SET_PREVIEW_TEXTURE_ASYNC: {
- setPreviewTexture(msg.obj);
- break;
- }
-
- case CameraActions.SET_PREVIEW_DISPLAY_ASYNC: {
- try {
- mCamera.setPreviewDisplay((SurfaceHolder) msg.obj);
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- break;
- }
-
- case CameraActions.START_PREVIEW_ASYNC: {
- final CameraStartPreviewCallbackForward cbForward =
- (CameraStartPreviewCallbackForward) msg.obj;
- mCamera.startPreview();
- if (cbForward != null) {
- cbForward.onPreviewStarted();
- }
- break;
- }
-
- case CameraActions.STOP_PREVIEW: {
- mCamera.stopPreview();
- break;
- }
-
- case CameraActions.SET_PREVIEW_CALLBACK_WITH_BUFFER: {
- mCamera.setPreviewCallbackWithBuffer((PreviewCallback) msg.obj);
- break;
- }
-
- case CameraActions.SET_ONE_SHOT_PREVIEW_CALLBACK: {
- mCamera.setOneShotPreviewCallback((PreviewCallback) msg.obj);
- break;
- }
-
- case CameraActions.ADD_CALLBACK_BUFFER: {
- mCamera.addCallbackBuffer((byte[]) msg.obj);
- break;
- }
-
- case CameraActions.AUTO_FOCUS: {
- mCameraState.setState(CameraStateHolder.CAMERA_FOCUSING);
- mCamera.autoFocus((AutoFocusCallback) msg.obj);
- break;
- }
-
- case CameraActions.CANCEL_AUTO_FOCUS: {
- mCamera.cancelAutoFocus();
- mCameraState.setState(CameraStateHolder.CAMERA_IDLE);
- break;
- }
-
- case CameraActions.SET_AUTO_FOCUS_MOVE_CALLBACK: {
- setAutoFocusMoveCallback(mCamera, msg.obj);
- break;
- }
-
- case CameraActions.SET_DISPLAY_ORIENTATION: {
- mCamera.setDisplayOrientation(msg.arg1);
- break;
- }
-
- case CameraActions.SET_ZOOM_CHANGE_LISTENER: {
- mCamera.setZoomChangeListener((OnZoomChangeListener) msg.obj);
- break;
- }
-
- case CameraActions.SET_FACE_DETECTION_LISTENER: {
- setFaceDetectionListener((FaceDetectionListener) msg.obj);
- break;
- }
-
- case CameraActions.START_FACE_DETECTION: {
- startFaceDetection();
- break;
- }
-
- case CameraActions.STOP_FACE_DETECTION: {
- stopFaceDetection();
- break;
- }
-
- case CameraActions.SET_ERROR_CALLBACK: {
- mCamera.setErrorCallback((ErrorCallback) msg.obj);
- break;
- }
-
- case CameraActions.APPLY_SETTINGS: {
- mParametersIsDirty = true;
- CameraSettings settings = (CameraSettings) msg.obj;
- applyToParameters(settings);
- mCamera.setParameters(mParamsToSet);
- break;
- }
-
- case CameraActions.SET_PARAMETERS: {
- mParametersIsDirty = true;
- mParamsToSet.unflatten((String) msg.obj);
- mCamera.setParameters(mParamsToSet);
- break;
- }
-
- case CameraActions.GET_PARAMETERS: {
- if (mParametersIsDirty) {
- mParameters = mCamera.getParameters();
- mParametersIsDirty = false;
- }
- break;
- }
-
- case CameraActions.SET_PREVIEW_CALLBACK: {
- mCamera.setPreviewCallback((PreviewCallback) msg.obj);
- break;
- }
-
- case CameraActions.ENABLE_SHUTTER_SOUND: {
- enableShutterSound((msg.arg1 == 1) ? true : false);
- break;
- }
-
- case CameraActions.REFRESH_PARAMETERS: {
- mParametersIsDirty = true;
- break;
- }
-
- case CameraActions.CAPTURE_PHOTO: {
- mCameraState.setState(CameraStateHolder.CAMERA_CAPTURING);
- capture((CaptureCallbacks) msg.obj);
- break;
- }
-
- default: {
- throw new RuntimeException("Invalid CameraProxy message=" + msg.what);
- }
- }
- } catch (final RuntimeException e) {
- if (msg.what != CameraActions.RELEASE && mCamera != null) {
- try {
- mCamera.release();
- mCameraState.setState(CameraStateHolder.CAMERA_UNOPENED);
- } catch (Exception ex) {
- Log.e(TAG, "Fail to release the camera.");
- }
- mCamera = null;
- } else {
- if (mCamera == null) {
- if (msg.what == CameraActions.OPEN_CAMERA) {
- final int cameraId = msg.arg1;
- if (msg.obj != null) {
- ((CameraOpenCallback) msg.obj).onDeviceOpenFailure(
- msg.arg1, generateHistoryString(cameraId));
- }
- } else {
- Log.w(TAG, "Cannot handle message " + msg.what + ", mCamera is null.");
- }
- return;
- }
- }
- synchronized (mCameraExceptionCallback) {
- mCameraExceptionCallbackHandler.post(new Runnable() {
- @Override
- public void run() {
- mCameraExceptionCallback.onCameraException(e);
- }
- });
- }
- }
- }
-
- private void applyToParameters(final CameraSettings settings) {
- final CameraCapabilities.Stringifier stringifier = mCapabilities.getStringifier();
- Size photoSize = settings.getCurrentPhotoSize();
- mParamsToSet.setPictureSize(photoSize.width(), photoSize.height());
- Size previewSize = settings.getCurrentPreviewSize();
- mParamsToSet.setPreviewSize(previewSize.width(), previewSize.height());
- if (settings.getPreviewFrameRate() == -1) {
- mParamsToSet.setPreviewFpsRange(settings.getPreviewFpsRangeMin(),
- settings.getPreviewFpsRangeMax());
- } else {
- mParamsToSet.setPreviewFrameRate(settings.getPreviewFrameRate());
- }
- mParamsToSet.setJpegQuality(settings.getPhotoJpegCompressionQuality());
- if (mCapabilities.supports(CameraCapabilities.Feature.ZOOM)) {
- // Should use settings.getCurrentZoomRatio() instead here.
- mParamsToSet.setZoom(settings.getCurrentZoomIndex());
- }
- mParamsToSet.setRotation((int) settings.getCurrentPhotoRotationDegrees());
- mParamsToSet.setExposureCompensation(settings.getExposureCompensationIndex());
- if (mCapabilities.supports(CameraCapabilities.Feature.AUTO_EXPOSURE_LOCK)) {
- mParamsToSet.setAutoExposureLock(settings.isAutoExposureLocked());
- }
- mParamsToSet.setFocusMode(stringifier.stringify(settings.getCurrentFocusMode()));
- if (mCapabilities.supports(CameraCapabilities.Feature.AUTO_WHITE_BALANCE_LOCK)) {
- mParamsToSet.setAutoWhiteBalanceLock(settings.isAutoWhiteBalanceLocked());
- }
- if (mCapabilities.supports(CameraCapabilities.Feature.FOCUS_AREA)) {
- if (settings.getFocusAreas().size() != 0) {
- mParamsToSet.setFocusAreas(settings.getFocusAreas());
- }
- }
- if (mCapabilities.supports(CameraCapabilities.Feature.METERING_AREA)) {
- if (settings.getMeteringAreas().size() != 0) {
- mParamsToSet.setMeteringAreas(settings.getMeteringAreas());
- }
- }
- if (settings.getCurrentFlashMode() != CameraCapabilities.FlashMode.NO_FLASH) {
- mParamsToSet.setFlashMode(stringifier.stringify(settings.getCurrentFlashMode()));
- }
- if (settings.getCurrentSceneMode() != CameraCapabilities.SceneMode.NO_SCENE_MODE) {
- if (settings.getCurrentSceneMode() != null) {
- mParamsToSet
- .setSceneMode(stringifier.stringify(settings.getCurrentSceneMode()));
- }
- }
-
- CameraSettings.GpsData gpsData = settings.getGpsData();
- if (gpsData == null) {
- mParamsToSet.removeGpsData();
- } else {
- mParamsToSet.setGpsTimestamp(gpsData.timeStamp);
- if (gpsData.processingMethod != null) {
- // It's a hack since we always use GPS time stamp but does
- // not use other fields sometimes. Setting processing
- // method to null means the other fields should not be used.
- mParamsToSet.setGpsAltitude(gpsData.altitude);
- mParamsToSet.setGpsLatitude(gpsData.latitude);
- mParamsToSet.setGpsLongitude(gpsData.longitude);
- mParamsToSet.setGpsProcessingMethod(gpsData.processingMethod);
- }
- }
-
- }
- }
-
- @Override
- public void openCamera(final Handler handler, final int cameraId,
- final CameraOpenCallback callback) {
- mDispatchThread.runJob(new Runnable() {
- @Override
- public void run() {
- mCameraHandler.obtainMessage(CameraActions.OPEN_CAMERA, cameraId, 0,
- CameraOpenCallbackForward.getNewInstance(handler, callback)).sendToTarget();
- }
- });
- }
-
- @Override
- public void closeCamera(CameraProxy camera, boolean synced) {
- if (synced) {
- final WaitDoneBundle bundle = new WaitDoneBundle();
-
- mDispatchThread.runJobSync(new Runnable() {
- @Override
- public void run() {
- mCameraHandler.obtainMessage(CameraActions.RELEASE).sendToTarget();
- mCameraHandler.post(bundle.mUnlockRunnable);
- }
- }, bundle.mWaitLock, CAMERA_OPERATION_TIMEOUT_MS, "camera release");
- } else {
- mDispatchThread.runJob(new Runnable() {
- @Override
- public void run() {
- mCameraHandler.removeCallbacksAndMessages(null);
- mCameraHandler.obtainMessage(CameraActions.RELEASE).sendToTarget();
- }
- });
- }
- }
-
- /**
- * A class which implements {@link CameraManager.CameraProxy} and
- * camera handler thread.
- */
- private class AndroidCameraProxyImpl implements CameraManager.CameraProxy {
- private final int mCameraId;
- /* TODO: remove this Camera instance. */
- private final Camera mCamera;
- private final AndroidCameraCapabilities mCapabilities;
-
- private AndroidCameraProxyImpl(int cameraId, Camera camera,
- AndroidCameraCapabilities capabilities) {
- mCamera = camera;
- mCameraId = cameraId;
- mCapabilities = capabilities;
- }
-
- @Override
- public android.hardware.Camera getCamera() {
- return mCamera;
- }
-
- @Override
- public int getCameraId() {
- return mCameraId;
- }
-
- @Override
- public CameraCapabilities getCapabilities() {
- return new AndroidCameraCapabilities(mCapabilities);
- }
-
- @Override
- public void reconnect(final Handler handler, final CameraOpenCallback cb) {
- mDispatchThread.runJob(new Runnable() {
- @Override
- public void run() {
- mCameraHandler.obtainMessage(CameraActions.RECONNECT, mCameraId, 0,
- CameraOpenCallbackForward.getNewInstance(handler, cb)).sendToTarget();
- }
- });
- }
-
- @Override
- public void unlock() {
- final WaitDoneBundle bundle = new WaitDoneBundle();
- mDispatchThread.runJobSync(new Runnable() {
- @Override
- public void run() {
- mCameraHandler.sendEmptyMessage(CameraActions.UNLOCK);
- mCameraHandler.post(bundle.mUnlockRunnable);
- }
- }, bundle.mWaitLock, CAMERA_OPERATION_TIMEOUT_MS, "camera unlock");
- }
-
- @Override
- public void lock() {
- mDispatchThread.runJob(new Runnable() {
- @Override
- public void run() {
- mCameraHandler.sendEmptyMessage(CameraActions.LOCK);
- }
- });
- }
-
- @Override
- public void setPreviewTexture(final SurfaceTexture surfaceTexture) {
- mDispatchThread.runJob(new Runnable() {
- @Override
- public void run() {
- mCameraHandler
- .obtainMessage(CameraActions.SET_PREVIEW_TEXTURE_ASYNC, surfaceTexture)
- .sendToTarget();
- }
- });
- }
-
- @Override
- public void setPreviewTextureSync(final SurfaceTexture surfaceTexture) {
- final WaitDoneBundle bundle = new WaitDoneBundle();
- mDispatchThread.runJobSync(new Runnable() {
- @Override
- public void run() {
- mCameraHandler
- .obtainMessage(CameraActions.SET_PREVIEW_TEXTURE_ASYNC, surfaceTexture)
- .sendToTarget();
- mCameraHandler.post(bundle.mUnlockRunnable);
- }
- }, bundle.mWaitLock, CAMERA_OPERATION_TIMEOUT_MS, "set preview texture");
- }
-
- @Override
- public void setPreviewDisplay(final SurfaceHolder surfaceHolder) {
- mDispatchThread.runJob(new Runnable() {
- @Override
- public void run() {
- mCameraHandler
- .obtainMessage(CameraActions.SET_PREVIEW_DISPLAY_ASYNC, surfaceHolder)
- .sendToTarget();
- }
- });
- }
-
- @Override
- public void startPreview() {
- mDispatchThread.runJob(new Runnable() {
- @Override
- public void run() {
- mCameraHandler
- .obtainMessage(CameraActions.START_PREVIEW_ASYNC, null).sendToTarget();
- }
- });
- }
-
- @Override
- public void startPreviewWithCallback(final Handler handler,
- final CameraStartPreviewCallback cb) {
- mDispatchThread.runJob(new Runnable() {
- @Override
- public void run() {
- mCameraHandler.obtainMessage(CameraActions.START_PREVIEW_ASYNC,
- CameraStartPreviewCallbackForward.getNewInstance(handler, cb)).sendToTarget();
- }
- });
- }
-
- @Override
- public void stopPreview() {
- final WaitDoneBundle bundle = new WaitDoneBundle();
- mDispatchThread.runJobSync(new Runnable() {
- @Override
- public void run() {
- mCameraHandler.sendEmptyMessage(CameraActions.STOP_PREVIEW);
- mCameraHandler.post(bundle.mUnlockRunnable);
- }
- }, bundle.mWaitLock, CAMERA_OPERATION_TIMEOUT_MS, "stop preview");
- }
-
- @Override
- public void setPreviewDataCallback(
- final Handler handler, final CameraPreviewDataCallback cb) {
- mDispatchThread.runJob(new Runnable() {
- @Override
- public void run() {
- mCameraHandler.obtainMessage(CameraActions.SET_PREVIEW_CALLBACK,
- PreviewCallbackForward.getNewInstance(
- handler, AndroidCameraProxyImpl.this, cb))
- .sendToTarget();
- }
- });
- }
- @Override
- public void setOneShotPreviewCallback(final Handler handler,
- final CameraPreviewDataCallback cb) {
- mDispatchThread.runJob(new Runnable() {
- @Override
- public void run() {
- mCameraHandler.obtainMessage(CameraActions.SET_ONE_SHOT_PREVIEW_CALLBACK,
- PreviewCallbackForward
- .getNewInstance(handler, AndroidCameraProxyImpl.this, cb))
- .sendToTarget();
- }
- });
- }
-
- @Override
- public void setPreviewDataCallbackWithBuffer(
- final Handler handler, final CameraPreviewDataCallback cb) {
- mDispatchThread.runJob(new Runnable() {
- @Override
- public void run() {
- mCameraHandler.obtainMessage(CameraActions.SET_PREVIEW_CALLBACK_WITH_BUFFER,
- PreviewCallbackForward
- .getNewInstance(handler, AndroidCameraProxyImpl.this, cb))
- .sendToTarget();
- }
- });
- }
-
- @Override
- public void addCallbackBuffer(final byte[] callbackBuffer) {
- mDispatchThread.runJob(new Runnable() {
- @Override
- public void run() {
- mCameraHandler.obtainMessage(CameraActions.ADD_CALLBACK_BUFFER, callbackBuffer)
- .sendToTarget();
- }
- });
- }
-
- @Override
- public void autoFocus(final Handler handler, final CameraAFCallback cb) {
- final AutoFocusCallback afCallback = new AutoFocusCallback() {
- @Override
- public void onAutoFocus(final boolean b, Camera camera) {
- if (mCameraState.getState() != CameraStateHolder.CAMERA_FOCUSING) {
- Log.w(TAG, "onAutoFocus callback returning when not focusing");
- } else {
- mCameraState.setState(CameraStateHolder.CAMERA_IDLE);
- }
- handler.post(new Runnable() {
- @Override
- public void run() {
- cb.onAutoFocus(b, AndroidCameraProxyImpl.this);
- }
- });
- }
- };
- mDispatchThread.runJob(new Runnable() {
- @Override
- public void run() {
- mCameraState.waitForStates(CameraStateHolder.CAMERA_IDLE);
- mCameraHandler.obtainMessage(CameraActions.AUTO_FOCUS, afCallback)
- .sendToTarget();
- }
- });
- }
-
- @Override
- public void cancelAutoFocus() {
- mDispatchThread.runJob(new Runnable() {
- @Override
- public void run() {
- mCameraHandler.removeMessages(CameraActions.AUTO_FOCUS);
- mCameraHandler.sendEmptyMessage(CameraActions.CANCEL_AUTO_FOCUS);
- }
- });
- }
-
- @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
- @Override
- public void setAutoFocusMoveCallback(
- final Handler handler, final CameraAFMoveCallback cb) {
- mDispatchThread.runJob(new Runnable() {
- @Override
- public void run() {
- mCameraHandler.obtainMessage(CameraActions.SET_AUTO_FOCUS_MOVE_CALLBACK,
- AFMoveCallbackForward.getNewInstance(
- handler, AndroidCameraProxyImpl.this, cb))
- .sendToTarget();
- }
- });
- }
-
- @Override
- public void takePicture(
- final Handler handler, final CameraShutterCallback shutter,
- final CameraPictureCallback raw, final CameraPictureCallback post,
- final CameraPictureCallback jpeg) {
- final PictureCallback jpegCallback = new PictureCallback() {
- @Override
- public void onPictureTaken(final byte[] data, Camera camera) {
- if (mCameraState.getState() != CameraStateHolder.CAMERA_CAPTURING) {
- Log.w(TAG, "picture callback returning when not capturing");
- } else {
- mCameraState.setState(CameraStateHolder.CAMERA_IDLE);
- }
- handler.post(new Runnable() {
- @Override
- public void run() {
- jpeg.onPictureTaken(data, AndroidCameraProxyImpl.this);
- }
- });
- }
- };
-
- mDispatchThread.runJob(new Runnable() {
- @Override
- public void run() {
- mCameraState.waitForStates(
- CameraStateHolder.CAMERA_IDLE | CameraStateHolder.CAMERA_UNLOCKED);
- mCameraHandler.requestTakePicture(ShutterCallbackForward
- .getNewInstance(handler, AndroidCameraProxyImpl.this, shutter),
- PictureCallbackForward
- .getNewInstance(handler, AndroidCameraProxyImpl.this, raw),
- PictureCallbackForward
- .getNewInstance(handler, AndroidCameraProxyImpl.this, post),
- jpegCallback
- );
- }
- });
- }
-
- @Override
- public void setDisplayOrientation(final int degrees) {
- mDispatchThread.runJob(new Runnable() {
- @Override
- public void run() {
- mCameraHandler.obtainMessage(CameraActions.SET_DISPLAY_ORIENTATION, degrees, 0)
- .sendToTarget();
- }
- });
- }
-
- @Override
- public void setZoomChangeListener(final OnZoomChangeListener listener) {
- mDispatchThread.runJob(new Runnable() {
- @Override
- public void run() {
- mCameraHandler.obtainMessage(CameraActions.SET_ZOOM_CHANGE_LISTENER, listener)
- .sendToTarget();
- }
- });
- }
-
- @Override
- public void setFaceDetectionCallback(final Handler handler,
- final CameraFaceDetectionCallback cb) {
- mDispatchThread.runJob(new Runnable() {
- @Override
- public void run() {
- mCameraHandler.obtainMessage(CameraActions.SET_FACE_DETECTION_LISTENER,
- FaceDetectionCallbackForward
- .getNewInstance(handler, AndroidCameraProxyImpl.this, cb))
- .sendToTarget();
- }
- });
- }
-
- @Override
- public void startFaceDetection() {
- mDispatchThread.runJob(new Runnable() {
- @Override
- public void run() {
- mCameraHandler.sendEmptyMessage(CameraActions.START_FACE_DETECTION);
- }
- });
- }
-
- @Override
- public void stopFaceDetection() {
- mDispatchThread.runJob(new Runnable() {
- @Override
- public void run() {
- mCameraHandler.sendEmptyMessage(CameraActions.STOP_FACE_DETECTION);
- }
- });
- }
-
- @Override
- public void setErrorCallback(final Handler handler, final CameraErrorCallback cb) {
- mDispatchThread.runJob(new Runnable() {
- @Override
- public void run() {
- mCameraHandler.obtainMessage(CameraActions.SET_ERROR_CALLBACK,
- ErrorCallbackForward.getNewInstance(
- handler, AndroidCameraProxyImpl.this, cb))
- .sendToTarget();
- }
- });
- }
-
- @Override
- public void setParameters(final Parameters params) {
- if (params == null) {
- Log.v(TAG, "null parameters in setParameters()");
- return;
- }
- final String flattenedParameters = params.flatten();
- mDispatchThread.runJob(new Runnable() {
- @Override
- public void run() {
- mCameraState.waitForStates(
- CameraStateHolder.CAMERA_IDLE | CameraStateHolder.CAMERA_UNLOCKED);
- mCameraHandler.obtainMessage(CameraActions.SET_PARAMETERS, flattenedParameters)
- .sendToTarget();
- }
- });
- }
-
- @Override
- public Parameters getParameters() {
- final WaitDoneBundle bundle = new WaitDoneBundle();
- mDispatchThread.runJobSync(new Runnable() {
- @Override
- public void run() {
- mCameraHandler.sendEmptyMessage(CameraActions.GET_PARAMETERS);
- mCameraHandler.post(bundle.mUnlockRunnable);
- }
- }, bundle.mWaitLock, CAMERA_OPERATION_TIMEOUT_MS, "get parameters");
- return mParameters;
- }
-
- @Override
- public CameraSettings getSettings() {
- return new AndroidCameraSettings(mCapabilities, getParameters());
- }
-
- @Override
- public boolean applySettings(final CameraSettings settings) {
- if (settings == null) {
- Log.v(TAG, "null parameters in applySettings()");
- return false;
- }
- if (!mCapabilities.supports(settings)) {
- return false;
- }
-
- final CameraSettings copyOfSettings = new CameraSettings(settings);
- mDispatchThread.runJob(new Runnable() {
- @Override
- public void run() {
- mCameraState.waitForStates(
- CameraStateHolder.CAMERA_IDLE | CameraStateHolder.CAMERA_UNLOCKED);
- mCameraHandler.obtainMessage(CameraActions.APPLY_SETTINGS, copyOfSettings)
- .sendToTarget();
- }
- });
- return true;
- }
-
- @Override
- public void refreshSettings() {
- mDispatchThread.runJob(new Runnable() {
- @Override
- public void run() {
- mCameraHandler.sendEmptyMessage(CameraActions.REFRESH_PARAMETERS);
- }
- });
- }
-
- @Override
- public void enableShutterSound(final boolean enable) {
- mDispatchThread.runJob(new Runnable() {
- @Override
- public void run() {
- mCameraHandler
- .obtainMessage(CameraActions.ENABLE_SHUTTER_SOUND, (enable ? 1 : 0), 0)
- .sendToTarget();
- }
- });
- }
- }
-
- private static class WaitDoneBundle {
- public Runnable mUnlockRunnable;
- private final Object mWaitLock;
-
- WaitDoneBundle() {
- mWaitLock = new Object();
- mUnlockRunnable = new Runnable() {
- @Override
- public void run() {
- synchronized (mWaitLock) {
- mWaitLock.notifyAll();
- }
- }
- };
- }
- }
-
- /**
- * A helper class to forward AutoFocusCallback to another thread.
- */
- private static class AFCallbackForward implements AutoFocusCallback {
- private final Handler mHandler;
- private final CameraProxy mCamera;
- private final CameraAFCallback mCallback;
-
- /**
- * Returns a new instance of {@link AFCallbackForward}.
- *
- * @param handler The handler in which the callback will be invoked in.
- * @param camera The {@link CameraProxy} which the callback is from.
- * @param cb The callback to be invoked.
- * @return The instance of the {@link AFCallbackForward},
- * or null if any parameter is null.
- */
- public static AFCallbackForward getNewInstance(
- Handler handler, CameraProxy camera, CameraAFCallback cb) {
- if (handler == null || camera == null || cb == null) {
- return null;
- }
- return new AFCallbackForward(handler, camera, cb);
- }
-
- private AFCallbackForward(
- Handler h, CameraProxy camera, CameraAFCallback cb) {
- mHandler = h;
- mCamera = camera;
- mCallback = cb;
- }
-
- @Override
- public void onAutoFocus(final boolean b, Camera camera) {
- mHandler.post(new Runnable() {
- @Override
- public void run() {
- mCallback.onAutoFocus(b, mCamera);
- }
- });
- }
- }
-
- /**
- * A helper class to forward ErrorCallback to another thread.
- */
- private static class ErrorCallbackForward implements Camera.ErrorCallback {
- private final Handler mHandler;
- private final CameraProxy mCamera;
- private final CameraErrorCallback mCallback;
-
- /**
- * Returns a new instance of {@link AFCallbackForward}.
- *
- * @param handler The handler in which the callback will be invoked in.
- * @param camera The {@link CameraProxy} which the callback is from.
- * @param cb The callback to be invoked.
- * @return The instance of the {@link AFCallbackForward},
- * or null if any parameter is null.
- */
- public static ErrorCallbackForward getNewInstance(
- Handler handler, CameraProxy camera, CameraErrorCallback cb) {
- if (handler == null || camera == null || cb == null) {
- return null;
- }
- return new ErrorCallbackForward(handler, camera, cb);
- }
-
- private ErrorCallbackForward(
- Handler h, CameraProxy camera, CameraErrorCallback cb) {
- mHandler = h;
- mCamera = camera;
- mCallback = cb;
- }
-
- @Override
- public void onError(final int error, Camera camera) {
- mHandler.post(new Runnable() {
- @Override
- public void run() {
- mCallback.onError(error, mCamera);
- }
- });
- }
- }
-
- /** A helper class to forward AutoFocusMoveCallback to another thread. */
- @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
- private static class AFMoveCallbackForward implements AutoFocusMoveCallback {
- private final Handler mHandler;
- private final CameraAFMoveCallback mCallback;
- private final CameraProxy mCamera;
-
- /**
- * Returns a new instance of {@link AFMoveCallbackForward}.
- *
- * @param handler The handler in which the callback will be invoked in.
- * @param camera The {@link CameraProxy} which the callback is from.
- * @param cb The callback to be invoked.
- * @return The instance of the {@link AFMoveCallbackForward},
- * or null if any parameter is null.
- */
- public static AFMoveCallbackForward getNewInstance(
- Handler handler, CameraProxy camera, CameraAFMoveCallback cb) {
- if (handler == null || camera == null || cb == null) {
- return null;
- }
- return new AFMoveCallbackForward(handler, camera, cb);
- }
-
- private AFMoveCallbackForward(
- Handler h, CameraProxy camera, CameraAFMoveCallback cb) {
- mHandler = h;
- mCamera = camera;
- mCallback = cb;
- }
-
- @Override
- public void onAutoFocusMoving(
- final boolean moving, android.hardware.Camera camera) {
- mHandler.post(new Runnable() {
- @Override
- public void run() {
- mCallback.onAutoFocusMoving(moving, mCamera);
- }
- });
- }
- }
-
- /**
- * A helper class to forward ShutterCallback to to another thread.
- */
- private static class ShutterCallbackForward implements ShutterCallback {
- private final Handler mHandler;
- private final CameraShutterCallback mCallback;
- private final CameraProxy mCamera;
-
- /**
- * Returns a new instance of {@link ShutterCallbackForward}.
- *
- * @param handler The handler in which the callback will be invoked in.
- * @param camera The {@link CameraProxy} which the callback is from.
- * @param cb The callback to be invoked.
- * @return The instance of the {@link ShutterCallbackForward},
- * or null if any parameter is null.
- */
- public static ShutterCallbackForward getNewInstance(
- Handler handler, CameraProxy camera, CameraShutterCallback cb) {
- if (handler == null || camera == null || cb == null) {
- return null;
- }
- return new ShutterCallbackForward(handler, camera, cb);
- }
-
- private ShutterCallbackForward(
- Handler h, CameraProxy camera, CameraShutterCallback cb) {
- mHandler = h;
- mCamera = camera;
- mCallback = cb;
- }
-
- @Override
- public void onShutter() {
- mHandler.post(new Runnable() {
- @Override
- public void run() {
- mCallback.onShutter(mCamera);
- }
- });
- }
- }
-
- /**
- * A helper class to forward PictureCallback to another thread.
- */
- private static class PictureCallbackForward implements PictureCallback {
- private final Handler mHandler;
- private final CameraPictureCallback mCallback;
- private final CameraProxy mCamera;
-
- /**
- * Returns a new instance of {@link PictureCallbackForward}.
- *
- * @param handler The handler in which the callback will be invoked in.
- * @param camera The {@link CameraProxy} which the callback is from.
- * @param cb The callback to be invoked.
- * @return The instance of the {@link PictureCallbackForward},
- * or null if any parameters is null.
- */
- public static PictureCallbackForward getNewInstance(
- Handler handler, CameraProxy camera, CameraPictureCallback cb) {
- if (handler == null || camera == null || cb == null) {
- return null;
- }
- return new PictureCallbackForward(handler, camera, cb);
- }
-
- private PictureCallbackForward(
- Handler h, CameraProxy camera, CameraPictureCallback cb) {
- mHandler = h;
- mCamera = camera;
- mCallback = cb;
- }
-
- @Override
- public void onPictureTaken(
- final byte[] data, android.hardware.Camera camera) {
- mHandler.post(new Runnable() {
- @Override
- public void run() {
- mCallback.onPictureTaken(data, mCamera);
- }
- });
- }
- }
-
- /**
- * A helper class to forward PreviewCallback to another thread.
- */
- private static class PreviewCallbackForward implements PreviewCallback {
- private final Handler mHandler;
- private final CameraPreviewDataCallback mCallback;
- private final CameraProxy mCamera;
-
- /**
- * Returns a new instance of {@link PreviewCallbackForward}.
- *
- * @param handler The handler in which the callback will be invoked in.
- * @param camera The {@link CameraProxy} which the callback is from.
- * @param cb The callback to be invoked.
- * @return The instance of the {@link PreviewCallbackForward},
- * or null if any parameters is null.
- */
- public static PreviewCallbackForward getNewInstance(
- Handler handler, CameraProxy camera, CameraPreviewDataCallback cb) {
- if (handler == null || camera == null || cb == null) {
- return null;
- }
- return new PreviewCallbackForward(handler, camera, cb);
- }
-
- private PreviewCallbackForward(
- Handler h, CameraProxy camera, CameraPreviewDataCallback cb) {
- mHandler = h;
- mCamera = camera;
- mCallback = cb;
- }
-
- @Override
- public void onPreviewFrame(
- final byte[] data, android.hardware.Camera camera) {
- mHandler.post(new Runnable() {
- @Override
- public void run() {
- mCallback.onPreviewFrame(data, mCamera);
- }
- });
- }
- }
-
- private static class FaceDetectionCallbackForward implements FaceDetectionListener {
- private final Handler mHandler;
- private final CameraFaceDetectionCallback mCallback;
- private final CameraProxy mCamera;
-
- /**
- * Returns a new instance of {@link FaceDetectionCallbackForward}.
- *
- * @param handler The handler in which the callback will be invoked in.
- * @param camera The {@link CameraProxy} which the callback is from.
- * @param cb The callback to be invoked.
- * @return The instance of the {@link FaceDetectionCallbackForward},
- * or null if any parameter is null.
- */
- public static FaceDetectionCallbackForward getNewInstance(
- Handler handler, CameraProxy camera, CameraFaceDetectionCallback cb) {
- if (handler == null || camera == null || cb == null) {
- return null;
- }
- return new FaceDetectionCallbackForward(handler, camera, cb);
- }
-
- private FaceDetectionCallbackForward(
- Handler h, CameraProxy camera, CameraFaceDetectionCallback cb) {
- mHandler = h;
- mCamera = camera;
- mCallback = cb;
- }
-
- @Override
- public void onFaceDetection(
- final Camera.Face[] faces, Camera camera) {
- mHandler.post(new Runnable() {
- @Override
- public void run() {
- mCallback.onFaceDetection(faces, mCamera);
- }
- });
- }
- }
-}
diff --git a/src/com/android/camera/cameradevice/AndroidCameraSettings.java b/src/com/android/camera/cameradevice/AndroidCameraSettings.java
deleted file mode 100644
index 43a844d75..000000000
--- a/src/com/android/camera/cameradevice/AndroidCameraSettings.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package com.android.camera.cameradevice;
-
-import android.hardware.Camera;
-
-/**
- * Created by shkong on 6/2/14.
- */
-public class AndroidCameraSettings extends CameraSettings {
-
- public AndroidCameraSettings(CameraCapabilities capabilities, Camera.Parameters params) {
- CameraCapabilities.Stringifier stringifier = capabilities.getStringifier();
-
- // Preview
- Camera.Size paramPreviewSize = params.getPreviewSize();
- setPreviewSize(new Size(paramPreviewSize.width, paramPreviewSize.height));
- setPreviewFrameRate(params.getPreviewFrameRate());
- int[] previewFpsRange = new int[2];
- params.getPreviewFpsRange(previewFpsRange);
- setPreviewFpsRange(previewFpsRange[Camera.Parameters.PREVIEW_FPS_MIN_INDEX],
- previewFpsRange[Camera.Parameters.PREVIEW_FPS_MAX_INDEX]);
-
-
- // Capture: Focus, flash, zoom, exposure, scene mode.
- if (capabilities.supports(CameraCapabilities.Feature.ZOOM)) {
- setZoomRatio(params.getZoomRatios().get(params.getZoom()) / 100f);
- setZoomIndex(params.getZoom());
- } else {
- setZoomRatio(1.0f);
- setZoomIndex(0);
- }
- setExposureCompensationIndex(params.getExposureCompensation());
- setFlashMode(stringifier.flashModeFromString(params.getFlashMode()));
- setFocusMode(stringifier.focusModeFromString(params.getFocusMode()));
- setSceneMode(stringifier.sceneModeFromString(params.getSceneMode()));
-
- // Video capture.
- if (capabilities.supports(CameraCapabilities.Feature.VIDEO_STABILIZATION)) {
- setVideoStabilization(isVideoStabilizationEnabled());
- }
-
- // Output: Photo size, compression quality, rotation.
- setPhotoRotationDegrees(0f);
- setPhotoJpegCompressionQuality(params.getJpegQuality());
- Camera.Size paramPictureSize = params.getPictureSize();
- setPhotoSize(new Size(paramPictureSize.width, paramPictureSize.height));
- }
-}
diff --git a/src/com/android/camera/cameradevice/CameraActions.java b/src/com/android/camera/cameradevice/CameraActions.java
deleted file mode 100644
index ce0961b22..000000000
--- a/src/com/android/camera/cameradevice/CameraActions.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"),
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.camera.cameradevice;
-
-class CameraActions {
- // Camera initialization/finalization
- public static final int OPEN_CAMERA = 1;
- public static final int RELEASE = 2;
- public static final int RECONNECT = 3;
- public static final int UNLOCK = 4;
- public static final int LOCK = 5;
- // Preview
- public static final int SET_PREVIEW_TEXTURE_ASYNC = 101;
- public static final int START_PREVIEW_ASYNC = 102;
- public static final int STOP_PREVIEW = 103;
- public static final int SET_PREVIEW_CALLBACK_WITH_BUFFER = 104;
- public static final int ADD_CALLBACK_BUFFER = 105;
- public static final int SET_PREVIEW_DISPLAY_ASYNC = 106;
- public static final int SET_PREVIEW_CALLBACK = 107;
- public static final int SET_ONE_SHOT_PREVIEW_CALLBACK = 108;
- // Parameters
- public static final int SET_PARAMETERS = 201;
- public static final int GET_PARAMETERS = 202;
- public static final int REFRESH_PARAMETERS = 203;
- public static final int APPLY_SETTINGS = 204;
- // Focus, Zoom
- public static final int AUTO_FOCUS = 301;
- public static final int CANCEL_AUTO_FOCUS = 302;
- public static final int SET_AUTO_FOCUS_MOVE_CALLBACK = 303;
- public static final int SET_ZOOM_CHANGE_LISTENER = 304;
- // Face detection
- public static final int SET_FACE_DETECTION_LISTENER = 461;
- public static final int START_FACE_DETECTION = 462;
- public static final int STOP_FACE_DETECTION = 463;
- public static final int SET_ERROR_CALLBACK = 464;
- // Presentation
- public static final int ENABLE_SHUTTER_SOUND = 501;
- public static final int SET_DISPLAY_ORIENTATION = 502;
- // Capture
- public static final int CAPTURE_PHOTO = 601;
-}
diff --git a/src/com/android/camera/cameradevice/CameraCapabilities.java b/src/com/android/camera/cameradevice/CameraCapabilities.java
deleted file mode 100644
index 423d42f6f..000000000
--- a/src/com/android/camera/cameradevice/CameraCapabilities.java
+++ /dev/null
@@ -1,681 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.camera.cameradevice;
-
-import com.android.camera.debug.Log;
-
-import java.util.ArrayList;
-import java.util.EnumSet;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.TreeSet;
-
-/**
- * This class holds all the static information of a camera's capabilities.
- * <p>
- * The design of this class is thread-safe and can be passed around regardless
- * of which thread using it.
- * </p>
- */
-public class CameraCapabilities {
-
- private static Log.Tag TAG = new Log.Tag("CamCapabilities");
-
- /* All internal states are declared final and should be thread-safe. */
-
- protected final ArrayList<int[]> mSupportedPreviewFpsRange = new ArrayList<int[]>();
- protected final ArrayList<Size> mSupportedPreviewSizes = new ArrayList<Size>();
- protected final TreeSet<Integer> mSupportedPreviewFormats = new TreeSet<Integer>();
- protected final ArrayList<Size> mSupportedVideoSizes = new ArrayList<Size>();
- protected final ArrayList<Size> mSupportedPhotoSizes = new ArrayList<Size>();
- protected final TreeSet<Integer> mSupportedPhotoFormats = new TreeSet<Integer>();
- protected final EnumSet<SceneMode> mSupportedSceneModes = EnumSet.noneOf(SceneMode.class);
- protected final EnumSet<FlashMode> mSupportedFlashModes = EnumSet.noneOf(FlashMode.class);
- protected final EnumSet<FocusMode> mSupportedFocusModes = EnumSet.noneOf(FocusMode.class);
- protected final EnumSet<WhiteBalance> mSupportedWhiteBalances =
- EnumSet.noneOf(WhiteBalance.class);
- protected final EnumSet<Feature> mSupportedFeatures = EnumSet.noneOf(Feature.class);
- protected Size mPreferredPreviewSizeForVideo;
- protected int mMinExposureCompensation;
- protected int mMaxExposureCompensation;
- protected float mExposureCompensationStep;
- protected int mMaxNumOfFacesSupported;
- protected int mMaxNumOfFocusAreas;
- protected int mMaxNumOfMeteringArea;
- protected int mMaxZoomRatio;
- private final Stringifier mStringifier;
- protected final ArrayList<Integer> mZoomRatioList = new ArrayList<Integer>();
- protected int mMaxZoomIndex;
-
- /**
- * Focus modes.
- */
- public enum FocusMode {
- /**
- * Continuous auto focus mode intended for taking pictures.
- * @see {@link android.hardware.Camera.Parameters#FOCUS_MODE_AUTO}.
- */
- AUTO,
- /**
- * Continuous auto focus mode intended for taking pictures.
- * @see {@link android.hardware.Camera.Parameters#FOCUS_MODE_CONTINUOUS_PICTURE}.
- */
- CONTINUOUS_PICTURE,
- /**
- * Continuous auto focus mode intended for video recording.
- * @see {@link android.hardware.Camera.Parameters#FOCUS_MODE_CONTINUOUS_VIDEO}.
- */
- CONTINUOUS_VIDEO,
- /**
- * Extended depth of field (EDOF).
- * @see {@link android.hardware.Camera.Parameters#FOCUS_MODE_EDOF}.
- */
- EXTENDED_DOF,
- /**
- * Focus is fixed.
- * @see {@link android.hardware.Camera.Parameters#FOCUS_MODE_FIXED}.
- */
- FIXED,
- /**
- * Focus is set at infinity.
- * @see {@link android.hardware.Camera.Parameters#FOCUS_MODE_INFINITY}.
- */
- INFINITY,
- /**
- * Macro (close-up) focus mode.
- * @see {@link android.hardware.Camera.Parameters#FOCUS_MODE_MACRO}.
- */
- MACRO,
- }
-
- /**
- * Flash modes.
- */
- public enum FlashMode {
- /**
- * No flash.
- */
- NO_FLASH,
- /**
- * Flash will be fired automatically when required.
- * @see {@link android.hardware.Camera.Parameters#FLASH_MODE_OFF}.
- */
- AUTO,
- /**
- * Flash will not be fired.
- * @see {@link android.hardware.Camera.Parameters#FLASH_MODE_OFF}.
- */
- OFF,
- /**
- * Flash will always be fired during snapshot.
- * @see {@link android.hardware.Camera.Parameters#FLASH_MODE_ON}.
- */
- ON,
- /**
- * Constant emission of light during preview, auto-focus and snapshot.
- * @see {@link android.hardware.Camera.Parameters#FLASH_MODE_TORCH}.
- */
- TORCH,
- /**
- * Flash will be fired in red-eye reduction mode.
- * @see {@link android.hardware.Camera.Parameters#FLASH_MODE_RED_EYE}.
- */
- RED_EYE,
- }
-
- /**
- * Scene modes.
- */
- public enum SceneMode {
- /**
- * No supported scene mode.
- */
- NO_SCENE_MODE,
- /**
- * Scene mode is off.
- * @see {@link android.hardware.Camera.Parameters#SCENE_MODE_AUTO}.
- */
- AUTO,
- /**
- * Take photos of fast moving objects.
- * @see {@link android.hardware.Camera.Parameters#SCENE_MODE_ACTION}.
- */
- ACTION,
- /**
- * Applications are looking for a barcode.
- * @see {@link android.hardware.Camera.Parameters#SCENE_MODE_BARCODE}.
- */
- BARCODE,
- /**
- * Take pictures on the beach.
- * @see {@link android.hardware.Camera.Parameters#SCENE_MODE_BEACH}.
- */
- BEACH,
- /**
- * Capture the naturally warm color of scenes lit by candles.
- * @see {@link android.hardware.Camera.Parameters#SCENE_MODE_CANDLELIGHT}.
- */
- CANDLELIGHT,
- /**
- * For shooting firework displays.
- * @see {@link android.hardware.Camera.Parameters#SCENE_MODE_FIREWORKS}.
- */
- FIREWORKS,
- /**
- * Capture a scene using high dynamic range imaging techniques.
- * @see {@link android.hardware.Camera.Parameters#SCENE_MODE_HDR}.
- */
- HDR,
- /**
- * Take pictures on distant objects.
- * @see {@link android.hardware.Camera.Parameters#SCENE_MODE_LANDSCAPE}.
- */
- LANDSCAPE,
- /**
- * Take photos at night.
- * @see {@link android.hardware.Camera.Parameters#SCENE_MODE_NIGHT}.
- */
- NIGHT,
- /**
- * Take people pictures at night.
- * @see {@link android.hardware.Camera.Parameters#SCENE_MODE_NIGHT_PORTRAIT}.
- */
- NIGHT_PORTRAIT,
- /**
- * Take indoor low-light shot.
- * @see {@link android.hardware.Camera.Parameters#SCENE_MODE_PARTY}.
- */
- PARTY,
- /**
- * Take people pictures.
- * @see {@link android.hardware.Camera.Parameters#SCENE_MODE_PORTRAIT}.
- */
- PORTRAIT,
- /**
- * Take pictures on the snow.
- * @see {@link android.hardware.Camera.Parameters#SCENE_MODE_SNOW}.
- */
- SNOW,
- /**
- * Take photos of fast moving objects.
- * @see {@link android.hardware.Camera.Parameters#SCENE_MODE_SPORTS}.
- */
- SPORTS,
- /**
- * Avoid blurry pictures (for example, due to hand shake).
- * @see {@link android.hardware.Camera.Parameters#SCENE_MODE_STEADYPHOTO}.
- */
- STEADYPHOTO,
- /**
- * Take sunset photos.
- * @see {@link android.hardware.Camera.Parameters#SCENE_MODE_SUNSET}.
- */
- SUNSET,
- /**
- * Take photos in a theater.
- * @see {@link android.hardware.Camera.Parameters#SCENE_MODE_THEATRE}.
- */
- THEATRE,
- }
-
- /**
- * White blances.
- */
- public enum WhiteBalance {
- /**
- * @see {@link android.hardware.Camera.Parameters#WHITE_BALANCE_AUTO}.
- */
- AUTO,
- /**
- * @see {@link android.hardware.Camera.Parameters#WHITE_BALANCE_CLOUDY_DAYLIGHT}.
- */
- CLOUDY_DAYLIGHT,
- /**
- * @see {@link android.hardware.Camera.Parameters#WHITE_BALANCE_DAYLIGHT}.
- */
- DAYLIGHT,
- /**
- * @see {@link android.hardware.Camera.Parameters#WHITE_BALANCE_FLUORESCENT}.
- */
- FLUORESCENT,
- /**
- * @see {@link android.hardware.Camera.Parameters#WHITE_BALANCE_INCANDESCENT}.
- */
- INCANDESCENT,
- /**
- * @see {@link android.hardware.Camera.Parameters#WHITE_BALANCE_SHADE}.
- */
- SHADE,
- /**
- * @see {@link android.hardware.Camera.Parameters#WHITE_BALANCE_TWILIGHT}.
- */
- TWILIGHT,
- /**
- * @see {@link android.hardware.Camera.Parameters#WHITE_BALANCE_WARM_FLUORESCENT}.
- */
- WARM_FLUORESCENT,
- }
-
- /**
- * Features.
- */
- public enum Feature {
- /**
- * Support zoom-related methods.
- */
- ZOOM,
- /**
- * Support for photo capturing during video recording.
- */
- VIDEO_SNAPSHOT,
- /**
- * Support for focus area settings.
- */
- FOCUS_AREA,
- /**
- * Support for metering area settings.
- */
- METERING_AREA,
- /**
- * Support for automatic exposure lock.
- */
- AUTO_EXPOSURE_LOCK,
- /**
- * Support for automatic white balance lock.
- */
- AUTO_WHITE_BALANCE_LOCK,
- /**
- * Support for video stabilization.
- */
- VIDEO_STABILIZATION,
- }
-
- /**
- * A interface stringifier to convert abstract representations to API
- * related string representation.
- */
- public interface Stringifier {
- /**
- * Converts the focus mode to API-related string representation.
- *
- * @param focus The focus mode to convert.
- * @return The string used by the camera framework API to represent the
- * focus mode.
- */
- String stringify(FocusMode focus);
-
- /**
- * Converts the API-related string representation of the focus mode to the
- * abstract representation.
- *
- * @param val The string representation.
- * @return The focus mode represented by the input string.
- */
- FocusMode focusModeFromString(String val);
-
- /**
- * Converts the flash mode to API-related string representation.
- *
- * @param flash The focus mode to convert.
- * @return The string used by the camera framework API to represent the
- * flash mode.
- */
- String stringify(FlashMode flash);
-
- /**
- * Converts the API-related string representation of the flash mode to the
- * abstract representation.
- *
- * @param val The string representation.
- * @return The flash mode represented by the input string. Can be
- * {@code null}.
- */
- FlashMode flashModeFromString(String val);
-
- /**
- * Converts the scene mode to API-related string representation.
- *
- * @param scene The focus mode to convert.
- * @return The string used by the camera framework API to represent the
- * scene mode.
- */
- String stringify(SceneMode scene);
-
- /**
- * Converts the API-related string representation of the scene mode to the
- * abstract representation.
- *
- * @param val The string representation.
- * @return The scene mode represented by the input string.
- */
- SceneMode sceneModeFromString(String val);
-
- /**
- * Converts the white balance to API-related string representation.
- *
- * @param wb The focus mode to convert.
- * @return The string used by the camera framework API to represent the
- * white balance.
- */
- String stringify(WhiteBalance wb);
-
- /**
- * Converts the API-related string representation of the white balance to
- * the abstract representation.
- *
- * @param val The string representation.
- * @return The white balance represented by the input string.
- */
- WhiteBalance whiteBalanceFromString(String val);
- }
-
- /**
- * Constructor.
- * @param stringifier The API-specific stringifier for this instance.
- */
- CameraCapabilities(Stringifier stringifier) {
- mStringifier = stringifier;
- }
-
- /**
- * Copy constructor.
- * @param src The source instance.
- */
- public CameraCapabilities(CameraCapabilities src) {
- mSupportedPreviewFpsRange.addAll(src.mSupportedPreviewFpsRange);
- mSupportedPreviewSizes.addAll(src.mSupportedPreviewSizes);
- mSupportedPreviewFormats.addAll(src.mSupportedPreviewFormats);
- mSupportedVideoSizes.addAll(src.mSupportedVideoSizes);
- mSupportedPhotoSizes.addAll(src.mSupportedPhotoSizes);
- mSupportedPhotoFormats.addAll(src.mSupportedPhotoFormats);
- mSupportedSceneModes.addAll(src.mSupportedSceneModes);
- mSupportedFlashModes.addAll(src.mSupportedFlashModes);
- mSupportedFocusModes.addAll(src.mSupportedFocusModes);
- mSupportedWhiteBalances.addAll(src.mSupportedWhiteBalances);
- mSupportedFeatures.addAll(src.mSupportedFeatures);
- mPreferredPreviewSizeForVideo = src.mPreferredPreviewSizeForVideo;
- mMaxExposureCompensation = src.mMaxExposureCompensation;
- mMinExposureCompensation = src.mMinExposureCompensation;
- mExposureCompensationStep = src.mExposureCompensationStep;
- mMaxNumOfFacesSupported = src.mMaxNumOfFacesSupported;
- mMaxNumOfFocusAreas = src.mMaxNumOfFocusAreas;
- mMaxNumOfMeteringArea = src.mMaxNumOfMeteringArea;
- mMaxZoomRatio = src.mMaxZoomRatio;
- mStringifier = src.mStringifier;
- }
-
- /**
- * @return the supported picture formats. See {@link android.graphics.ImageFormat}.
- */
- public Set<Integer> getSupportedPhotoFormats() {
- return new TreeSet<Integer>(mSupportedPhotoFormats);
- }
-
- /**
- * Gets the supported preview formats.
- * @return The supported preview {@link android.graphics.ImageFormat}s.
- */
- public Set<Integer> getSupportedPreviewFormats() {
- return new TreeSet<Integer>(mSupportedPreviewFormats);
- }
-
- /**
- * Gets the supported picture sizes.
- */
- public List<Size> getSupportedPhotoSizes() {
- return new ArrayList<Size>(mSupportedPhotoSizes);
- }
-
-
- /**
- * @return The supported preview fps (frame-per-second) ranges. The returned
- * list is sorted by maximum fps then minimum fps in a descending order.
- * The values are multiplied by 1000.
- */
- public final List<int[]> getSupportedPreviewFpsRange() {
- return new ArrayList<int[]>(mSupportedPreviewFpsRange);
- }
-
- /**
- * @return The supported preview sizes. The list is sorted by width then
- * height in a descending order.
- */
- public final List<Size> getSupportedPreviewSizes() {
- return new ArrayList<Size>(mSupportedPreviewSizes);
- }
-
- public final Size getPreferredPreviewSizeForVideo() {
- return new Size(mPreferredPreviewSizeForVideo);
- }
-
- /**
- * @return The supported video frame sizes that can be used by MediaRecorder.
- * The list is sorted by width then height in a descending order.
- */
- public final List<Size> getSupportedVideoSizes() {
- return new ArrayList<Size>(mSupportedVideoSizes);
- }
-
- /**
- * @return The supported scene modes.
- */
- public final Set<SceneMode> getSupportedSceneModes() {
- return new HashSet<SceneMode>(mSupportedSceneModes);
- }
-
- /**
- * @return Whether the scene mode is supported.
- */
- public final boolean supports(SceneMode scene) {
- return (scene != null && mSupportedSceneModes.contains(scene));
- }
-
- public boolean supports(final CameraSettings settings) {
- if (zoomCheck(settings) && exposureCheck(settings) && focusCheck(settings) &&
- flashCheck(settings) && photoSizeCheck(settings) && previewSizeCheck(settings) &&
- videoStabilizationCheck(settings)) {
- return true;
- }
- return false;
- }
-
- /**
- * @return The supported flash modes.
- */
- public final Set<FlashMode> getSupportedFlashModes() {
- return new HashSet<FlashMode>(mSupportedFlashModes);
- }
-
- /**
- * @return Whether the flash mode is supported.
- */
- public final boolean supports(FlashMode flash) {
- return (flash != null && mSupportedFlashModes.contains(flash));
- }
-
- /**
- * @return The supported focus modes.
- */
- public final Set<FocusMode> getSupportedFocusModes() {
- return new HashSet<FocusMode>(mSupportedFocusModes);
- }
-
- /**
- * @return Whether the focus mode is supported.
- */
- public final boolean supports(FocusMode focus) {
- return (focus != null && mSupportedFocusModes.contains(focus));
- }
-
- /**
- * @return The supported white balanceas.
- */
- public final Set<WhiteBalance> getSupportedWhiteBalance() {
- return new HashSet<WhiteBalance>(mSupportedWhiteBalances);
- }
-
- /**
- * @return Whether the white balance is supported.
- */
- public boolean supports(WhiteBalance wb) {
- return (wb != null && mSupportedWhiteBalances.contains(wb));
- }
-
- public final Set<Feature> getSupportedFeature() {
- return new HashSet<Feature>(mSupportedFeatures);
- }
-
- public boolean supports(Feature ft) {
- return (ft != null && mSupportedFeatures.contains(ft));
- }
-
- /**
- * @return The maximal supported zoom ratio.
- */
- public float getMaxZoomRatio() {
- return mMaxZoomRatio;
- }
-
- // We'll replace these old style methods with new ones.
- @Deprecated
- public int getMaxZoomIndex() {
- return mMaxZoomIndex;
- }
-
- @Deprecated
- public List<Integer> getZoomRatioList() {
- return new ArrayList<Integer>(mZoomRatioList);
- }
-
- /**
- * @return The min exposure compensation index. The EV is the compensation
- * index multiplied by the step value. If unsupported, both this method and
- * {@link #getMaxExposureCompensation()} return 0.
- */
- public final int getMinExposureCompensation() {
- return mMinExposureCompensation;
- }
-
- /**
- * @return The max exposure compensation index. The EV is the compensation
- * index multiplied by the step value. If unsupported, both this method and
- * {@link #getMinExposureCompensation()} return 0.
- */
- public final int getMaxExposureCompensation() {
- return mMaxExposureCompensation;
- }
-
- /**
- * @return The exposure compensation step. The EV is the compensation index
- * multiplied by the step value.
- */
- public final float getExposureCompensationStep() {
- return mExposureCompensationStep;
- }
-
- /**
- * @return The max number of faces supported by the face detection. 0 if
- * unsupported.
- */
- public final int getMaxNumOfFacesSupported() {
- return mMaxNumOfFacesSupported;
- }
-
- /**
- * @return The stringifier used by this instance.
- */
- public Stringifier getStringifier() {
- return mStringifier;
- }
-
- private boolean zoomCheck(final CameraSettings settings) {
- final float ratio = settings.getCurrentZoomRatio();
- final int index = settings.getCurrentZoomIndex();
- if (!supports(Feature.ZOOM)) {
- if (ratio != 1.0f || index != 0) {
- Log.v(TAG, "Zoom is not supported");
- return false;
- }
- } else {
- if (settings.getCurrentZoomRatio() > getMaxZoomRatio() ||
- index > getMaxZoomIndex()) {
- Log.v(TAG, "Zoom ratio is not supported: ratio = " +
- settings.getCurrentZoomRatio() + ", index = " + index);
- return false;
- }
- }
- return true;
- }
-
- private boolean exposureCheck(final CameraSettings settings) {
- final int index = settings.getExposureCompensationIndex();
- if (index > getMaxExposureCompensation() || index < getMinExposureCompensation()) {
- Log.v(TAG, "Exposure compensation index is not supported. Min = " +
- getMinExposureCompensation() + ", max = " + getMaxExposureCompensation() + "," +
- " setting = " + index);
- return false;
- }
- return true;
- }
-
- private boolean focusCheck(final CameraSettings settings) {
- FocusMode focusMode = settings.getCurrentFocusMode();
- if (!supports(focusMode)) {
- Log.v(TAG,
- "Focus mode not supported:" + (focusMode != null ? focusMode.name() : "null"));
- return false;
- }
- return true;
- }
-
- private boolean flashCheck(final CameraSettings settings) {
- FlashMode flashMode = settings.getCurrentFlashMode();
- if (!supports(flashMode)) {
- Log.v(TAG,
- "Flash mode not supported:" + (flashMode != null ? flashMode.name() : "null"));
- return false;
- }
- return true;
- }
-
- private boolean photoSizeCheck(final CameraSettings settings) {
- Size photoSize = settings.getCurrentPhotoSize();
- if (mSupportedPhotoSizes.contains(photoSize)) {
- return true;
- }
- Log.v(TAG, "Unsupported photo size:" + photoSize);
- return false;
- }
-
- private boolean previewSizeCheck(final CameraSettings settings) {
- final Size previewSize = settings.getCurrentPreviewSize();
- if (mSupportedPreviewSizes.contains(previewSize)) {
- return true;
- }
- Log.v(TAG, "Unsupported preview size:" + previewSize);
- return false;
- }
-
- private boolean videoStabilizationCheck(final CameraSettings settings) {
- if (!settings.isVideoStabilizationEnabled() || supports(Feature.VIDEO_STABILIZATION)) {
- return true;
- }
- Log.v(TAG, "Video stabilization is not supported");
- return false;
- }
-}
diff --git a/src/com/android/camera/cameradevice/CameraCapabilitiesFactory.java b/src/com/android/camera/cameradevice/CameraCapabilitiesFactory.java
deleted file mode 100644
index 0f461d8d1..000000000
--- a/src/com/android/camera/cameradevice/CameraCapabilitiesFactory.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.camera.cameradevice;
-
-import android.hardware.Camera;
-
-import com.android.camera.debug.Log;
-
-public class CameraCapabilitiesFactory {
-
- private static Log.Tag TAG = new Log.Tag("CapabilitiesFactory");
-
- public static CameraCapabilities createFrom(Camera.Parameters p) {
- if (p == null) {
- Log.w(TAG, "Null parameter passed in.");
- return null;
- }
- return new AndroidCameraCapabilities(p);
- }
-}
diff --git a/src/com/android/camera/cameradevice/CameraDeviceInfo.java b/src/com/android/camera/cameradevice/CameraDeviceInfo.java
deleted file mode 100644
index 6cafb9f49..000000000
--- a/src/com/android/camera/cameradevice/CameraDeviceInfo.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package com.android.camera.cameradevice;
-
-import android.hardware.Camera;
-
-/**
- * The camera device info.
- */
-public interface CameraDeviceInfo {
-
- static final int NO_DEVICE = -1;
-
- /**
- * @return The camera info.
- * // TODO: Remove the dependency on API 1.
- */
- @Deprecated
- Camera.CameraInfo[] getCameraInfos();
-
- /**
- * @return The total number of the available camera devices.
- */
- int getNumberOfCameras();
-
- /**
- * @return The first (lowest) ID of the back cameras or {@code NO_DEVICE}
- * if not available.
- */
- int getFirstBackCameraId();
-
- /**
- * @return The first (lowest) ID of the front cameras or {@code NO_DEVICE}
- * if not available.
- */
- int getFirstFrontCameraId();
-}
diff --git a/src/com/android/camera/cameradevice/CameraManager.java b/src/com/android/camera/cameradevice/CameraManager.java
deleted file mode 100644
index 178c52ae4..000000000
--- a/src/com/android/camera/cameradevice/CameraManager.java
+++ /dev/null
@@ -1,581 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.camera.cameradevice;
-
-import android.annotation.TargetApi;
-import android.graphics.SurfaceTexture;
-import android.hardware.Camera;
-import android.hardware.Camera.OnZoomChangeListener;
-import android.os.Build;
-import android.os.Handler;
-import android.os.Looper;
-import android.view.SurfaceHolder;
-
-/**
- * An interface which provides possible camera device operations.
- *
- * The client should call {@code CameraManager.openCamera} to get an instance
- * of {@link CameraManager.CameraProxy} to control the camera. Classes
- * implementing this interface should have its own one unique {@code Thread}
- * other than the main thread for camera operations. Camera device callbacks
- * are wrapped since the client should not deal with
- * {@code android.hardware.Camera} directly.
- *
- * TODO: provide callback interfaces for:
- * {@code android.hardware.Camera.ErrorCallback},
- * {@code android.hardware.Camera.OnZoomChangeListener}, and
- */
-public interface CameraManager {
- public static final long CAMERA_OPERATION_TIMEOUT_MS = 2500;
-
- public static class CameraStartPreviewCallbackForward
- implements CameraStartPreviewCallback {
- private final Handler mHandler;
- private final CameraStartPreviewCallback mCallback;
-
- public static CameraStartPreviewCallbackForward getNewInstance(
- Handler handler, CameraStartPreviewCallback cb) {
- if (handler == null || cb == null) {
- return null;
- }
- return new CameraStartPreviewCallbackForward(handler, cb);
- }
-
- private CameraStartPreviewCallbackForward(Handler h,
- CameraStartPreviewCallback cb) {
- mHandler = h;
- mCallback = cb;
- }
-
- @Override
- public void onPreviewStarted() {
- mHandler.post(new Runnable() {
- @Override
- public void run() {
- mCallback.onPreviewStarted();
- }
- });
- }
- }
-
- /**
- * A callback helps to invoke the original callback on another
- * {@link android.os.Handler}.
- */
- public static class CameraOpenCallbackForward implements CameraOpenCallback {
- private final Handler mHandler;
- private final CameraOpenCallback mCallback;
-
- /**
- * Returns a new instance of {@link FaceDetectionCallbackForward}.
- *
- * @param handler The handler in which the callback will be invoked in.
- * @param cb The callback to be invoked.
- * @return The instance of the {@link FaceDetectionCallbackForward}, or
- * null if any parameter is null.
- */
- public static CameraOpenCallbackForward getNewInstance(
- Handler handler, CameraOpenCallback cb) {
- if (handler == null || cb == null) {
- return null;
- }
- return new CameraOpenCallbackForward(handler, cb);
- }
-
- private CameraOpenCallbackForward(Handler h, CameraOpenCallback cb) {
- // Given that we are using the main thread handler, we can create it
- // here instead of holding onto the PhotoModule objects. In this
- // way, we can avoid memory leak.
- mHandler = new Handler(Looper.getMainLooper());
- mCallback = cb;
- }
-
- @Override
- public void onCameraOpened(final CameraProxy camera) {
- mHandler.post(new Runnable() {
- @Override
- public void run() {
- mCallback.onCameraOpened(camera);
- }
- });
- }
-
- @Override
- public void onCameraDisabled(final int cameraId) {
- mHandler.post(new Runnable() {
- @Override
- public void run() {
- mCallback.onCameraDisabled(cameraId);
- }
- });
- }
-
- @Override
- public void onDeviceOpenFailure(final int cameraId, final String info) {
- mHandler.post(new Runnable() {
- @Override
- public void run() {
- mCallback.onDeviceOpenFailure(cameraId, info);
- }
- });
- }
-
- @Override
- public void onDeviceOpenedAlready(final int cameraId, final String info) {
- mHandler.post(new Runnable() {
- @Override
- public void run() {
- mCallback.onDeviceOpenedAlready(cameraId, info);
- }
- });
- }
-
- @Override
- public void onReconnectionFailure(final CameraManager mgr, final String info) {
- mHandler.post(new Runnable() {
- @Override
- public void run() {
- mCallback.onReconnectionFailure(mgr, info);
- }
- });
- }
- }
-
- /**
- * A handler for all camera api runtime exceptions.
- * The default behavior is to throw the runtime exception.
- */
- public interface CameraExceptionCallback {
- public void onCameraException(RuntimeException e);
- }
-
- /**
- * An interface which wraps
- * {@link android.hardware.Camera.ErrorCallback}
- */
- public interface CameraErrorCallback {
- public void onError(int error, CameraProxy camera);
- }
-
- /**
- * An interface which wraps
- * {@link android.hardware.Camera.AutoFocusCallback}.
- */
- public interface CameraAFCallback {
- public void onAutoFocus(boolean focused, CameraProxy camera);
- }
-
- /**
- * An interface which wraps
- * {@link android.hardware.Camera.AutoFocusMoveCallback}.
- */
- public interface CameraAFMoveCallback {
- public void onAutoFocusMoving(boolean moving, CameraProxy camera);
- }
-
- /**
- * An interface which wraps
- * {@link android.hardware.Camera.ShutterCallback}.
- */
- public interface CameraShutterCallback {
- public void onShutter(CameraProxy camera);
- }
-
- /**
- * An interface which wraps
- * {@link android.hardware.Camera.PictureCallback}.
- */
- public interface CameraPictureCallback {
- public void onPictureTaken(byte[] data, CameraProxy camera);
- }
-
- /**
- * An interface which wraps
- * {@link android.hardware.Camera.PreviewCallback}.
- */
- public interface CameraPreviewDataCallback {
- public void onPreviewFrame(byte[] data, CameraProxy camera);
- }
-
- /**
- * An interface which wraps
- * {@link android.hardware.Camera.FaceDetectionListener}.
- */
- public interface CameraFaceDetectionCallback {
- /**
- * Callback for face detection.
- *
- * @param faces Recognized face in the preview.
- * @param camera The camera which the preview image comes from.
- */
- public void onFaceDetection(Camera.Face[] faces, CameraProxy camera);
- }
-
- /**
- * An interface to be called when the camera preview has started.
- */
- public interface CameraStartPreviewCallback {
- /**
- * Callback when the preview starts.
- */
- public void onPreviewStarted();
- }
-
- /**
- * An interface to be called for any events when opening or closing the
- * camera device. This error callback is different from the one defined
- * in the framework, {@link android.hardware.Camera.ErrorCallback}, which
- * is used after the camera is opened.
- */
- public interface CameraOpenCallback {
- /**
- * Callback when camera open succeeds.
- */
- public void onCameraOpened(CameraProxy camera);
-
- /**
- * Callback when {@link com.android.camera.CameraDisabledException} is
- * caught.
- *
- * @param cameraId The disabled camera.
- */
- public void onCameraDisabled(int cameraId);
-
- /**
- * Callback when {@link com.android.camera.CameraHardwareException} is
- * caught.
- *
- * @param cameraId The camera with the hardware failure.
- * @param info The extra info regarding this failure.
- */
- public void onDeviceOpenFailure(int cameraId, String info);
-
- /**
- * Callback when trying to open the camera which is already opened.
- *
- * @param cameraId The camera which is causing the open error.
- */
- public void onDeviceOpenedAlready(int cameraId, String info);
-
- /**
- * Callback when {@link java.io.IOException} is caught during
- * {@link android.hardware.Camera#reconnect()}.
- *
- * @param mgr The {@link CameraManager}
- * with the reconnect failure.
- */
- public void onReconnectionFailure(CameraManager mgr, String info);
- }
-
- /**
- * Opens the camera of the specified ID asynchronously. The camera device
- * will be opened in the camera handler thread and will be returned through
- * the {@link CameraManager.CameraOpenCallback#
- * onCameraOpened(com.android.camera.cameradevice.CameraManager.CameraProxy)}.
- *
- * @param handler The {@link android.os.Handler} in which the callback
- * was handled.
- * @param callback The callback for the result.
- * @param cameraId The camera ID to open.
- */
- public void openCamera(Handler handler, int cameraId, CameraOpenCallback callback);
-
- /**
- * Closes the camera device.
- *
- * @param camera The camera to close. {@code null} means all.
- * @param synced Whether this call should be synchronous.
- */
- public void closeCamera(CameraProxy camera, boolean synced);
-
- /**
- * Sets a callback for handling camera api runtime exceptions on
- * a handler.
- */
- public void setCameraDefaultExceptionCallback(CameraExceptionCallback callback,
- Handler handler);
-
- /**
- * Recycles the resources used by this instance. CameraManager will be in
- * an unusable state after calling this.
- */
- public void recycle();
-
- /**
- * @return The camera devices info.
- */
- public CameraDeviceInfo getCameraDeviceInfo();
-
- /**
- * An interface that takes camera operation requests and post messages to the
- * camera handler thread. All camera operations made through this interface is
- * asynchronous by default except those mentioned specifically.
- */
- public interface CameraProxy {
-
- /**
- * Returns the underlying {@link android.hardware.Camera} object used
- * by this proxy. This method should only be used when handing the
- * camera device over to {@link android.media.MediaRecorder} for
- * recording.
- */
- @Deprecated
- public android.hardware.Camera getCamera();
-
- /**
- * @return The camera ID associated to by this
- * {@link CameraManager.CameraProxy}.
- */
- public int getCameraId();
-
- /**
- * @return The camera capabilities.
- */
- public CameraCapabilities getCapabilities();
-
- /**
- * Reconnects to the camera device. On success, the camera device will
- * be returned through {@link CameraManager
- * .CameraOpenCallback#onCameraOpened(com.android.camera.cameradevice.CameraManager
- * .CameraProxy)}.
- * @see android.hardware.Camera#reconnect()
- *
- * @param handler The {@link android.os.Handler} in which the callback
- * was handled.
- * @param cb The callback when any error happens.
- */
- public void reconnect(Handler handler, CameraOpenCallback cb);
-
- /**
- * Unlocks the camera device.
- *
- * @see android.hardware.Camera#unlock()
- */
- public void unlock();
-
- /**
- * Locks the camera device.
- * @see android.hardware.Camera#lock()
- */
- public void lock();
-
- /**
- * Sets the {@link android.graphics.SurfaceTexture} for preview.
- *
- * @param surfaceTexture The {@link SurfaceTexture} for preview.
- */
- public void setPreviewTexture(final SurfaceTexture surfaceTexture);
-
- /**
- * Blocks until a {@link android.graphics.SurfaceTexture} has been set
- * for preview.
- *
- * @param surfaceTexture The {@link SurfaceTexture} for preview.
- */
- public void setPreviewTextureSync(final SurfaceTexture surfaceTexture);
-
- /**
- * Sets the {@link android.view.SurfaceHolder} for preview.
- *
- * @param surfaceHolder The {@link SurfaceHolder} for preview.
- */
- public void setPreviewDisplay(final SurfaceHolder surfaceHolder);
-
- /**
- * Starts the camera preview.
- */
- public void startPreview();
-
- /**
- * Starts the camera preview and executes a callback on a handler once
- * the preview starts.
- */
- public void startPreviewWithCallback(Handler h, CameraStartPreviewCallback cb);
-
- /**
- * Stops the camera preview synchronously.
- * {@code stopPreview()} must be synchronous to ensure that the caller can
- * continues to release resources related to camera preview.
- */
- public void stopPreview();
-
- /**
- * Sets the callback for preview data.
- *
- * @param handler The {@link android.os.Handler} in which the callback was handled.
- * @param cb The callback to be invoked when the preview data is available.
- * @see android.hardware.Camera#setPreviewCallback(android.hardware.Camera.PreviewCallback)
- */
- public void setPreviewDataCallback(Handler handler, CameraPreviewDataCallback cb);
-
- /**
- * Sets the one-time callback for preview data.
- *
- * @param handler The {@link android.os.Handler} in which the callback was handled.
- * @param cb The callback to be invoked when the preview data for
- * next frame is available.
- * @see android.hardware.Camera#setPreviewCallback(android.hardware.Camera.PreviewCallback)
- */
- public void setOneShotPreviewCallback(Handler handler, CameraPreviewDataCallback cb);
-
- /**
- * Sets the callback for preview data.
- *
- * @param handler The handler in which the callback will be invoked.
- * @param cb The callback to be invoked when the preview data is available.
- * @see android.hardware.Camera#setPreviewCallbackWithBuffer(android.hardware.Camera.PreviewCallback)
- */
- public void setPreviewDataCallbackWithBuffer(Handler handler, CameraPreviewDataCallback cb);
-
- /**
- * Adds buffer for the preview callback.
- *
- * @param callbackBuffer The buffer allocated for the preview data.
- */
- public void addCallbackBuffer(byte[] callbackBuffer);
-
- /**
- * Starts the auto-focus process. The result will be returned through the callback.
- *
- * @param handler The handler in which the callback will be invoked.
- * @param cb The auto-focus callback.
- */
- public void autoFocus(Handler handler, CameraAFCallback cb);
-
- /**
- * Cancels the auto-focus process.
- */
- public void cancelAutoFocus();
-
- /**
- * Sets the auto-focus callback
- *
- * @param handler The handler in which the callback will be invoked.
- * @param cb The callback to be invoked when the preview data is available.
- */
- @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
- public void setAutoFocusMoveCallback(Handler handler, CameraAFMoveCallback cb);
-
- /**
- * Instrument the camera to take a picture.
- *
- * @param handler The handler in which the callback will be invoked.
- * @param shutter The callback for shutter action, may be null.
- * @param raw The callback for uncompressed data, may be null.
- * @param postview The callback for postview image data, may be null.
- * @param jpeg The callback for jpeg image data, may be null.
- * @see android.hardware.Camera#takePicture(
- * android.hardware.Camera.ShutterCallback,
- * android.hardware.Camera.PictureCallback,
- * android.hardware.Camera.PictureCallback)
- */
- public void takePicture(
- Handler handler,
- CameraShutterCallback shutter,
- CameraPictureCallback raw,
- CameraPictureCallback postview,
- CameraPictureCallback jpeg);
-
- /**
- * Sets the display orientation for camera to adjust the preview orientation.
- *
- * @param degrees The rotation in degrees. Should be 0, 90, 180 or 270.
- */
- public void setDisplayOrientation(int degrees);
-
- /**
- * Sets the listener for zoom change.
- *
- * @param listener The listener.
- */
- public void setZoomChangeListener(OnZoomChangeListener listener);
-
- /**
- * Sets the face detection listener.
- *
- * @param handler The handler in which the callback will be invoked.
- * @param callback The callback for face detection results.
- */
- public void setFaceDetectionCallback(Handler handler, CameraFaceDetectionCallback callback);
-
- /**
- * Starts the face detection.
- */
- public void startFaceDetection();
-
- /**
- * Stops the face detection.
- */
- public void stopFaceDetection();
-
- /**
- * Registers an error callback.
- *
- * @param handler The handler on which the callback will be invoked.
- * @param cb The error callback.
- * @see android.hardware.Camera#setErrorCallback(android.hardware.Camera.ErrorCallback)
- */
- public void setErrorCallback(Handler handler, CameraErrorCallback cb);
-
- /**
- * Sets the camera parameters.
- *
- * @param params The camera parameters to use.
- */
- @Deprecated
- public void setParameters(Camera.Parameters params);
-
- /**
- * Gets the current camera parameters synchronously. This method is
- * synchronous since the caller has to wait for the camera to return
- * the parameters. If the parameters are already cached, it returns
- * immediately.
- */
- @Deprecated
- public Camera.Parameters getParameters();
-
- /**
- * Gets the current camera settings synchronously.
- * <p>This method is synchronous since the caller has to wait for the
- * camera to return the parameters. If the parameters are already
- * cached, it returns immediately.</p>
- */
- public CameraSettings getSettings();
-
- /**
- * Applies the settings to the camera device.
- *
- * @param settings The settings to use on the device.
- * @return Whether the settings can be applied.
- */
- public boolean applySettings(CameraSettings settings);
-
- /**
- * Forces {@code CameraProxy} to update the cached version of the camera
- * settings regardless of the dirty bit.
- */
- public void refreshSettings();
-
- /**
- * Enables/Disables the camera shutter sound.
- *
- * @param enable {@code true} to enable the shutter sound,
- * {@code false} to disable it.
- */
- public void enableShutterSound(boolean enable);
- }
-}
diff --git a/src/com/android/camera/cameradevice/CameraManagerFactory.java b/src/com/android/camera/cameradevice/CameraManagerFactory.java
deleted file mode 100644
index 5f1c39d27..000000000
--- a/src/com/android/camera/cameradevice/CameraManagerFactory.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (C) 2013 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.camera.cameradevice;
-
-/**
- * A factory class for {@link CameraManager}.
- */
-public class CameraManagerFactory {
-
- private static AndroidCameraManagerImpl sAndroidCameraManager;
- private static int sAndoridCameraManagerClientCount;
-
- /**
- * Returns the android camera implementation of {@link com.android.camera.cameradevice.CameraManager}.
- *
- * @return The {@link CameraManager} to control the camera device.
- */
- public static synchronized CameraManager getAndroidCameraManager() {
- if (sAndroidCameraManager == null) {
- sAndroidCameraManager = new AndroidCameraManagerImpl();
- sAndoridCameraManagerClientCount = 1;
- } else {
- ++sAndoridCameraManagerClientCount;
- }
- return sAndroidCameraManager;
- }
-
- /**
- * Recycles the resources. Always call this method when the activity is
- * stopped.
- */
- public static synchronized void recycle() {
- if (--sAndoridCameraManagerClientCount == 0 && sAndroidCameraManager != null) {
- sAndroidCameraManager.recycle();
- sAndroidCameraManager = null;
- }
- }
-}
diff --git a/src/com/android/camera/cameradevice/CameraSettings.java b/src/com/android/camera/cameradevice/CameraSettings.java
deleted file mode 100644
index 38f64b477..000000000
--- a/src/com/android/camera/cameradevice/CameraSettings.java
+++ /dev/null
@@ -1,377 +0,0 @@
-package com.android.camera.cameradevice;
-
-import android.hardware.Camera;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.TreeMap;
-
-/**
- * A class which stores the camera settings.
- */
-public class CameraSettings {
-
- protected final Map<String, String> mGeneralSetting = new TreeMap<>();
- protected final List<Camera.Area> mMeteringAreas = new ArrayList<>();
- protected final List<Camera.Area> mFocusAreas = new ArrayList<>();
- protected int mPreviewFpsRangeMin;
- protected int mPreviewFpsRangeMax;
- protected int mPreviewFrameRate;
- protected Size mCurrentPreviewSize;
- protected Size mCurrentPhotoSize;
- protected int mJpegCompressQuality;
- protected float mCurrentZoomRatio;
- protected int mCurrentZoomIndex;
- protected float mPhotoRotationDegrees;
- protected int mExposureCompensationIndex;
- protected CameraCapabilities.FlashMode mCurrentFlashMode;
- protected CameraCapabilities.FocusMode mCurrentFocusMode;
- protected CameraCapabilities.SceneMode mCurrentSceneMode;
- protected CameraCapabilities.WhiteBalance mWhiteBalance;
- protected boolean mVideoStabilizationEnabled;
- protected boolean mAutoExposureLocked;
- protected boolean mAutoWhiteBalanceLocked;
- protected GpsData mGpsData;
-
- /**
- * An immutable class storing GPS related information.
- * <p>It's a hack since we always use GPS time stamp but does not use other
- * fields sometimes. Setting processing method to null means the other
- * fields should not be used.</p>
- */
- public static class GpsData {
- public final double latitude;
- public final double longitude;
- public final double altitude;
- public final long timeStamp;
- public final String processingMethod;
-
- /** Constructor. */
- public GpsData(double latitude, double longitude, double altitude, long timeStamp,
- String processingMethod) {
- this.latitude = latitude;
- this.longitude = longitude;
- this.altitude = altitude;
- this.timeStamp = timeStamp;
- this.processingMethod = processingMethod;
- }
-
- /** Copy constructor. */
- public GpsData(GpsData src) {
- this.latitude = src.latitude;
- this.longitude = src.longitude;
- this.altitude = src.altitude;
- this.timeStamp = src.timeStamp;
- this.processingMethod = src.processingMethod;
- }
- }
-
- protected CameraSettings() {
- }
-
- /**
- * Copy constructor.
- *
- * @param src The source settings.
- * @return The copy of the source.
- */
- public CameraSettings(CameraSettings src) {
- mGeneralSetting.putAll(src.mGeneralSetting);
- mMeteringAreas.addAll(src.mMeteringAreas);
- mFocusAreas.addAll(src.mFocusAreas);
- mPreviewFpsRangeMin = src.mPreviewFpsRangeMin;
- mPreviewFpsRangeMax = src.mPreviewFpsRangeMax;
- mPreviewFrameRate = src.mPreviewFrameRate;
- mCurrentPreviewSize =
- (src.mCurrentPreviewSize == null ? null : new Size(src.mCurrentPreviewSize));
- mCurrentPhotoSize =
- (src.mCurrentPhotoSize == null ? null : new Size(src.mCurrentPhotoSize));
- mJpegCompressQuality = src.mJpegCompressQuality;
- mCurrentZoomRatio = src.mCurrentZoomRatio;
- mCurrentZoomIndex = src.mCurrentZoomIndex;
- mPhotoRotationDegrees = src.mPhotoRotationDegrees;
- mExposureCompensationIndex = src.mExposureCompensationIndex;
- mCurrentFlashMode = src.mCurrentFlashMode;
- mCurrentFocusMode = src.mCurrentFocusMode;
- mCurrentSceneMode = src.mCurrentSceneMode;
- mWhiteBalance = src.mWhiteBalance;
- mVideoStabilizationEnabled = src.mVideoStabilizationEnabled;
- mAutoExposureLocked = src.mAutoExposureLocked;
- mAutoWhiteBalanceLocked = src.mAutoWhiteBalanceLocked;
- mGpsData = src.mGpsData;
- }
-
- /** General setting **/
- @Deprecated
- public void setSetting(String key, String value) {
- mGeneralSetting.put(key, value);
- }
-
- /** Preview **/
-
- /**
- * Sets the preview FPS range. This call will invalidate prior calls to
- * {@link #setPreviewFrameRate(int)}.
- *
- * @param min The min FPS.
- * @param max The max FPS.
- */
- public void setPreviewFpsRange(int min, int max) {
- if (min > max) {
- int temp = max;
- max = min;
- min = temp;
- }
- mPreviewFpsRangeMax = max;
- mPreviewFpsRangeMin = min;
- mPreviewFrameRate = -1;
- }
-
- /**
- * @return The min of the preview FPS range.
- */
- public int getPreviewFpsRangeMin() {
- return mPreviewFpsRangeMin;
- }
-
- /**
- * @return The max of the preview FPS range.
- */
- public int getPreviewFpsRangeMax() {
- return mPreviewFpsRangeMax;
- }
-
- /**
- * Sets the preview FPS. This call will invalidate prior calls to
- * {@link #setPreviewFpsRange(int, int)}.
- *
- * @param frameRate The target frame rate.
- */
- public void setPreviewFrameRate(int frameRate) {
- if (frameRate > 0) {
- mPreviewFrameRate = frameRate;
- mPreviewFpsRangeMax = frameRate;
- mPreviewFpsRangeMin = frameRate;
- }
- }
-
- public int getPreviewFrameRate() {
- return mPreviewFrameRate;
- }
-
- /**
- * @return The current preview size.
- */
- public Size getCurrentPreviewSize() {
- return new Size(mCurrentPreviewSize);
- }
-
- /**
- * @param previewSize The size to use for preview.
- */
- public void setPreviewSize(Size previewSize) {
- mCurrentPreviewSize = new Size(previewSize);
- }
-
- /** Picture **/
-
- /**
- * @return The current photo size.
- */
- public Size getCurrentPhotoSize() {
- return new Size(mCurrentPhotoSize);
- }
-
- /**
- * Sets the size for the photo.
- *
- * @param photoSize The photo size.
- */
- public void setPhotoSize(Size photoSize) {
- mCurrentPhotoSize = new Size(photoSize);
- }
-
- /**
- * Sets the JPEG compression quality.
- *
- * @param quality The quality for JPEG.
- */
- public void setPhotoJpegCompressionQuality(int quality) {
- mJpegCompressQuality = quality;
- }
-
- public int getPhotoJpegCompressionQuality() {
- return mJpegCompressQuality;
- }
-
- /** Zoom **/
-
- /**
- * @return The current zoom ratio. The min is 1.0f.
- */
- public float getCurrentZoomRatio() {
- return mCurrentZoomRatio;
- }
-
- /**
- * Sets the zoom ratio.
- * @param ratio The new zoom ratio. Should be in the range between 1.0 to
- * the value returned from {@link
- * com.android.camera.cameradevice.CameraCapabilities#getMaxZoomRatio()}.
- * @throws java.lang.UnsupportedOperationException if the ratio is not
- * supported.
- */
- public void setZoomRatio(float ratio) {
- mCurrentZoomRatio = ratio;
- }
-
- @Deprecated
- public int getCurrentZoomIndex() {
- return mCurrentZoomIndex;
- }
-
- @Deprecated
- public void setZoomIndex(int index) {
- mCurrentZoomIndex = index;
- }
-
- /** Transformation **/
-
- public void setPhotoRotationDegrees(float photoRotationDegrees) {
- mPhotoRotationDegrees = photoRotationDegrees;
- }
-
- public float getCurrentPhotoRotationDegrees() {
- return mPhotoRotationDegrees;
- }
-
- /** Exposure **/
-
- public void setExposureCompensationIndex(int index) {
- mExposureCompensationIndex = index;
- }
-
- public int getExposureCompensationIndex() {
- return mExposureCompensationIndex;
- }
-
- public void setAutoExposureLock(boolean locked) {
- mAutoExposureLocked = locked;
- }
-
- public boolean isAutoExposureLocked() {
- return mAutoExposureLocked;
- }
-
- public void setMeteringAreas(List<Camera.Area> areas) {
- mMeteringAreas.clear();
- if (areas != null) {
- mMeteringAreas.addAll(areas);
- }
- }
-
- public List<Camera.Area> getMeteringAreas() {
- return new ArrayList<Camera.Area>(mMeteringAreas);
- }
-
- /** Flash **/
-
- public CameraCapabilities.FlashMode getCurrentFlashMode() {
- return mCurrentFlashMode;
- }
-
- public void setFlashMode(CameraCapabilities.FlashMode flashMode) {
- mCurrentFlashMode = flashMode;
- }
-
- /** Focus **/
-
- /**
- * Sets the focus mode.
- * @param focusMode The focus mode to use.
- */
- public void setFocusMode(CameraCapabilities.FocusMode focusMode) {
- mCurrentFocusMode = focusMode;
- }
-
- /**
- * @return The current focus mode.
- */
- public CameraCapabilities.FocusMode getCurrentFocusMode() {
- return mCurrentFocusMode;
- }
-
- /**
- * @param areas The areas to focus.
- */
- public void setFocusAreas(List<Camera.Area> areas) {
- mFocusAreas.clear();
- if (areas != null) {
- mFocusAreas.addAll(areas);
- }
- }
-
- public List<Camera.Area> getFocusAreas() {
- return new ArrayList<Camera.Area>(mFocusAreas);
- }
-
- /** White balance **/
-
- public void setWhiteBalance(CameraCapabilities.WhiteBalance whiteBalance) {
- mWhiteBalance = whiteBalance;
- }
-
- public CameraCapabilities.WhiteBalance getWhiteBalance() {
- return mWhiteBalance;
- }
-
- public void setAutoWhiteBalanceLock(boolean locked) {
- mAutoWhiteBalanceLocked = locked;
- }
-
- public boolean isAutoWhiteBalanceLocked() {
- return mAutoWhiteBalanceLocked;
- }
-
- /** Scene mode **/
-
- /**
- * @return The current scene mode.
- */
- public CameraCapabilities.SceneMode getCurrentSceneMode() {
- return mCurrentSceneMode;
- }
-
- /**
- * Sets the scene mode for capturing.
- *
- * @param sceneMode The scene mode to use.
- * @throws java.lang.UnsupportedOperationException if it's not supported.
- */
- public void setSceneMode(CameraCapabilities.SceneMode sceneMode) {
- mCurrentSceneMode = sceneMode;
- }
-
- /** Other Features **/
-
- public void setVideoStabilization(boolean enabled) {
- mVideoStabilizationEnabled = enabled;
- }
-
- public boolean isVideoStabilizationEnabled() {
- return mVideoStabilizationEnabled;
- }
-
- public void setGpsData(GpsData data) {
- mGpsData = new GpsData(data);
- }
-
- public GpsData getGpsData() {
- return (mGpsData == null ? null : new GpsData(mGpsData));
- }
-
- public void clearGpsData() {
- mGpsData = null;
- }
-}
diff --git a/src/com/android/camera/cameradevice/CameraStateHolder.java b/src/com/android/camera/cameradevice/CameraStateHolder.java
deleted file mode 100644
index 0b0153fee..000000000
--- a/src/com/android/camera/cameradevice/CameraStateHolder.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"),
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.camera.cameradevice;
-
-import android.os.SystemClock;
-
-import com.android.camera.debug.Log;
-
-class CameraStateHolder {
- private static final Log.Tag TAG = new Log.Tag("CameraStateHolder");
-
- /** Camera states **/
- // These states are defined bitwise so we can easily to specify a set of
- // states together.
- public static final int CAMERA_UNOPENED = 1;
- public static final int CAMERA_IDLE = 1 << 1;
- public static final int CAMERA_UNLOCKED = 1 << 2;
- public static final int CAMERA_CAPTURING = 1 << 3;
- public static final int CAMERA_FOCUSING = 1 << 4;
-
- private int mState;
-
- public CameraStateHolder() {
- setState(CAMERA_UNOPENED);
- }
-
- public CameraStateHolder(int state) {
- setState(state);
- }
-
- public synchronized void setState(int state) {
- mState = state;
- this.notifyAll();
- }
-
- public synchronized int getState() {
- return mState;
- }
-
- private interface ConditionChecker {
- /**
- * @return Whether the condition holds.
- */
- boolean success();
- }
-
- /**
- * A helper method used by {@link #waitToAvoidStates(int)} and
- * {@link #waitForStates(int)}. This method will wait until the
- * condition is successful.
- *
- * @param stateChecker The state checker to be used.
- * @param timeoutMs The timeout limit in milliseconds.
- * @return {@code false} if the wait is interrupted or timeout limit is
- * reached.
- */
- private boolean waitForCondition(ConditionChecker stateChecker,
- long timeoutMs) {
- long timeBound = SystemClock.uptimeMillis() + timeoutMs;
- synchronized (this) {
- while (!stateChecker.success()) {
- try {
- this.wait(timeoutMs);
- } catch (InterruptedException ex) {
- if (SystemClock.uptimeMillis() > timeBound) {
- // Timeout.
- Log.w(TAG, "Timeout waiting.");
- }
- return false;
- }
- }
- }
- return true;
- }
-
- /**
- * Block the current thread until the state becomes one of the
- * specified.
- *
- * @param states Expected states.
- * @return {@code false} if the wait is interrupted or timeout limit is
- * reached.
- */
- public boolean waitForStates(final int states) {
- return waitForCondition(new ConditionChecker() {
- @Override
- public boolean success() {
- return (states | mState) == states;
- }
- }, CameraManager.CAMERA_OPERATION_TIMEOUT_MS);
- }
-
- /**
- * Block the current thread until the state becomes NOT one of the
- * specified.
- *
- * @param states States to avoid.
- * @return {@code false} if the wait is interrupted or timeout limit is
- * reached.
- */
- public boolean waitToAvoidStates(final int states) {
- return waitForCondition(new ConditionChecker() {
- @Override
- public boolean success() {
- return (states & mState) == 0;
- }
- }, CameraManager.CAMERA_OPERATION_TIMEOUT_MS);
- }
-}
diff --git a/src/com/android/camera/cameradevice/DispatchThread.java b/src/com/android/camera/cameradevice/DispatchThread.java
deleted file mode 100644
index 7deb27c8d..000000000
--- a/src/com/android/camera/cameradevice/DispatchThread.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.camera.cameradevice;
-
-import android.os.Handler;
-import android.os.HandlerThread;
-import android.os.SystemClock;
-
-import com.android.camera.debug.Log;
-
-import java.util.LinkedList;
-import java.util.Queue;
-
-class DispatchThread extends Thread {
- private static final Log.Tag TAG = new Log.Tag("DispatchThread");
- private static final long MAX_MESSAGE_QUEUE_LENGTH = 256;
-
- private final Queue<Runnable> mJobQueue;
- private Boolean mIsEnded;
- private Handler mCameraHandler;
- private HandlerThread mCameraHandlerThread;
-
- public DispatchThread(Handler cameraHandler, HandlerThread cameraHandlerThread) {
- super("Camera Job Dispatch Thread");
- mJobQueue = new LinkedList<Runnable>();
- mIsEnded = new Boolean(false);
- mCameraHandler = cameraHandler;
- mCameraHandlerThread = cameraHandlerThread;
- }
-
- /**
- * Queues up the job.
- *
- * @param job The job to run.
- */
- public void runJob(Runnable job) {
- if (isEnded()) {
- throw new IllegalStateException(
- "Trying to run job on interrupted dispatcher thread");
- }
- synchronized (mJobQueue) {
- if (mJobQueue.size() == MAX_MESSAGE_QUEUE_LENGTH) {
- throw new RuntimeException("Camera master thread job queue full");
- }
-
- mJobQueue.add(job);
- mJobQueue.notifyAll();
- }
- }
-
- /**
- * Queues up the job and wait for it to be done.
- *
- * @param job The job to run.
- * @param timeoutMs Timeout limit in milliseconds.
- * @param jobMsg The message to log when the job runs timeout.
- * @return Whether the job finishes before timeout.
- */
- public void runJobSync(final Runnable job, Object waitLock, long timeoutMs, String jobMsg) {
- String timeoutMsg = "Timeout waiting " + timeoutMs + "ms for " + jobMsg;
- synchronized (waitLock) {
- long timeoutBound = SystemClock.uptimeMillis() + timeoutMs;
- try {
- runJob(job);
- waitLock.wait(timeoutMs);
- if (SystemClock.uptimeMillis() > timeoutBound) {
- throw new IllegalStateException(timeoutMsg);
- }
- } catch (InterruptedException ex) {
- if (SystemClock.uptimeMillis() > timeoutBound) {
- throw new IllegalStateException(timeoutMsg);
- }
- }
- }
- }
-
- /**
- * Gracefully ends this thread. Will stop after all jobs are processed.
- */
- public void end() {
- synchronized (mIsEnded) {
- mIsEnded = true;
- }
- synchronized(mJobQueue) {
- mJobQueue.notifyAll();
- }
- }
-
- private boolean isEnded() {
- synchronized (mIsEnded) {
- return mIsEnded;
- }
- }
-
- @Override
- public void run() {
- while(true) {
- Runnable job = null;
- synchronized (mJobQueue) {
- while (mJobQueue.size() == 0 && !isEnded()) {
- try {
- mJobQueue.wait();
- } catch (InterruptedException ex) {
- Log.w(TAG, "Dispatcher thread wait() interrupted, exiting");
- break;
- }
- }
-
- job = mJobQueue.poll();
- }
-
- if (job == null) {
- // mJobQueue.poll() returning null means wait() is
- // interrupted and the queue is empty.
- if (isEnded()) {
- break;
- }
- continue;
- }
-
- job.run();
-
- synchronized (DispatchThread.this) {
- mCameraHandler.post(new Runnable() {
- @Override
- public void run() {
- synchronized (DispatchThread.this) {
- DispatchThread.this.notifyAll();
- }
- }
- });
- try {
- DispatchThread.this.wait();
- } catch (InterruptedException ex) {
- // TODO: do something here.
- }
- }
- }
- mCameraHandlerThread.quitSafely();
- }
-}
diff --git a/src/com/android/camera/cameradevice/HistoryHandler.java b/src/com/android/camera/cameradevice/HistoryHandler.java
deleted file mode 100644
index fd9c43a28..000000000
--- a/src/com/android/camera/cameradevice/HistoryHandler.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.camera.cameradevice;
-
-import android.os.Handler;
-import android.os.Looper;
-import android.os.Message;
-
-import java.util.LinkedList;
-
-class HistoryHandler extends Handler {
- private static final int MAX_HISTORY_SIZE = 400;
-
- final LinkedList<Integer> mMsgHistory;
-
- HistoryHandler(Looper looper) {
- super(looper);
- mMsgHistory = new LinkedList<Integer>();
- // We add a -1 at the beginning to mark the very beginning of the
- // history.
- mMsgHistory.offerLast(-1);
- }
-
- String generateHistoryString(int cameraId) {
- String info = new String("HIST");
- info += "_ID" + cameraId;
- for (Integer msg : mMsgHistory) {
- info = info + '_' + msg.toString();
- }
- info += "_HEND";
- return info;
- }
-
- /**
- * Subclasses' implementations should call this one before doing their work.
- */
- @Override
- public void handleMessage(Message msg) {
- mMsgHistory.offerLast(msg.what);
- while (mMsgHistory.size() > MAX_HISTORY_SIZE) {
- mMsgHistory.pollFirst();
- }
- }
-}
diff --git a/src/com/android/camera/cameradevice/Size.java b/src/com/android/camera/cameradevice/Size.java
deleted file mode 100644
index 9fdf6dca8..000000000
--- a/src/com/android/camera/cameradevice/Size.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.camera.cameradevice;
-
-import android.graphics.Point;
-import android.hardware.Camera;
-import android.text.TextUtils;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * An immutable simple size container.
- */
-public class Size {
- public static final String DELIMITER = ",";
-
- /**
- * An helper method to build a list of this class from a list of
- * {@link android.hardware.Camera.Size}.
- *
- * @param cameraSizes Source.
- * @return The built list.
- */
- public static List<Size> buildListFromCameraSizes(List<Camera.Size> cameraSizes) {
- ArrayList<Size> list = new ArrayList<Size>(cameraSizes.size());
- for (Camera.Size cameraSize : cameraSizes) {
- list.add(new Size(cameraSize));
- }
- return list;
- }
-
- /**
- * Encode List of this class as comma-separated list of integers.
- *
- * @param sizes List of this class to encode.
- * @return encoded string.
- */
- public static String listToString(List<Size> sizes) {
- ArrayList<Integer> flatSizes = new ArrayList<>();
- for (Size s : sizes) {
- flatSizes.add(s.width());
- flatSizes.add(s.height());
- }
- return TextUtils.join(DELIMITER, flatSizes);
- }
-
- /**
- * Decode comma-separated even-length list of integers into a List of this class.
- *
- * @param encodedSizes encoded string.
- * @return List of this class.
- */
- public static List<Size> stringToList(String encodedSizes) {
- String[] flatSizes = TextUtils.split(encodedSizes, DELIMITER);
- ArrayList<Size> list = new ArrayList<>();
- for (int i = 0; i < flatSizes.length; i += 2) {
- int width = Integer.parseInt(flatSizes[i]);
- int height = Integer.parseInt(flatSizes[i + 1]);
- list.add(new Size(width,height));
- }
- return list;
- }
-
- private final Point val;
-
- /**
- * Constructor.
- */
- public Size(int width, int height) {
- val = new Point(width, height);
- }
-
- /**
- * Copy constructor.
- */
- public Size(Size other) {
- if (other == null) {
- val = new Point(0, 0);
- } else {
- val = new Point(other.width(), other.height());
- }
- }
-
- /**
- * Constructor from a source {@link android.hardware.Camera.Size}.
- *
- * @param other The source size.
- */
- public Size(Camera.Size other) {
- if (other == null) {
- val = new Point(0, 0);
- } else {
- val = new Point(other.width, other.height);
- }
- }
-
- /**
- * Constructor from a source {@link android.graphics.Point}.
- *
- * @param p The source size.
- */
- public Size(Point p) {
- if (p == null) {
- val = new Point(0, 0);
- } else {
- val = new Point(p);
- }
- }
-
- public int width() {
- return val.x;
- }
-
- public int height() {
- return val.y;
- }
-
- @Override
- public boolean equals(Object o) {
- if (o instanceof Size) {
- Size other = (Size) o;
- return val.equals(other.val);
- }
- return false;
- }
-
- @Override
- public int hashCode() {
- return val.hashCode();
- }
-
- @Override
- public String toString() {
- return "Size: (" + this.width() + " x " + this.height() + ")";
- }
-}
diff --git a/src/com/android/camera/debug/DebugCameraProxy.java b/src/com/android/camera/debug/DebugCameraProxy.java
index e1fb672a6..33ab366d0 100644
--- a/src/com/android/camera/debug/DebugCameraProxy.java
+++ b/src/com/android/camera/debug/DebugCameraProxy.java
@@ -21,17 +21,17 @@ import android.hardware.Camera;
import android.os.Handler;
import android.view.SurfaceHolder;
-import com.android.camera.cameradevice.CameraCapabilities;
-import com.android.camera.cameradevice.CameraManager;
-import com.android.camera.cameradevice.CameraSettings;
+import com.android.ex.camera2.portability.CameraCapabilities;
+import com.android.ex.camera2.portability.CameraAgent;
+import com.android.ex.camera2.portability.CameraSettings;
/**
- * A {@link com.android.camera.cameradevice.CameraManager.CameraProxy} which wraps the
+ * A {@link com.android.ex.camera2.portability.CameraAgent.CameraProxy} which wraps the
* other and adds logs for all operations.
*/
-public class DebugCameraProxy implements CameraManager.CameraProxy {
+public class DebugCameraProxy implements CameraAgent.CameraProxy {
private final Log.Tag mTag;
- private final CameraManager.CameraProxy mProxy;
+ private final CameraAgent.CameraProxy mProxy;
/**
* Constructor.
@@ -39,7 +39,7 @@ public class DebugCameraProxy implements CameraManager.CameraProxy {
* @param tag The tag to be used for logs.
* @param proxy The camera proxy to be wrapped.
*/
- public DebugCameraProxy(Log.Tag tag, CameraManager.CameraProxy proxy) {
+ public DebugCameraProxy(Log.Tag tag, CameraAgent.CameraProxy proxy) {
mTag = tag;
mProxy = proxy;
}
@@ -63,7 +63,7 @@ public class DebugCameraProxy implements CameraManager.CameraProxy {
}
@Override
- public void reconnect(Handler handler, CameraManager.CameraOpenCallback cb) {
+ public void reconnect(Handler handler, CameraAgent.CameraOpenCallback cb) {
log("reconnect");
mProxy.reconnect(handler, cb);
}
@@ -105,7 +105,7 @@ public class DebugCameraProxy implements CameraManager.CameraProxy {
}
@Override
- public void startPreviewWithCallback(Handler h, CameraManager.CameraStartPreviewCallback cb) {
+ public void startPreviewWithCallback(Handler h, CameraAgent.CameraStartPreviewCallback cb) {
log("startPreviewWithCallback");
mProxy.startPreviewWithCallback(h, cb);
}
@@ -118,21 +118,21 @@ public class DebugCameraProxy implements CameraManager.CameraProxy {
@Override
public void setPreviewDataCallback(Handler handler,
- CameraManager.CameraPreviewDataCallback cb) {
+ CameraAgent.CameraPreviewDataCallback cb) {
log("setPreviewDataCallback");
mProxy.setPreviewDataCallback(handler, cb);
}
@Override
public void setOneShotPreviewCallback(Handler handler,
- CameraManager.CameraPreviewDataCallback cb) {
+ CameraAgent.CameraPreviewDataCallback cb) {
log("setOneShotPreviewCallback");
mProxy.setOneShotPreviewCallback(handler, cb);
}
@Override
public void setPreviewDataCallbackWithBuffer(Handler handler,
- CameraManager.CameraPreviewDataCallback cb) {
+ CameraAgent.CameraPreviewDataCallback cb) {
log("setPreviewDataCallbackWithBuffer");
mProxy.setPreviewDataCallbackWithBuffer(handler, cb);
}
@@ -144,7 +144,7 @@ public class DebugCameraProxy implements CameraManager.CameraProxy {
}
@Override
- public void autoFocus(Handler handler, CameraManager.CameraAFCallback cb) {
+ public void autoFocus(Handler handler, CameraAgent.CameraAFCallback cb) {
log("autoFocus");
mProxy.autoFocus(handler, cb);
}
@@ -156,15 +156,15 @@ public class DebugCameraProxy implements CameraManager.CameraProxy {
}
@Override
- public void setAutoFocusMoveCallback(Handler handler, CameraManager.CameraAFMoveCallback cb) {
+ public void setAutoFocusMoveCallback(Handler handler, CameraAgent.CameraAFMoveCallback cb) {
log("setAutoFocusMoveCallback");
mProxy.setAutoFocusMoveCallback(handler, cb);
}
@Override
- public void takePicture(Handler handler, CameraManager.CameraShutterCallback shutter,
- CameraManager.CameraPictureCallback raw, CameraManager.CameraPictureCallback postview,
- CameraManager.CameraPictureCallback jpeg) {
+ public void takePicture(Handler handler, CameraAgent.CameraShutterCallback shutter,
+ CameraAgent.CameraPictureCallback raw, CameraAgent.CameraPictureCallback postview,
+ CameraAgent.CameraPictureCallback jpeg) {
log("takePicture");
mProxy.takePicture(handler, shutter, raw, postview, jpeg);
}
@@ -183,7 +183,7 @@ public class DebugCameraProxy implements CameraManager.CameraProxy {
@Override
public void setFaceDetectionCallback(Handler handler,
- CameraManager.CameraFaceDetectionCallback callback) {
+ CameraAgent.CameraFaceDetectionCallback callback) {
log("setFaceDetectionCallback");
mProxy.setFaceDetectionCallback(handler, callback);
}
@@ -201,7 +201,7 @@ public class DebugCameraProxy implements CameraManager.CameraProxy {
}
@Override
- public void setErrorCallback(Handler handler, CameraManager.CameraErrorCallback cb) {
+ public void setErrorCallback(Handler handler, CameraAgent.CameraErrorCallback cb) {
log("setErrorCallback");
mProxy.setErrorCallback(handler, cb);
}
diff --git a/src/com/android/camera/hardware/HardwareSpecImpl.java b/src/com/android/camera/hardware/HardwareSpecImpl.java
index 2cece65c1..0ea5375a6 100644
--- a/src/com/android/camera/hardware/HardwareSpecImpl.java
+++ b/src/com/android/camera/hardware/HardwareSpecImpl.java
@@ -18,9 +18,9 @@ package com.android.camera.hardware;
import android.hardware.Camera;
-import com.android.camera.cameradevice.CameraCapabilities;
import com.android.camera.util.CameraUtil;
import com.android.camera.util.GcamHelper;
+import com.android.ex.camera2.portability.CameraCapabilities;
import java.util.List;
@@ -60,7 +60,7 @@ public class HardwareSpecImpl implements HardwareSpec {
/**
* Compute the supported values for all
* {@link com.android.camera.hardware.HardwareSpec} methods
- * based on {@link com.android.camera.cameradevice.CameraCapabilities}.
+ * based on {@link com.android.ex.camera2.portability.CameraCapabilities}.
*/
public HardwareSpecImpl(CameraCapabilities capabilities) {
// Cache whether front camera is supported.
diff --git a/src/com/android/camera/module/ModuleController.java b/src/com/android/camera/module/ModuleController.java
index f47a27892..76cf9283d 100644
--- a/src/com/android/camera/module/ModuleController.java
+++ b/src/com/android/camera/module/ModuleController.java
@@ -19,9 +19,9 @@ package com.android.camera.module;
import com.android.camera.CameraActivity;
import com.android.camera.ShutterButton;
import com.android.camera.app.CameraAppUI.BottomBarUISpec;
-import com.android.camera.cameradevice.CameraManager;
import com.android.camera.hardware.HardwareSpec;
import com.android.camera.settings.SettingsManager;
+import com.android.ex.camera2.portability.CameraAgent;
/**
* The controller at app level.
@@ -104,7 +104,7 @@ public interface ModuleController extends ShutterButton.OnShutterButtonListener
*
* @param cameraProxy The camera device proxy.
*/
- public void onCameraAvailable(CameraManager.CameraProxy cameraProxy);
+ public void onCameraAvailable(CameraAgent.CameraProxy cameraProxy);
/**
* Called by the app on startup or module switches, this allows the module
diff --git a/src/com/android/camera/settings/CameraPictureSizesCacher.java b/src/com/android/camera/settings/CameraPictureSizesCacher.java
index 6e0f23fb4..6f0c86e8a 100644
--- a/src/com/android/camera/settings/CameraPictureSizesCacher.java
+++ b/src/com/android/camera/settings/CameraPictureSizesCacher.java
@@ -22,7 +22,7 @@ import android.hardware.Camera;
import android.os.Build;
import android.preference.PreferenceManager;
-import com.android.camera.cameradevice.Size;
+import com.android.ex.camera2.portability.Size;
import java.util.List;
diff --git a/src/com/android/camera/settings/CameraSettingsActivity.java b/src/com/android/camera/settings/CameraSettingsActivity.java
index 43bbfcf32..3a7e92979 100644
--- a/src/com/android/camera/settings/CameraSettingsActivity.java
+++ b/src/com/android/camera/settings/CameraSettingsActivity.java
@@ -46,8 +46,8 @@ import com.android.camera.settings.SettingsUtil.SelectedVideoQualities;
import com.android.camera.util.FeedbackHelper;
import com.android.camera.util.GoogleHelpHelper;
import com.android.camera.util.SettingsHelper;
-import com.android.camera.cameradevice.Size;
import com.android.camera2.R;
+import com.android.ex.camera2.portability.Size;
import java.text.DecimalFormat;
import java.util.ArrayList;
diff --git a/src/com/android/camera/settings/ResolutionUtil.java b/src/com/android/camera/settings/ResolutionUtil.java
index c81b36c93..9ddb45c70 100644
--- a/src/com/android/camera/settings/ResolutionUtil.java
+++ b/src/com/android/camera/settings/ResolutionUtil.java
@@ -17,7 +17,7 @@
package com.android.camera.settings;
import com.android.camera.util.ApiHelper;
-import com.android.camera.cameradevice.Size;
+import com.android.ex.camera2.portability.Size;
import java.math.BigInteger;
import java.util.ArrayList;
diff --git a/src/com/android/camera/settings/SettingsManager.java b/src/com/android/camera/settings/SettingsManager.java
index fd47ed80b..c825eb6f1 100644
--- a/src/com/android/camera/settings/SettingsManager.java
+++ b/src/com/android/camera/settings/SettingsManager.java
@@ -29,8 +29,8 @@ import com.android.camera.app.LocationManager;
import com.android.camera.debug.Log;
import com.android.camera.util.CameraUtil;
import com.android.camera.util.SettingsHelper;
-import com.android.camera.cameradevice.Size;
import com.android.camera2.R;
+import com.android.ex.camera2.portability.Size;
import java.util.ArrayList;
import java.util.List;
diff --git a/src/com/android/camera/settings/SettingsUtil.java b/src/com/android/camera/settings/SettingsUtil.java
index d559fa55e..166300861 100644
--- a/src/com/android/camera/settings/SettingsUtil.java
+++ b/src/com/android/camera/settings/SettingsUtil.java
@@ -23,13 +23,13 @@ import android.hardware.Camera.Parameters;
import android.media.CamcorderProfile;
import android.util.SparseArray;
-import com.android.camera.cameradevice.CameraManager;
-import com.android.camera.cameradevice.CameraSettings;
import com.android.camera.debug.Log;
import com.android.camera.settings.SettingsManager.SettingsCapabilities;
import com.android.camera.util.Callback;
-import com.android.camera.cameradevice.Size;
import com.android.camera2.R;
+import com.android.ex.camera2.portability.CameraAgent;
+import com.android.ex.camera2.portability.CameraSettings;
+import com.android.ex.camera2.portability.Size;
import java.util.ArrayList;
import java.util.Collections;
@@ -406,7 +406,7 @@ public class SettingsUtil {
* Determines and returns the capabilities of the given camera.
*/
public static SettingsCapabilities
- getSettingsCapabilities(CameraManager.CameraProxy camera) {
+ getSettingsCapabilities(CameraAgent.CameraProxy camera) {
final Parameters parameters = camera.getParameters();
return (new SettingsCapabilities() {
@Override
diff --git a/src/com/android/camera/util/CameraUtil.java b/src/com/android/camera/util/CameraUtil.java
index 715169527..02549eda5 100644
--- a/src/com/android/camera/util/CameraUtil.java
+++ b/src/com/android/camera/util/CameraUtil.java
@@ -53,12 +53,12 @@ import android.widget.Toast;
import com.android.camera.CameraActivity;
import com.android.camera.CameraDisabledException;
-import com.android.camera.cameradevice.CameraCapabilities;
-import com.android.camera.cameradevice.CameraSettings;
-import com.android.camera.cameradevice.Size;
import com.android.camera.debug.Log;
import com.android.camera.filmstrip.ImageData;
import com.android.camera2.R;
+import com.android.ex.camera2.portability.CameraCapabilities;
+import com.android.ex.camera2.portability.CameraSettings;
+import com.android.ex.camera2.portability.Size;
import java.io.Closeable;
import java.io.IOException;