OSDN Git Service

am 46b3c730: Merge "Fix crash on Shamu since it\'s no longer camera 2 FULL." into...
authorSascha Haeberling <haeberling@google.com>
Mon, 25 Aug 2014 22:07:44 +0000 (22:07 +0000)
committerAndroid Git Automerger <android-git-automerger@android.com>
Mon, 25 Aug 2014 22:07:44 +0000 (22:07 +0000)
* commit '46b3c730aa059bf5103922ae0c36c13a12e98223':
  Fix crash on Shamu since it's no longer camera 2 FULL.

src/com/android/camera/one/OneCameraManager.java

index 25f34cb..dc83d14 100644 (file)
@@ -86,7 +86,7 @@ public abstract class OneCameraManager {
                 .getSystemService(Context.CAMERA_SERVICE);
         int maxMemoryMB = activity.getServices().getMemoryManager()
                 .getMaxAllowedNativeMemoryAllocation();
-        if (cameraManager != null && isCamera2FullySupported(cameraManager)) {
+        if (cameraManager != null && isCamera2Supported(cameraManager)) {
             return new com.android.camera.one.v2.OneCameraManagerImpl(cameraManager, maxMemoryMB,
                     displayMetrics);
         } else {
@@ -95,7 +95,7 @@ public abstract class OneCameraManager {
     }
 
     /**
-     * Returns whether the device fully supports API2,
+     * Returns whether the device fully supports API2
      *
      * @param cameraManager the Camera2 API manager.
      * @return If this device is only emulating Camera2 API on top of an older
@@ -103,12 +103,16 @@ public abstract class OneCameraManager {
      *         only returns true, if Camera2 is fully supported through newer
      *         HALs.
      */
-    private static boolean isCamera2FullySupported(CameraManager cameraManager) {
+    private static boolean isCamera2Supported(CameraManager cameraManager) {
         try {
             final String id = cameraManager.getCameraIdList()[0];
+            // TODO: We should check for all the flags we need to ensure the
+            // device is capable of taking Camera2 API shots. For now, let's
+            // accept all device that are either 'partial' or 'full' devices
+            // (but not legacy).
             return cameraManager.getCameraCharacteristics(id).get(
                     CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL)
-                == CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_FULL;
+                != CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY;
         } catch (CameraAccessException ex) {
             Log.e(TAG, "Could not access camera to determine hardware-level API support.");
             return false;