LatencyAggregatorWithHistograms for InputEventLatencyReported atom.

Currently, input latency metrics cannot be reported on a per-device/per
-source/per-input-event-type granular level. Moreover, regarding
implementation, the input event latencies are aggregated into KLL
sketches (per day) and serialized into the InputEventLatencySketch,
which is a pulled atom, using LatencyAggregator. This means that only
20,000 input event latencies can be recorded per day, the rest are
dropped.

We want to capture latency statistics that can be broken down by per
input device (characterized by its Product ID and Vendor ID), by
source(s) of the input event (such as stylus, touchpad, touchscreen) and
by specific types of input events (such as MOTION_ACTION_DOWN,
MOTION_ACTION_UP, MOTION_ACTION_MOVE, KEY).

The logic for per device input latency metrics lives in
LatencyAggregatorWithHistograms.
Once the flag is rolled out, this will replace LatencyAggregator.

Input events with the same identifier are mapped to an array of 7
histograms. Each histogram's bin sizes are custom to the latency stage
and input event type. When an input event timeline is received, the
relevant bin counter of the corresponding histogram is incremented.

The InputEventLatencyReported atom is pushed every 6 hours by calling
pushLatencyStatistics from InputDispatcher DispatchOnce. After a push,
histograms are cleared.

processSlowEvent was copied from LatencyAggregator to keep logging the
SLOW_iNPUT_EVENT_REPORTED atom.

Tests will be added in a separate CL.

Bug: 270049345
Test: atest inputflinger_tests
Test: manual tests with statsd_testdrive 932
Flag: com.android.input.flags.enable_per_device_input_latency_metrics
Change-Id: I64fb883f4a01889b3600043d21446613a5a5bce7
diff --git a/services/inputflinger/dispatcher/LatencyAggregator.cpp b/services/inputflinger/dispatcher/LatencyAggregator.cpp
index 4ddd2e9..d0e9d7c 100644
--- a/services/inputflinger/dispatcher/LatencyAggregator.cpp
+++ b/services/inputflinger/dispatcher/LatencyAggregator.cpp
@@ -28,6 +28,8 @@
 using dist_proc::aggregation::KllQuantile;
 using std::chrono_literals::operator""ms;
 
+namespace {
+
 // Convert the provided nanoseconds into hundreds of microseconds.
 // Use hundreds of microseconds (as opposed to microseconds) to preserve space.
 static inline int64_t ns2hus(nsecs_t nanos) {
@@ -74,6 +76,8 @@
     return std::chrono::milliseconds(std::stoi(millis));
 }
 
+} // namespace
+
 namespace android::inputdispatcher {
 
 /**
@@ -125,6 +129,9 @@
     processSlowEvent(timeline);
 }
 
+// This version of LatencyAggregator doesn't push any atoms
+void LatencyAggregator::pushLatencyStatistics() {}
+
 void LatencyAggregator::processStatistics(const InputEventTimeline& timeline) {
     std::scoped_lock lock(mLock);
     // Before we do any processing, check that we have not yet exceeded MAX_SIZE