diff options
| author | 2023-04-06 00:28:48 +0000 | |
|---|---|---|
| committer | 2023-05-18 02:03:26 +0000 | |
| commit | addf8e99584c20b25660b67412cfe6a2c0a36455 (patch) | |
| tree | a3540f0cfd0080e54b7d760311443805d26c80b1 /services/inputflinger/InputManager.cpp | |
| parent | 3b13bff39d67100ea0705efddac78c1f67715f3c (diff) | |
Introduce the InputDeviceMetricsCollector stage
Bug: 275726706
Test: Build
Test: adb shell setprop persist.debug.input.enable_input_device_usage_metrics 1
Change-Id: Ie0c19f220c077c9d46df34787fed72cef70eace2
Diffstat (limited to 'services/inputflinger/InputManager.cpp')
| -rw-r--r-- | services/inputflinger/InputManager.cpp | 22 |
1 files changed, 20 insertions, 2 deletions
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 <android/sysprop/InputProperties.sysprop.h> #include <binder/IPCThreadState.h> #include <log/log.h> @@ -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<InputReaderPolicyInterface>& readerPolicy, InputDispatcherPolicyInterface& dispatcherPolicy) { mDispatcher = createInputDispatcher(dispatcherPolicy); - mProcessor = std::make_unique<InputProcessor>(*mDispatcher); + + if (ENABLE_INPUT_DEVICE_USAGE_METRICS) { + mCollector = std::make_unique<InputDeviceMetricsCollector>(*mDispatcher); + } + + mProcessor = ENABLE_INPUT_DEVICE_USAGE_METRICS ? std::make_unique<InputProcessor>(*mCollector) + : std::make_unique<InputProcessor>(*mDispatcher); mBlocker = std::make_unique<UnwantedInteractionBlocker>(*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'; } |