Camera2: initialize supported video sizes correctly

The size bound should be set based on the max supported size from
CamCorderProfile

Bug: 16963525
Change-Id: Iaa66867599b7cc97c45822bdfa2a98daf8b9cdf9
diff --git a/tests/tests/hardware/src/android/hardware/camera2/cts/CameraTestUtils.java b/tests/tests/hardware/src/android/hardware/camera2/cts/CameraTestUtils.java
index bbfd7b5..1f4fc49 100644
--- a/tests/tests/hardware/src/android/hardware/camera2/cts/CameraTestUtils.java
+++ b/tests/tests/hardware/src/android/hardware/camera2/cts/CameraTestUtils.java
@@ -70,8 +70,10 @@
     private static final String TAG = "CameraTestUtils";
     private static final boolean VERBOSE = Log.isLoggable(TAG, Log.VERBOSE);
     private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
-    // Only test the preview and video size that is no larger than 1080p.
-    public static final Size PREVIEW_SIZE_BOUND = new Size(1920, 1080);
+    public static final Size SIZE_BOUND_1080P = new Size(1920, 1088);
+    public static final Size SIZE_BOUND_2160P = new Size(3840, 2160);
+    // Only test the preview size that is no larger than 1080p.
+    public static final Size PREVIEW_SIZE_BOUND = SIZE_BOUND_1080P;
     // Default timeouts for reaching various states
     public static final int CAMERA_OPEN_TIMEOUT_MS = 2000;
     public static final int CAMERA_CLOSE_TIMEOUT_MS = 2000;
diff --git a/tests/tests/hardware/src/android/hardware/camera2/cts/RecordingTest.java b/tests/tests/hardware/src/android/hardware/camera2/cts/RecordingTest.java
index 652462c..05b6243 100644
--- a/tests/tests/hardware/src/android/hardware/camera2/cts/RecordingTest.java
+++ b/tests/tests/hardware/src/android/hardware/camera2/cts/RecordingTest.java
@@ -56,7 +56,6 @@
     private static final String TAG = "RecordingTest";
     private static final boolean VERBOSE = Log.isLoggable(TAG, Log.VERBOSE);
     private static final boolean DEBUG_DUMP = false;
-    private static final Size VIDEO_SIZE_BOUND = new Size(1920, 1080);
     private static final int RECORDING_DURATION_MS = 2000;
     private static final int DURATION_MARGIN_MS = 400;
     private static final int FRAME_DURATION_ERROR_TOLERANCE_MS = 3;
@@ -116,8 +115,8 @@
                 // Re-use the MediaRecorder object for the same camera device.
                 mMediaRecorder = new MediaRecorder();
                 openDevice(mCameraIds[i]);
-                mSupportedVideoSizes = getSupportedVideoSizes(mCamera.getId(), mCameraManager,
-                        VIDEO_SIZE_BOUND);
+
+                initSupportedVideoSize(mCameraIds[i]);
 
                 basicRecordingTestByCamera();
             } finally {
@@ -145,8 +144,7 @@
                 mMediaRecorder = new MediaRecorder();
                 openDevice(mCameraIds[i]);
 
-                mSupportedVideoSizes = getSupportedVideoSizes(mCamera.getId(), mCameraManager,
-                        VIDEO_SIZE_BOUND);
+                initSupportedVideoSize(mCameraIds[i]);
 
                 recordingSizeTestByCamera();
             } finally {
@@ -470,6 +468,18 @@
     }
 
     /**
+     * Initialize the supported video sizes.
+     */
+    private void initSupportedVideoSize(String cameraId)  throws Exception {
+        Size maxVideoSize = SIZE_BOUND_1080P;
+        if (CamcorderProfile.hasProfile(CamcorderProfile.QUALITY_2160P)) {
+            maxVideoSize = SIZE_BOUND_2160P;
+        }
+        mSupportedVideoSizes =
+                getSupportedVideoSizes(cameraId, mCameraManager, maxVideoSize);
+    }
+
+    /**
      * Simple wrapper to wrap normal/burst video snapshot tests
      */
     private void videoSnapshotHelper(boolean burstTest) throws Exception {
@@ -478,9 +488,10 @@
                     Log.i(TAG, "Testing video snapshot for camera " + id);
                     // Re-use the MediaRecorder object for the same camera device.
                     mMediaRecorder = new MediaRecorder();
+
                     openDevice(id);
-                    mSupportedVideoSizes =
-                            getSupportedVideoSizes(id, mCameraManager, VIDEO_SIZE_BOUND);
+
+                    initSupportedVideoSize(id);
 
                     videoSnapshotTestByCamera(burstTest);
                 } finally {