summaryrefslogtreecommitdiffstats
path: root/camera2/utils/tests/src/com
diff options
context:
space:
mode:
authorSol Boucher <solb@google.com>2014-07-22 18:39:32 -0700
committerSol Boucher <solb@google.com>2014-08-07 15:02:05 -0700
commitde48004068f8c16f9a56c60b0ed2485a67687b4b (patch)
treecc584bbc1756d0f5f00367f39565288679728809 /camera2/utils/tests/src/com
parentd4e5286bb4145e0371b783158fc8411565429c9b (diff)
downloadandroid_frameworks_ex-de48004068f8c16f9a56c60b0ed2485a67687b4b.tar.gz
android_frameworks_ex-de48004068f8c16f9a56c60b0ed2485a67687b4b.tar.bz2
android_frameworks_ex-de48004068f8c16f9a56c60b0ed2485a67687b4b.zip
camera2-portability: Support photo capture using camera2 API
This implements JPEG capture, including an autoexposure precapture sequence. There are many changes to AndroidCamera2Capabilities and AndroidCamera2Settings to support the representation of modes (e.g. flash modes) whose flags do not map trivially between the API implementations. Part of this work is the conversion of AndroidCamera2AgentImpl to use and store a Camera2RequestSettingsSet instead of a bare API 2 CaptureRequest.Builder. Change-Id: I03f9f98c954a7b0c140ac8d80161878c92ef65d2
Diffstat (limited to 'camera2/utils/tests/src/com')
-rw-r--r--camera2/utils/tests/src/com/android/ex/camera2/utils/Camera2DeviceTester.java93
-rw-r--r--camera2/utils/tests/src/com/android/ex/camera2/utils/Camera2UtilsTest.java70
2 files changed, 94 insertions, 69 deletions
diff --git a/camera2/utils/tests/src/com/android/ex/camera2/utils/Camera2DeviceTester.java b/camera2/utils/tests/src/com/android/ex/camera2/utils/Camera2DeviceTester.java
new file mode 100644
index 0000000..4db6dfb
--- /dev/null
+++ b/camera2/utils/tests/src/com/android/ex/camera2/utils/Camera2DeviceTester.java
@@ -0,0 +1,93 @@
+/*
+ * 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.ex.camera2.utils;
+
+import android.content.Context;
+import android.hardware.camera2.CameraDevice;
+import android.hardware.camera2.CameraManager;
+import android.os.Handler;
+import android.os.HandlerThread;
+import android.support.test.InjectContext;
+
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+
+/**
+ * Subclasses of this have an {@code mCamera} instance variable representing the first camera.
+ */
+public class Camera2DeviceTester {
+ private static HandlerThread sThread;
+
+ private static Handler sHandler;
+
+ @BeforeClass
+ public static void setupBackgroundHandler() {
+ sThread = new HandlerThread("CameraFramework");
+ sThread.start();
+ sHandler = new Handler(sThread.getLooper());
+ }
+
+ @AfterClass
+ public static void teardownBackgroundHandler() throws Exception {
+ sThread.quitSafely();
+ sThread.join();
+ }
+
+ @InjectContext
+ public Context mContext;
+
+ private class DeviceCapturer extends CameraDevice.StateListener {
+ private CameraDevice mCamera;
+
+ public CameraDevice captureCameraDevice() throws Exception {
+ CameraManager manager =
+ (CameraManager) mContext.getSystemService(Context.CAMERA_SERVICE);
+ String id = manager.getCameraIdList()[0];
+ synchronized (this) {
+ manager.openCamera(id, this, sHandler);
+ wait();
+ }
+ return mCamera;
+ }
+
+ @Override
+ public synchronized void onOpened(CameraDevice camera) {
+ mCamera = camera;
+ notify();
+ }
+
+ @Override
+ public void onDisconnected(CameraDevice camera) {}
+
+ @Override
+ public void onError(CameraDevice camera, int error) {}
+ }
+
+ protected CameraDevice mCamera;
+
+ @Before
+ public void obtainCameraCaptureRequestBuilderFactory() throws Exception {
+ mCamera = new DeviceCapturer().captureCameraDevice();
+ }
+
+ @After
+ public void releaseCameraCaptureRequestBuilderFactory() {
+ mCamera.close();
+ }
+}
diff --git a/camera2/utils/tests/src/com/android/ex/camera2/utils/Camera2UtilsTest.java b/camera2/utils/tests/src/com/android/ex/camera2/utils/Camera2UtilsTest.java
index dd9566b..bb23e37 100644
--- a/camera2/utils/tests/src/com/android/ex/camera2/utils/Camera2UtilsTest.java
+++ b/camera2/utils/tests/src/com/android/ex/camera2/utils/Camera2UtilsTest.java
@@ -23,24 +23,15 @@ import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
-import android.content.Context;
import android.hardware.camera2.CameraCaptureSession.CaptureListener;
import android.hardware.camera2.CameraDevice;
-import android.hardware.camera2.CameraManager;
import android.hardware.camera2.CaptureRequest;
import android.hardware.camera2.CaptureRequest.Key;
-import android.os.Handler;
-import android.os.HandlerThread;
-import android.support.test.InjectContext;
import android.view.Surface;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
import org.junit.Test;
-public class Camera2UtilsTest {
+public class Camera2UtilsTest extends Camera2DeviceTester {
private void captureListenerSplitterAllCallbacksReceived(CaptureListener splitter,
CaptureListener... terminals) {
splitter.onCaptureCompleted(null, null, null);
@@ -152,65 +143,6 @@ public class Camera2UtilsTest {
assertFalse(setUp.contains(CaptureRequest.CONTROL_AE_LOCK));
}
- private static HandlerThread sThread;
-
- private static Handler sHandler;
-
- @BeforeClass
- public static void setupBackgroundHandler() {
- sThread = new HandlerThread("CameraFramework");
- sThread.start();
- sHandler = new Handler(sThread.getLooper());
- }
-
- @AfterClass
- public static void teardownBackgroundHandler() throws Exception {
- sThread.quitSafely();
- sThread.join();
- }
-
- @InjectContext
- public Context mContext;
-
- public class DeviceCapturer extends CameraDevice.StateListener {
- private CameraDevice mCamera;
-
- public CameraDevice captureCameraDevice() throws Exception {
- CameraManager manager =
- (CameraManager) mContext.getSystemService(Context.CAMERA_SERVICE);
- String id = manager.getCameraIdList()[0];
- synchronized (this) {
- manager.openCamera(id, this, sHandler);
- wait();
- }
- return mCamera;
- }
-
- @Override
- public synchronized void onOpened(CameraDevice camera) {
- mCamera = camera;
- notify();
- }
-
- @Override
- public void onDisconnected(CameraDevice camera) {}
-
- @Override
- public void onError(CameraDevice camera, int error) {}
- }
-
- private CameraDevice mCamera;
-
- @Before
- public void obtainCameraCaptureRequestBuilderFactory() throws Exception {
- mCamera = new DeviceCapturer().captureCameraDevice();
- }
-
- @After
- public void releaseCameraCaptureRequestBuilderFactory() {
- mCamera.close();
- }
-
@Test
public void requestSettingsSetStartsWithoutChanges() {
Camera2RequestSettingsSet setUp = new Camera2RequestSettingsSet();