Introduce thread safety to InputDeviceMetricsCollector

There are several threads that interact with the metrics collector, such
as the Reader thread, Dispatcher thread, and binder threads for
dumping.

However, thread safety was never added to it, since it started off only
running on the Reader thread. There is a high likelihood that this is
the root cause of crashes that we see when dumping the metrics
collector.

Add a lock to the metrics collector to guard its state.

Bug: 315193876
Test: atest inputflinger_tests
Change-Id: I6a53014fbc533cf15516e8b079ee5b715b4aa58f
diff --git a/services/inputflinger/InputManager.cpp b/services/inputflinger/InputManager.cpp
index 8cf61f9..af4ba5a 100644
--- a/services/inputflinger/InputManager.cpp
+++ b/services/inputflinger/InputManager.cpp
@@ -228,6 +228,9 @@
     mReader->monitor();
     mBlocker->monitor();
     mProcessor->monitor();
+    if (ENABLE_INPUT_DEVICE_USAGE_METRICS) {
+        mCollector->monitor();
+    }
     mDispatcher->monitor();
 }