summaryrefslogtreecommitdiffstats
path: root/core/java/android/hardware
diff options
context:
space:
mode:
authorZhijun He <zhijunhe@google.com>2013-10-01 11:09:28 -0700
committerZhijun He <zhijunhe@google.com>2013-10-01 14:26:40 -0700
commit18fe0ae08d49b0fe4b6414a3841bd0fcab5419e8 (patch)
treedff744e28e58d878f20aa6b299617198850c5445 /core/java/android/hardware
parent7eb5ce03d9697caa2e9caf0437036a937d081e90 (diff)
downloadframeworks_base-18fe0ae08d49b0fe4b6414a3841bd0fcab5419e8.zip
frameworks_base-18fe0ae08d49b0fe4b6414a3841bd0fcab5419e8.tar.gz
frameworks_base-18fe0ae08d49b0fe4b6414a3841bd0fcab5419e8.tar.bz2
Camera2: return device list with the only supported device
Bug: 10360518 Change-Id: I823f0b6965728ddefc9b70f3df0f50259919cce5
Diffstat (limited to 'core/java/android/hardware')
-rw-r--r--core/java/android/hardware/camera2/CameraManager.java22
1 files changed, 21 insertions, 1 deletions
diff --git a/core/java/android/hardware/camera2/CameraManager.java b/core/java/android/hardware/camera2/CameraManager.java
index 798ad7b..f5ee367 100644
--- a/core/java/android/hardware/camera2/CameraManager.java
+++ b/core/java/android/hardware/camera2/CameraManager.java
@@ -369,10 +369,30 @@ public final class CameraManager {
}
mDeviceIdList = new ArrayList<String>();
+ CameraMetadataNative info = new CameraMetadataNative();
for (int i = 0; i < numCameras; ++i) {
// Non-removable cameras use integers starting at 0 for their
// identifiers
- mDeviceIdList.add(String.valueOf(i));
+ boolean isDeviceSupported = false;
+ try {
+ mCameraService.getCameraCharacteristics(i, info);
+ if (!info.isEmpty()) {
+ isDeviceSupported = true;
+ } else {
+ throw new AssertionError("Expected to get non-empty characteristics");
+ }
+ } catch(IllegalArgumentException e) {
+ // Got a BAD_VALUE from service, meaning that this
+ // device is not supported.
+ } catch(CameraRuntimeException e) {
+ throw e.asChecked();
+ } catch(RemoteException e) {
+ // impossible
+ }
+
+ if (isDeviceSupported) {
+ mDeviceIdList.add(String.valueOf(i));
+ }
}
}