summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Android.mk6
-rw-r--r--core/java/android/hardware/CameraInfo.aidl20
-rw-r--r--core/java/android/hardware/CameraInfo.java63
-rw-r--r--core/java/android/hardware/ICamera.aidl26
-rw-r--r--core/java/android/hardware/ICameraClient.aidl26
-rw-r--r--core/java/android/hardware/ICameraService.aidl48
-rw-r--r--core/java/android/hardware/ICameraServiceListener.aidl26
-rw-r--r--core/java/android/hardware/IProCameraCallbacks.aidl26
-rw-r--r--core/java/android/hardware/IProCameraUser.aidl26
-rw-r--r--media/tests/MediaFrameworkTest/AndroidManifest.xml5
-rw-r--r--media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaFrameworkIntegrationTestRunner.java54
-rw-r--r--media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaFrameworkTestRunner.java2
-rw-r--r--media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/CameraTest.java7
-rw-r--r--media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/integration/CameraBinderTest.java225
14 files changed, 558 insertions, 2 deletions
diff --git a/Android.mk b/Android.mk
index fad3f13..f0828b7 100644
--- a/Android.mk
+++ b/Android.mk
@@ -119,6 +119,12 @@ LOCAL_SRC_FILES += \
core/java/android/content/pm/IPackageMoveObserver.aidl \
core/java/android/content/pm/IPackageStatsObserver.aidl \
core/java/android/database/IContentObserver.aidl \
+ core/java/android/hardware/ICameraService.aidl \
+ core/java/android/hardware/ICameraServiceListener.aidl \
+ core/java/android/hardware/ICamera.aidl \
+ core/java/android/hardware/ICameraClient.aidl \
+ core/java/android/hardware/IProCameraUser.aidl \
+ core/java/android/hardware/IProCameraCallbacks.aidl \
core/java/android/hardware/ISerialManager.aidl \
core/java/android/hardware/display/IDisplayManager.aidl \
core/java/android/hardware/display/IDisplayManagerCallback.aidl \
diff --git a/core/java/android/hardware/CameraInfo.aidl b/core/java/android/hardware/CameraInfo.aidl
new file mode 100644
index 0000000..e21e694
--- /dev/null
+++ b/core/java/android/hardware/CameraInfo.aidl
@@ -0,0 +1,20 @@
+/*
+ * 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 android.hardware;
+
+/** @hide */
+parcelable CameraInfo;
diff --git a/core/java/android/hardware/CameraInfo.java b/core/java/android/hardware/CameraInfo.java
new file mode 100644
index 0000000..53da0ce
--- /dev/null
+++ b/core/java/android/hardware/CameraInfo.java
@@ -0,0 +1,63 @@
+/*
+ * 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 android.hardware;
+
+import android.os.Parcel;
+import android.os.Parcelable;
+
+/**
+ * Information about a camera
+ *
+ * @hide
+ */
+public class CameraInfo implements Parcelable {
+ // Can't parcel nested classes, so make this a top level class that composes
+ // CameraInfo.
+ public Camera.CameraInfo info = new Camera.CameraInfo();
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public void writeToParcel(Parcel out, int flags) {
+ out.writeInt(info.facing);
+ out.writeInt(info.orientation);
+ }
+
+ public void readFromParcel(Parcel in) {
+ info.facing = in.readInt();
+ info.orientation = in.readInt();
+ }
+
+ public static final Parcelable.Creator<CameraInfo> CREATOR =
+ new Parcelable.Creator<CameraInfo>() {
+ @Override
+ public CameraInfo createFromParcel(Parcel in) {
+ CameraInfo info = new CameraInfo();
+ info.readFromParcel(in);
+
+ return info;
+ }
+
+ @Override
+ public CameraInfo[] newArray(int size) {
+ return new CameraInfo[size];
+ }
+ };
+};
diff --git a/core/java/android/hardware/ICamera.aidl b/core/java/android/hardware/ICamera.aidl
new file mode 100644
index 0000000..d4f64f8
--- /dev/null
+++ b/core/java/android/hardware/ICamera.aidl
@@ -0,0 +1,26 @@
+/*
+ * 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 android.hardware;
+
+/** @hide */
+interface ICamera
+{
+ /**
+ * Keep up-to-date with frameworks/av/include/camera/ICamera.h
+ */
+ void disconnect();
+}
diff --git a/core/java/android/hardware/ICameraClient.aidl b/core/java/android/hardware/ICameraClient.aidl
new file mode 100644
index 0000000..d7877b4
--- /dev/null
+++ b/core/java/android/hardware/ICameraClient.aidl
@@ -0,0 +1,26 @@
+/*
+ * 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 android.hardware;
+
+/** @hide */
+interface ICameraClient
+{
+ /**
+ * Keep up-to-date with frameworks/av/include/camera/ICameraClient.h
+ */
+ // TODO: consider implementing this.
+}
diff --git a/core/java/android/hardware/ICameraService.aidl b/core/java/android/hardware/ICameraService.aidl
new file mode 100644
index 0000000..b8fbfdb
--- /dev/null
+++ b/core/java/android/hardware/ICameraService.aidl
@@ -0,0 +1,48 @@
+/*
+ * 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 android.hardware;
+
+import android.hardware.ICamera;
+import android.hardware.ICameraClient;
+import android.hardware.IProCameraUser;
+import android.hardware.IProCameraCallbacks;
+import android.hardware.ICameraServiceListener;
+import android.hardware.CameraInfo;
+
+/** @hide */
+interface ICameraService
+{
+ /**
+ * Keep up-to-date with frameworks/av/include/camera/ICameraService.h
+ */
+ int getNumberOfCameras();
+
+ // rest of 'int' return values in this file are actually status_t
+
+ int getCameraInfo(int cameraId, out CameraInfo info);
+
+ ICamera connect(ICameraClient client, int cameraId,
+ String clientPackageName,
+ int clientUid);
+
+ IProCameraUser connectPro(IProCameraCallbacks callbacks, int cameraId,
+ String clientPackageName,
+ int clientUid);
+
+ int addListener(ICameraServiceListener listener);
+ int removeListener(ICameraServiceListener listener);
+}
diff --git a/core/java/android/hardware/ICameraServiceListener.aidl b/core/java/android/hardware/ICameraServiceListener.aidl
new file mode 100644
index 0000000..c548496
--- /dev/null
+++ b/core/java/android/hardware/ICameraServiceListener.aidl
@@ -0,0 +1,26 @@
+/*
+ * 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 android.hardware;
+
+/** @hide */
+interface ICameraServiceListener
+{
+ /**
+ * Keep up-to-date with frameworks/av/include/camera/ICameraServiceListener.h
+ */
+ void onStatusChanged(int status, int cameraId);
+}
diff --git a/core/java/android/hardware/IProCameraCallbacks.aidl b/core/java/android/hardware/IProCameraCallbacks.aidl
new file mode 100644
index 0000000..a09b452
--- /dev/null
+++ b/core/java/android/hardware/IProCameraCallbacks.aidl
@@ -0,0 +1,26 @@
+/*
+ * 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 android.hardware;
+
+/** @hide */
+interface IProCameraCallbacks
+{
+ /**
+ * Keep up-to-date with frameworks/av/include/camera/IProCameraCallbacks.h
+ */
+ // TODO: consider implementing this.
+}
diff --git a/core/java/android/hardware/IProCameraUser.aidl b/core/java/android/hardware/IProCameraUser.aidl
new file mode 100644
index 0000000..eacb0f4
--- /dev/null
+++ b/core/java/android/hardware/IProCameraUser.aidl
@@ -0,0 +1,26 @@
+/*
+ * 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 android.hardware;
+
+/** @hide */
+interface IProCameraUser
+{
+ /**
+ * Keep up-to-date with frameworks/av/include/camera/IProCameraUser.h
+ */
+ void disconnect();
+}
diff --git a/media/tests/MediaFrameworkTest/AndroidManifest.xml b/media/tests/MediaFrameworkTest/AndroidManifest.xml
index b698705..91ee2c6 100644
--- a/media/tests/MediaFrameworkTest/AndroidManifest.xml
+++ b/media/tests/MediaFrameworkTest/AndroidManifest.xml
@@ -71,4 +71,9 @@
android:label="Media Power tests InstrumentationRunner">
</instrumentation>
+ <instrumentation android:name=".MediaFrameworkIntegrationTestRunner"
+ android:targetPackage="com.android.mediaframeworktest"
+ android:label="MediaFramework integration tests InstrumentationRunner">
+ </instrumentation>
+
</manifest>
diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaFrameworkIntegrationTestRunner.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaFrameworkIntegrationTestRunner.java
new file mode 100644
index 0000000..88c5b0c
--- /dev/null
+++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaFrameworkIntegrationTestRunner.java
@@ -0,0 +1,54 @@
+/*
+ * 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.mediaframeworktest;
+
+import android.os.Bundle;
+import android.test.InstrumentationTestRunner;
+import android.test.InstrumentationTestSuite;
+
+import com.android.mediaframeworktest.integration.CameraBinderTest;
+
+import junit.framework.TestSuite;
+
+/**
+ * Instrumentation Test Runner for all media framework integration tests.
+ *
+ * Running all tests:
+ *
+ * adb shell am instrument -w com.android.mediaframeworktest/.MediaFrameworkIntegrationTestRunner
+ */
+
+public class MediaFrameworkIntegrationTestRunner extends InstrumentationTestRunner {
+
+
+ @Override
+ public TestSuite getAllTests() {
+ TestSuite suite = new InstrumentationTestSuite(this);
+ suite.addTestSuite(CameraBinderTest.class);
+ return suite;
+ }
+
+ @Override
+ public ClassLoader getLoader() {
+ return MediaFrameworkIntegrationTestRunner.class.getClassLoader();
+ }
+
+ @Override
+ public void onCreate(Bundle icicle) {
+ super.onCreate(icicle);
+ }
+}
diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaFrameworkTestRunner.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaFrameworkTestRunner.java
index 92ac9eb..cbb6642 100644
--- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaFrameworkTestRunner.java
+++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaFrameworkTestRunner.java
@@ -50,7 +50,7 @@ import android.test.InstrumentationTestSuite;
* Running all tests:
*
* adb shell am instrument \
- * -w com.android.smstests.MediaPlayerInstrumentationTestRunner
+ * -w com.android.mediaframeworktest/.MediaFrameworkTestRunner
*/
public class MediaFrameworkTestRunner extends InstrumentationTestRunner {
diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/CameraTest.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/CameraTest.java
index 2f864d7..7f23ba5 100644
--- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/CameraTest.java
+++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/CameraTest.java
@@ -36,7 +36,12 @@ import java.io.*;
/**
* Junit / Instrumentation test case for the camera api
-
+ *
+ * To run only tests in this class:
+ *
+ * adb shell am instrument \
+ * -e class com.android.mediaframeworktest.functional.CameraTest \
+ * -w com.android.mediaframeworktest/.MediaFrameworkTestRunner
*/
public class CameraTest extends ActivityInstrumentationTestCase<MediaFrameworkTest> {
private String TAG = "CameraTest";
diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/integration/CameraBinderTest.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/integration/CameraBinderTest.java
new file mode 100644
index 0000000..ba2859b
--- /dev/null
+++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/integration/CameraBinderTest.java
@@ -0,0 +1,225 @@
+/*
+ * 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.mediaframeworktest.integration;
+
+import android.content.Context;
+import android.content.pm.FeatureInfo;
+import android.content.pm.PackageManager;
+import android.hardware.CameraInfo;
+import android.hardware.ICamera;
+import android.hardware.ICameraClient;
+import android.hardware.ICameraService;
+import android.hardware.ICameraServiceListener;
+import android.hardware.IProCameraCallbacks;
+import android.hardware.IProCameraUser;
+import android.os.Binder;
+import android.os.IBinder;
+import android.os.RemoteException;
+import android.os.ServiceManager;
+import android.test.AndroidTestCase;
+import android.test.suitebuilder.annotation.SmallTest;
+import android.util.Log;
+
+/**
+ * Junit / Instrumentation test case for the camera2 api
+ *
+ * To run only tests in
+ * this class:
+ *
+ * adb shell am instrument \
+ * -e class com.android.mediaframeworktest.integration.CameraBinderTest \
+ * -w com.android.mediaframeworktest/.MediaFrameworkIntegrationTestRunner
+ */
+public class CameraBinderTest extends AndroidTestCase {
+ private static String TAG = "CameraBinderTest";
+
+ private static final String CAMERA_SERVICE_BINDER_NAME = "media.camera";
+ private static final int NO_ERROR = 0;
+ private static final int ALREADY_EXISTS = -17;
+ private static final int BAD_VALUE = -22;
+
+ private static final int USE_CALLING_UID = -1;
+
+ private ICameraService mCameraService;
+ private int mGuessedNumCameras = 0;
+
+ public CameraBinderTest() {
+ }
+
+ private final static boolean isFeatureAvailable(Context context, String feature) {
+ final PackageManager packageManager = context.getPackageManager();
+ final FeatureInfo[] featuresList = packageManager.getSystemAvailableFeatures();
+ for (FeatureInfo f : featuresList) {
+ if (f.name != null && f.name.equals(feature)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ // Guess the lower bound for how many cameras there are
+ private void guessNumCameras() {
+
+ /**
+ * Why do we need this? This way we have no dependency on getNumCameras
+ * actually working. On most systems there are only 0, 1, or 2 cameras,
+ * and this covers that 'usual case'. On other systems there might be 3+
+ * cameras, but this will at least check the first 2.
+ */
+ mGuessedNumCameras = 0;
+
+ // Front facing camera
+ if (isFeatureAvailable(getContext(), PackageManager.FEATURE_CAMERA_FRONT)) {
+ mGuessedNumCameras++;
+ }
+
+ // Back facing camera
+ if (isFeatureAvailable(getContext(), PackageManager.FEATURE_CAMERA)) {
+ mGuessedNumCameras++;
+ }
+
+ // Any facing camera
+ if (mGuessedNumCameras == 0
+ && isFeatureAvailable(getContext(), PackageManager.FEATURE_CAMERA_ANY)) {
+ mGuessedNumCameras++;
+ }
+
+ Log.v(TAG, "Guessing there are at least " + mGuessedNumCameras + " cameras");
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ guessNumCameras();
+
+ IBinder cameraServiceBinder = ServiceManager.getService(CAMERA_SERVICE_BINDER_NAME);
+ assertNotNull("Camera service IBinder should not be null", cameraServiceBinder);
+
+ mCameraService = ICameraService.Stub.asInterface(cameraServiceBinder);
+ assertNotNull("Camera service should not be null", mCameraService);
+ }
+
+ @SmallTest
+ public void testNumberOfCameras() throws Exception {
+ int numCameras = mCameraService.getNumberOfCameras();
+ assertTrue("At least this many cameras: " + mGuessedNumCameras,
+ numCameras >= mGuessedNumCameras);
+ Log.v(TAG, "Number of cameras " + numCameras);
+ }
+
+ @SmallTest
+ public void testCameraInfo() throws Exception {
+ for (int cameraId = 0; cameraId < mGuessedNumCameras; ++cameraId) {
+
+ CameraInfo info = new CameraInfo();
+ info.info.facing = -1;
+ info.info.orientation = -1;
+
+ assertTrue("Camera service returned info for camera " + cameraId,
+ mCameraService.getCameraInfo(cameraId, info) == NO_ERROR);
+ assertTrue("Facing was not set for camera " + cameraId, info.info.facing != -1);
+ assertTrue("Orientation was not set for camera " + cameraId,
+ info.info.orientation != -1);
+
+ Log.v(TAG, "Camera " + cameraId + " info: facing " + info.info.facing
+ + ", orientation " + info.info.orientation);
+ }
+ }
+
+ static abstract class DummyBase extends Binder implements android.os.IInterface {
+ @Override
+ public IBinder asBinder() {
+ return this;
+ }
+ }
+
+ static class DummyCameraClient extends DummyBase implements ICameraClient {
+ }
+
+ @SmallTest
+ public void testConnect() throws Exception {
+ for (int cameraId = 0; cameraId < mGuessedNumCameras; ++cameraId) {
+
+ ICameraClient dummyCallbacks = new DummyCameraClient();
+
+ String clientPackageName = getContext().getPackageName();
+
+ ICamera cameraUser = mCameraService.connect(dummyCallbacks, cameraId, clientPackageName,
+ USE_CALLING_UID);
+ assertNotNull(String.format("Camera %s was null", cameraId), cameraUser);
+
+ Log.v(TAG, String.format("Camera %s connected", cameraId));
+
+ cameraUser.disconnect();
+ }
+ }
+
+ static class DummyProCameraCallbacks extends DummyBase implements IProCameraCallbacks {
+ }
+
+ @SmallTest
+ public void testConnectPro() throws Exception {
+ for (int cameraId = 0; cameraId < mGuessedNumCameras; ++cameraId) {
+
+ IProCameraCallbacks dummyCallbacks = new DummyProCameraCallbacks();
+
+ String clientPackageName = getContext().getPackageName();
+
+ IProCameraUser cameraUser = mCameraService.connectPro(dummyCallbacks, cameraId,
+ clientPackageName, USE_CALLING_UID);
+ assertNotNull(String.format("Camera %s was null", cameraId), cameraUser);
+
+ Log.v(TAG, String.format("Camera %s connected", cameraId));
+
+ cameraUser.disconnect();
+ }
+ }
+
+ static class DummyCameraServiceListener extends DummyBase implements ICameraServiceListener {
+ @Override
+ public void onStatusChanged(int status, int cameraId)
+ throws RemoteException {
+ Log.v(TAG, String.format("Camera %d has status changed to 0x%x", cameraId, status));
+ }
+ }
+
+ /**
+ * adb shell am instrument \
+ * -e class 'com.android.mediaframeworktest.integration.CameraBinderTest#testAddRemoveListeners' \
+ * -w com.android.mediaframeworktest/.MediaFrameworkIntegrationTestRunner
+ */
+ @SmallTest
+ public void testAddRemoveListeners() throws Exception {
+ for (int cameraId = 0; cameraId < mGuessedNumCameras; ++cameraId) {
+
+ ICameraServiceListener listener = new DummyCameraServiceListener();
+
+ assertTrue("Listener was removed before added",
+ mCameraService.removeListener(listener) == BAD_VALUE);
+
+ assertTrue("Listener was not added", mCameraService.addListener(listener) == NO_ERROR);
+ assertTrue("Listener was wrongly added again",
+ mCameraService.addListener(listener) == ALREADY_EXISTS);
+
+ assertTrue("Listener was not removed",
+ mCameraService.removeListener(listener) == NO_ERROR);
+ assertTrue("Listener was wrongly removed again",
+ mCameraService.removeListener(listener) == BAD_VALUE);
+ }
+ }
+}