Camera2: Fix StreamConfigurationMap#isOutputSupportedFor for depth

Need to check the right configuration list if the format is a
depth format.

Also refactor code slightly to use SurfaceUtils when possible.

Bug: 21902551
Change-Id: Icca2e81d8144bede46ad9f117d5e010ed409887c
diff --git a/core/java/android/hardware/camera2/legacy/LegacyCameraDevice.java b/core/java/android/hardware/camera2/legacy/LegacyCameraDevice.java
index 2fb3203..e786707 100644
--- a/core/java/android/hardware/camera2/legacy/LegacyCameraDevice.java
+++ b/core/java/android/hardware/camera2/legacy/LegacyCameraDevice.java
@@ -605,6 +605,14 @@
         return LegacyExceptionUtils.throwOnError(nativeDetectSurfaceType(surface));
     }
 
+    /**
+     * Query the surface for its currently configured dataspace
+     */
+    public static int detectSurfaceDataspace(Surface surface) throws BufferQueueAbandonedException {
+        checkNotNull(surface);
+        return LegacyExceptionUtils.throwOnError(nativeDetectSurfaceDataspace(surface));
+    }
+
     static void configureSurface(Surface surface, int width, int height,
                                  int pixelFormat) throws BufferQueueAbandonedException {
         checkNotNull(surface);
@@ -702,6 +710,8 @@
 
     private static native int nativeDetectSurfaceType(Surface surface);
 
+    private static native int nativeDetectSurfaceDataspace(Surface surface);
+
     private static native int nativeDetectSurfaceDimens(Surface surface,
             /*out*/int[/*2*/] dimens);