From b5045651749f957381669698027d542da9d1080f Mon Sep 17 00:00:00 2001 From: Prabir Pradhan Date: Thu, 18 May 2023 02:04:24 +0000 Subject: [PATCH] Notify MetricsCollector of device interaction from Dispatcher InputDispatcher will notify the metrics collector whenever an interaction occurs between an input device and a UID through its policy. Bug: 275726706 Test: atest inputflinger_tests Test: statsd_testdrive Change-Id: Ic74aa10c5d8806fe7d0bc376c9bf05862c60cf7b --- .../com_android_server_input_InputManagerService.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/services/core/jni/com_android_server_input_InputManagerService.cpp b/services/core/jni/com_android_server_input_InputManagerService.cpp index 8587270dd1870..52615295f38a6 100644 --- a/services/core/jni/com_android_server_input_InputManagerService.cpp +++ b/services/core/jni/com_android_server_input_InputManagerService.cpp @@ -355,6 +355,8 @@ public: void onPointerDownOutsideFocus(const sp& touchedToken) override; void setPointerCapture(const PointerCaptureRequest& request) override; void notifyDropWindow(const sp& token, float x, float y) override; + void notifyDeviceInteraction(int32_t deviceId, nsecs_t timestamp, + const std::set& uids) override; /* --- PointerControllerPolicyInterface implementation --- */ @@ -966,6 +968,15 @@ void NativeInputManager::notifyDropWindow(const sp& token, float x, flo checkAndClearExceptionFromCallback(env, "notifyDropWindow"); } +void NativeInputManager::notifyDeviceInteraction(int32_t deviceId, nsecs_t timestamp, + const std::set& uids) { + static const bool ENABLE_INPUT_DEVICE_USAGE_METRICS = + sysprop::InputProperties::enable_input_device_usage_metrics().value_or(false); + if (!ENABLE_INPUT_DEVICE_USAGE_METRICS) return; + + mInputManager->getMetricsCollector().notifyDeviceInteraction(deviceId, timestamp, uids); +} + void NativeInputManager::notifySensorEvent(int32_t deviceId, InputDeviceSensorType sensorType, InputDeviceSensorAccuracy accuracy, nsecs_t timestamp, const std::vector& values) {