summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcodeworkx <daniel.hillenbrand@codeworkx.de>2017-08-13 10:22:05 (GMT)
committercodeworkx <daniel.hillenbrand@codeworkx.de>2017-08-13 10:22:05 (GMT)
commit70dbc05d00a5e6011f532d029c50bfb4a17a2e57 (patch)
tree8b167c4b6f6cff952e81f1140542d4eebca997f7
parent0eed7503d2e3afeefccc0b753167a1a273605cb2 (diff)
downloadandroid_packages_apps_Snap-70dbc05d00a5e6011f532d029c50bfb4a17a2e57.zip
android_packages_apps_Snap-70dbc05d00a5e6011f532d029c50bfb4a17a2e57.tar.gz
android_packages_apps_Snap-70dbc05d00a5e6011f532d029c50bfb4a17a2e57.tar.bz2
Snap: add missing null check on isCamera2Supported
Change-Id: Ic1437db15763cf342088b8911298433d9ccd26ae
-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 214e716..61cced2 100644
--- a/src/com/android/camera/util/CameraUtil.java
+++ b/src/com/android/camera/util/CameraUtil.java
@@ -383,18 +383,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(cameraIds[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");