summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorEino-Ville Talvala <etalvala@google.com>2015-08-15 00:46:15 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-08-15 00:46:15 +0000
commit1017f9862fb2cdfbff0abe12ef7d20b657a38e36 (patch)
tree52c57562c34b950f65b8e0770866bf121ed98c7a /core
parent6fa531e0153d9b76994adbc631fed0a591e7ef93 (diff)
parent5717612ba9ac78021e81f5b45ca7903c318499f9 (diff)
downloadframeworks_base-1017f9862fb2cdfbff0abe12ef7d20b657a38e36.zip
frameworks_base-1017f9862fb2cdfbff0abe12ef7d20b657a38e36.tar.gz
frameworks_base-1017f9862fb2cdfbff0abe12ef7d20b657a38e36.tar.bz2
Merge "Camera2: Add camera type to getNumberOfCameras." into mnc-dev
Diffstat (limited to 'core')
-rw-r--r--core/java/android/hardware/ICameraService.aidl2
-rw-r--r--core/java/android/hardware/camera2/CameraManager.java5
-rw-r--r--core/jni/android_hardware_Camera.cpp6
3 files changed, 11 insertions, 2 deletions
diff --git a/core/java/android/hardware/ICameraService.aidl b/core/java/android/hardware/ICameraService.aidl
index c933f92..0b165cd 100644
--- a/core/java/android/hardware/ICameraService.aidl
+++ b/core/java/android/hardware/ICameraService.aidl
@@ -35,7 +35,7 @@ interface ICameraService
/**
* Keep up-to-date with frameworks/av/include/camera/ICameraService.h
*/
- int getNumberOfCameras();
+ int getNumberOfCameras(int type);
// rest of 'int' return values in this file are actually status_t
diff --git a/core/java/android/hardware/camera2/CameraManager.java b/core/java/android/hardware/camera2/CameraManager.java
index 2e4f628..1fcfaca 100644
--- a/core/java/android/hardware/camera2/CameraManager.java
+++ b/core/java/android/hardware/camera2/CameraManager.java
@@ -64,6 +64,9 @@ public final class CameraManager {
private static final int API_VERSION_1 = 1;
private static final int API_VERSION_2 = 2;
+ private static final int CAMERA_TYPE_BACKWARD_COMPATIBLE = 0;
+ private static final int CAMERA_TYPE_ALL = 1;
+
private ArrayList<String> mDeviceIdList;
private final Context mContext;
@@ -615,7 +618,7 @@ public final class CameraManager {
}
try {
- numCameras = cameraService.getNumberOfCameras();
+ numCameras = cameraService.getNumberOfCameras(CAMERA_TYPE_ALL);
} catch(CameraRuntimeException e) {
throw e.asChecked();
} catch (RemoteException e) {
diff --git a/core/jni/android_hardware_Camera.cpp b/core/jni/android_hardware_Camera.cpp
index 169fb60..4f44c26 100644
--- a/core/jni/android_hardware_Camera.cpp
+++ b/core/jni/android_hardware_Camera.cpp
@@ -497,6 +497,12 @@ static void android_hardware_Camera_getCameraInfo(JNIEnv *env, jobject thiz,
jint cameraId, jobject info_obj)
{
CameraInfo cameraInfo;
+ if (cameraId >= Camera::getNumberOfCameras() || cameraId < 0) {
+ ALOGE("%s: Unknown camera ID %d", __FUNCTION__, cameraId);
+ jniThrowRuntimeException(env, "Unknown camera ID");
+ return;
+ }
+
status_t rc = Camera::getCameraInfo(cameraId, &cameraInfo);
if (rc != NO_ERROR) {
jniThrowRuntimeException(env, "Fail to get camera info");