SurfaceFlinger: clamp frame refresh duration to min refresh duration

Some applications may send doubles frames which are scheduled to be
presented very close to each other. In this case to avoid calculating
a very high fps for the layer, clamp the refresh duration to the minimal
value allowed for the layer.

Test: YouTube play "YouTube 60fps Tester" video.
Bug: 139209733
Change-Id: I4bcdfad65b57782ec6e346e8d884bfb6e2abac4d
diff --git a/services/surfaceflinger/Scheduler/LayerInfo.cpp b/services/surfaceflinger/Scheduler/LayerInfo.cpp
index e782dd5..723d71f 100644
--- a/services/surfaceflinger/Scheduler/LayerInfo.cpp
+++ b/services/surfaceflinger/Scheduler/LayerInfo.cpp
@@ -49,7 +49,7 @@
     mLastPresentTime = lastPresentTime;
     // Ignore time diff that are too high - those are stale values
     if (timeDiff > OBSOLETE_TIME_EPSILON_NS.count()) return;
-    const nsecs_t refreshDuration = (timeDiff > 0) ? timeDiff : mMinRefreshDuration;
+    const nsecs_t refreshDuration = std::max(timeDiff, mMinRefreshDuration);
     const int fps = 1e9f / refreshDuration;
     mRefreshRateHistory.insertRefreshRate(fps);
 }