CameraCTS: relax previewFps test constraint

Bug: 17752386
Change-Id: Iacf0a6857aa482b99445825ef0223f8e5e337282
diff --git a/tests/tests/hardware/src/android/hardware/cts/CameraTest.java b/tests/tests/hardware/src/android/hardware/cts/CameraTest.java
index 3476895..019bd21 100644
--- a/tests/tests/hardware/src/android/hardware/cts/CameraTest.java
+++ b/tests/tests/hardware/src/android/hardware/cts/CameraTest.java
@@ -1859,6 +1859,7 @@
         initializeMessageLooper(cameraId);
 
         // Test if the parameters exists and minimum fps <= maximum fps.
+        final int INTERVAL_ERROR_THRESHOLD = 10;
         int[] defaultFps = new int[2];
         Parameters parameters = mCamera.getParameters();
         parameters.getPreviewFpsRange(defaultFps);
@@ -1919,6 +1920,13 @@
             // See if any frame duration violations occurred during preview run
             AssertionFailedError e = callback.getDurationException();
             if (e != null) throw(e);
+            int numIntervalError = callback.getNumIntervalError();
+            if (numIntervalError > INTERVAL_ERROR_THRESHOLD) {
+                fail(String.format(
+                        "Too many preview callback frame intervals out of bounds: " +
+                                "Count is %d, limit is %d",
+                        numIntervalError, INTERVAL_ERROR_THRESHOLD));
+            }
         }
 
         // Test the invalid fps cases.
@@ -1948,6 +1956,7 @@
         private ArrayList<Long> mFrames = new ArrayList<Long>();
         private long firstFrameArrivalTime;
         private AssertionFailedError mDurationException = null;
+        private int numIntervalError;
 
         public void reset(double minFps, double maxFps) {
             this.mMinFps = minFps;
@@ -1960,6 +1969,7 @@
             mFrames.clear();
             firstFrameArrivalTime = 0;
             mDurationException = null;
+            numIntervalError = 0;
         }
 
         // This method tests if the actual fps is between minimum and maximum.
@@ -1997,18 +2007,15 @@
                 long lastArrivalTime = mFrames.get(mFrames.size() - 1);
                 double interval = arrivalTime - lastArrivalTime;
                 if (VERBOSE) Log.v(TAG, "Frame interval=" + interval);
-                try {
-                    assertTrue("Frame interval (" + interval + "ms) is too " +
-                            "large. mMaxFrameInterval=" +
-                             mMaxFrameInterval + "ms",
-                            interval < mMaxFrameInterval *
-                            (1.0 + intervalMargin));
-                    assertTrue("Frame interval (" + interval + "ms) is too " +
-                            "small. mMinFrameInterval=" +
-                            mMinFrameInterval + "ms",
-                            interval > mMinFrameInterval *
-                            (1.0 - intervalMargin));
 
+                try {
+                    if (interval > mMaxFrameInterval * (1.0 + intervalMargin) ||
+                            interval < mMinFrameInterval * (1.0 - intervalMargin)) {
+                        Log.i(TAG, "Bad frame interval=" + interval + "ms. Out out range " +
+                                mMinFrameInterval * (1.0 - intervalMargin) + "/" +
+                                mMaxFrameInterval * (1.0 + intervalMargin));
+                        numIntervalError++;
+                    }
                     // Check if the fps is within range.
                     double fpsMargin = 0.5; // x100 = percent
                     double avgInterval = (double)(arrivalTime - mFrames.get(0))
@@ -2035,6 +2042,9 @@
         public AssertionFailedError getDurationException() {
             return mDurationException;
         }
+        public int getNumIntervalError() {
+            return numIntervalError;
+        }
     }
 
     private void assertEquals(Size expected, Size actual) {