SF: Adding statistical mode

- Adding statistical mode for timestamp intervals.
- Moving math calculations into util class, and adding a unit test.

See go/surface-flinger-scheduler for more info and systrace links.

Test: SF tests pass. Adding new test class.
Bug: 113612090
Change-Id: I3c3a73e3d8719e47326d8a48d27683037b7beb47
diff --git a/services/surfaceflinger/Scheduler/LayerHistory.cpp b/services/surfaceflinger/Scheduler/LayerHistory.cpp
index 1f47949..d5ccbe1 100644
--- a/services/surfaceflinger/Scheduler/LayerHistory.cpp
+++ b/services/surfaceflinger/Scheduler/LayerHistory.cpp
@@ -26,6 +26,8 @@
 #include <utils/Timers.h>
 #include <utils/Trace.h>
 
+#include "SchedulerUtils.h"
+
 namespace android {
 
 LayerHistory::LayerHistory() {}
@@ -38,7 +40,7 @@
 
 void LayerHistory::incrementCounter() {
     mCounter++;
-    mCounter = mCounter % ARRAY_SIZE;
+    mCounter = mCounter % scheduler::ARRAY_SIZE;
     // Clear all the previous data from the history. This is a ring buffer, so we are
     // reusing memory.
     mElements[mCounter].clear();
@@ -47,7 +49,8 @@
 const std::unordered_map<std::string, nsecs_t>& LayerHistory::get(size_t index) const {
     // For the purposes of the layer history, the index = 0 always needs to start at the
     // current counter, and then decrement to access the layers in correct historical order.
-    return mElements.at((ARRAY_SIZE + (mCounter - (index % ARRAY_SIZE))) % ARRAY_SIZE);
+    return mElements.at((scheduler::ARRAY_SIZE + (mCounter - (index % scheduler::ARRAY_SIZE))) %
+                        scheduler::ARRAY_SIZE);
 }
 
 } // namespace android
\ No newline at end of file