Camera: move YUV size check

Move the check from FULL hardware level to BURST_CAPTURE
capability.

Bug: 19969183
Change-Id: I08bfd80db67cb9bcdd6895ce1f28e75b7518ad61
diff --git a/tests/tests/hardware/src/android/hardware/camera2/cts/ExtendedCameraCharacteristicsTest.java b/tests/tests/hardware/src/android/hardware/camera2/cts/ExtendedCameraCharacteristicsTest.java
index 9cd3df6..8619f73 100644
--- a/tests/tests/hardware/src/android/hardware/camera2/cts/ExtendedCameraCharacteristicsTest.java
+++ b/tests/tests/hardware/src/android/hardware/camera2/cts/ExtendedCameraCharacteristicsTest.java
@@ -18,6 +18,7 @@
 
 import android.content.Context;
 import android.graphics.ImageFormat;
+import android.graphics.Rect;
 import android.graphics.SurfaceTexture;
 import android.hardware.camera2.CameraCharacteristics;
 import android.hardware.camera2.CameraCharacteristics.Key;
@@ -350,6 +351,7 @@
      */
     public void testStaticBurstCharacteristics() {
         int counter = 0;
+        final float SIZE_ERROR_MARGIN = 0.03f;
         for (CameraCharacteristics c : mCharacteristics) {
             int[] actualCapabilities = c.get(CameraCharacteristics.REQUEST_AVAILABLE_CAPABILITIES);
             assertNotNull("android.request.availableCapabilities must never be null",
@@ -363,6 +365,8 @@
                     c.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
             assertNotNull(String.format("No stream configuration map found for: ID %s",
                     mIds[counter]), config);
+            Rect activeRect = c.get(CameraCharacteristics.SENSOR_INFO_ACTIVE_ARRAY_SIZE);
+            Size sensorSize = new Size(activeRect.width(), activeRect.height());
 
             // Ensure that max YUV size matches max JPEG size
             Size maxYuvSize = CameraTestUtils.getMaxSize(
@@ -373,6 +377,12 @@
                 (maxJpegSize.getWidth() <= maxYuvSize.getWidth() &&
                         maxJpegSize.getHeight() <= maxYuvSize.getHeight()) : false;
 
+            boolean maxYuvMatchSensor =
+                    (maxYuvSize.getWidth() <= sensorSize.getWidth() * (1.0 + SIZE_ERROR_MARGIN) &&
+                     maxYuvSize.getWidth() >= sensorSize.getWidth() * (1.0 - SIZE_ERROR_MARGIN) &&
+                     maxYuvSize.getHeight() <= sensorSize.getHeight() * (1.0 + SIZE_ERROR_MARGIN) &&
+                     maxYuvSize.getHeight() >= sensorSize.getHeight() * (1.0 - SIZE_ERROR_MARGIN));
+
             // Ensure that YUV output is fast enough - needs to be at least 20 fps
 
             long maxYuvRate =
@@ -427,12 +437,15 @@
                                 "(%d frames reported, [0, %d] frames expected)",
                                 mIds[counter], maxSyncLatency, MAX_LATENCY_BOUND),
                         haveFastSyncLatency);
+                assertTrue(
+                        "Active array size and max YUV size should be similar",
+                        maxYuvMatchSensor);
             } else {
                 assertTrue(
                         String.format("Camera device %s has all the requirements for BURST" +
                                 " capability but does not report it!", mIds[counter]),
-                        !(haveMaxYuv && haveMaxYuvRate &&
-                                haveFastAeTargetFps && haveFastSyncLatency));
+                        !(haveMaxYuv && haveMaxYuvRate && haveFastAeTargetFps &&
+                                haveFastSyncLatency && maxYuvMatchSensor));
             }
 
             counter++;
diff --git a/tests/tests/hardware/src/android/hardware/camera2/cts/StaticMetadataTest.java b/tests/tests/hardware/src/android/hardware/camera2/cts/StaticMetadataTest.java
index 014c752..b8c2f2e 100644
--- a/tests/tests/hardware/src/android/hardware/camera2/cts/StaticMetadataTest.java
+++ b/tests/tests/hardware/src/android/hardware/camera2/cts/StaticMetadataTest.java
@@ -33,8 +33,6 @@
 import android.util.Pair;
 import android.util.Size;
 
-import junit.framework.Assert;
-
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
@@ -88,13 +86,6 @@
                 mCollector.expectTrue("Full device must contain BURST_CAPTURE capability",
                         availableCaps.contains(REQUEST_AVAILABLE_CAPABILITIES_BURST_CAPTURE));
 
-                // Max yuv resolution must be very close to  sensor resolution
-                Size[] yuvSizes = configs.getOutputSizes(ImageFormat.YUV_420_888);
-                Size maxYuvSize = CameraTestUtils.getMaxSize(yuvSizes);
-                mCollector.expectSizesAreSimilar(
-                        "Active array size and max YUV size should be similar",
-                        sensorSize, maxYuvSize, SIZE_ERROR_MARGIN);
-
                 // Max resolution fps must be >= 20.
                 mCollector.expectTrue("Full device must support at least 20fps for max resolution",
                         getFpsForMaxSize(id) >= MIN_FPS_FOR_FULL_DEVICE);