summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcodeworkx <daniel.hillenbrand@codeworkx.de>2017-08-13 12:22:05 +0200
committerDaniel Hillenbrand <daniel.hillenbrand@codeworkx.de>2018-03-11 15:31:24 +0000
commitd600a3b51b1f2e74b30a286f90bbbf16da69262e (patch)
treea068173478241cb7886ee146bf04b32ca5760717
parentea3d12e41cb9626e4ffe3b976dda98f5c5630306 (diff)
downloadandroid_packages_apps_Snap-d600a3b51b1f2e74b30a286f90bbbf16da69262e.zip
android_packages_apps_Snap-d600a3b51b1f2e74b30a286f90bbbf16da69262e.tar.gz
android_packages_apps_Snap-d600a3b51b1f2e74b30a286f90bbbf16da69262e.tar.bz2
Snap: add missing null check on isCamera2Supported
Change-Id: I61c04c7cb8d344573ab7fb11f7114f09aaf24fb7
-rw-r--r--src/com/android/camera/util/CameraUtil.java28
1 files changed, 16 insertions, 12 deletions
diff --git a/src/com/android/camera/util/CameraUtil.java b/src/com/android/camera/util/CameraUtil.java
index 8835661..2f7e6cb 100644
--- a/src/com/android/camera/util/CameraUtil.java
+++ b/src/com/android/camera/util/CameraUtil.java
@@ -410,18 +410,22 @@ public class CameraUtil {
android.hardware.camera2.CameraManager manager = (android.hardware.camera2.CameraManager)context.getSystemService(Context.CAMERA_SERVICE);
try {
- CameraCharacteristics characteristics = manager.getCameraCharacteristics(manager.getCameraIdList()[0]);
- int deviceLevel = characteristics.get(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL);
-
- switch (deviceLevel) {
- case CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED:
- return true;
- case CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_FULL:
- return true;
- case CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_3:
- return true;
- default:
- return false;
+ String[] cameraIds = manager.getCameraIdList();
+
+ if (cameraIds != null && cameraIds.length > 0) {
+ CameraCharacteristics characteristics = manager.getCameraCharacteristics(manager.getCameraIdList()[0]);
+ int deviceLevel = characteristics.get(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL);
+
+ switch (deviceLevel) {
+ case CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED:
+ return true;
+ case CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_FULL:
+ return true;
+ case CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_3:
+ return true;
+ default:
+ return false;
+ }
}
} catch(CameraAccessException | NumberFormatException e) {
Log.e(TAG, "exception trying to get camera characteristics");