From addf8e99584c20b25660b67412cfe6a2c0a36455 Mon Sep 17 00:00:00 2001 From: Prabir Pradhan Date: Thu, 6 Apr 2023 00:28:48 +0000 Subject: Introduce the InputDeviceMetricsCollector stage Bug: 275726706 Test: Build Test: adb shell setprop persist.debug.input.enable_input_device_usage_metrics 1 Change-Id: Ie0c19f220c077c9d46df34787fed72cef70eace2 --- services/inputflinger/InputManager.cpp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'services/inputflinger/InputManager.cpp') diff --git a/services/inputflinger/InputManager.cpp b/services/inputflinger/InputManager.cpp index ddebcad0d3..863b4839be 100644 --- a/services/inputflinger/InputManager.cpp +++ b/services/inputflinger/InputManager.cpp @@ -23,6 +23,7 @@ #include "InputReaderFactory.h" #include "UnwantedInteractionBlocker.h" +#include #include #include @@ -32,6 +33,9 @@ namespace android { +static const bool ENABLE_INPUT_DEVICE_USAGE_METRICS = + sysprop::InputProperties::enable_input_device_usage_metrics().value_or(false); + using gui::FocusRequest; static int32_t exceptionCodeFromStatusT(status_t status) { @@ -55,12 +59,22 @@ static int32_t exceptionCodeFromStatusT(status_t status) { /** * The event flow is via the "InputListener" interface, as follows: - * InputReader -> UnwantedInteractionBlocker -> InputProcessor -> InputDispatcher + * InputReader + * -> UnwantedInteractionBlocker + * -> InputProcessor + * -> InputDeviceMetricsCollector + * -> InputDispatcher */ InputManager::InputManager(const sp& readerPolicy, InputDispatcherPolicyInterface& dispatcherPolicy) { mDispatcher = createInputDispatcher(dispatcherPolicy); - mProcessor = std::make_unique(*mDispatcher); + + if (ENABLE_INPUT_DEVICE_USAGE_METRICS) { + mCollector = std::make_unique(*mDispatcher); + } + + mProcessor = ENABLE_INPUT_DEVICE_USAGE_METRICS ? std::make_unique(*mCollector) + : std::make_unique(*mDispatcher); mBlocker = std::make_unique(*mProcessor); mReader = createInputReader(readerPolicy, *mBlocker); } @@ -131,6 +145,10 @@ void InputManager::dump(std::string& dump) { dump += '\n'; mProcessor->dump(dump); dump += '\n'; + if (ENABLE_INPUT_DEVICE_USAGE_METRICS) { + mCollector->dump(dump); + dump += '\n'; + } mDispatcher->dump(dump); dump += '\n'; } -- cgit v1.2.3-59-g8ed1b