Loading services/inputflinger/Android.bp +2 −0 Original line number Diff line number Diff line Loading @@ -60,6 +60,7 @@ filegroup { name: "libinputflinger_sources", srcs: [ "InputCommonConverter.cpp", "InputDeviceMetricsCollector.cpp", "InputProcessor.cpp", "PreferStylusOverTouchBlocker.cpp", "UnwantedInteractionBlocker.cpp", Loading Loading @@ -129,6 +130,7 @@ cc_library_shared { "libinputflinger_base", "libinputreader", "libinputreporter", "libPlatformProperties", ], static_libs: [ "libinputdispatcher", Loading services/inputflinger/InputDeviceMetricsCollector.cpp 0 → 100644 +68 −0 Original line number Diff line number Diff line /* * Copyright 2023 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #define LOG_TAG "InputDeviceMetricsCollector" #include "InputDeviceMetricsCollector.h" namespace android { InputDeviceMetricsCollector::InputDeviceMetricsCollector(InputListenerInterface& listener) : mNextListener(listener){}; void InputDeviceMetricsCollector::notifyInputDevicesChanged( const NotifyInputDevicesChangedArgs& args) { mNextListener.notify(args); } void InputDeviceMetricsCollector::notifyConfigurationChanged( const NotifyConfigurationChangedArgs& args) { mNextListener.notify(args); } void InputDeviceMetricsCollector::notifyKey(const NotifyKeyArgs& args) { mNextListener.notify(args); } void InputDeviceMetricsCollector::notifyMotion(const NotifyMotionArgs& args) { mNextListener.notify(args); } void InputDeviceMetricsCollector::notifySwitch(const NotifySwitchArgs& args) { mNextListener.notify(args); } void InputDeviceMetricsCollector::notifySensor(const NotifySensorArgs& args) { mNextListener.notify(args); } void InputDeviceMetricsCollector::notifyVibratorState(const NotifyVibratorStateArgs& args) { mNextListener.notify(args); } void InputDeviceMetricsCollector::notifyDeviceReset(const NotifyDeviceResetArgs& args) { mNextListener.notify(args); } void InputDeviceMetricsCollector::notifyPointerCaptureChanged( const NotifyPointerCaptureChangedArgs& args) { mNextListener.notify(args); } void InputDeviceMetricsCollector::dump(std::string& dump) { dump += "InputDeviceMetricsCollector:\n"; } } // namespace android services/inputflinger/InputDeviceMetricsCollector.h 0 → 100644 +58 −0 Original line number Diff line number Diff line /* * Copyright 2023 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #pragma once #include "InputListener.h" namespace android { /** * Logs metrics about registered input devices and their usages. * * Not thread safe. Must be called from a single thread. */ class InputDeviceMetricsCollectorInterface : public InputListenerInterface { public: /** * Dump the state of the interaction blocker. * This method may be called on any thread (usually by the input manager on a binder thread). */ virtual void dump(std::string& dump) = 0; }; class InputDeviceMetricsCollector : public InputDeviceMetricsCollectorInterface { public: explicit InputDeviceMetricsCollector(InputListenerInterface& listener); ~InputDeviceMetricsCollector() override = default; void notifyInputDevicesChanged(const NotifyInputDevicesChangedArgs& args) override; void notifyConfigurationChanged(const NotifyConfigurationChangedArgs& args) override; void notifyKey(const NotifyKeyArgs& args) override; void notifyMotion(const NotifyMotionArgs& args) override; void notifySwitch(const NotifySwitchArgs& args) override; void notifySensor(const NotifySensorArgs& args) override; void notifyVibratorState(const NotifyVibratorStateArgs& args) override; void notifyDeviceReset(const NotifyDeviceResetArgs& args) override; void notifyPointerCaptureChanged(const NotifyPointerCaptureChangedArgs& args) override; void dump(std::string& dump) override; private: InputListenerInterface& mNextListener; }; } // namespace android services/inputflinger/InputManager.cpp +20 −2 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ #include "InputReaderFactory.h" #include "UnwantedInteractionBlocker.h" #include <android/sysprop/InputProperties.sysprop.h> #include <binder/IPCThreadState.h> #include <log/log.h> Loading @@ -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) { Loading @@ -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); } Loading Loading @@ -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'; } Loading services/inputflinger/InputManager.h +4 −1 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ * Native input manager. */ #include "InputDeviceMetricsCollector.h" #include "InputProcessor.h" #include "InputReaderBase.h" #include "include/UnwantedInteractionBlockerInterface.h" Loading Loading @@ -82,7 +83,7 @@ public: /* Gets the input reader. */ virtual InputReaderInterface& getReader() = 0; /* Gets the input processor */ /* Gets the input processor. */ virtual InputProcessorInterface& getProcessor() = 0; /* Gets the input dispatcher. */ Loading Loading @@ -124,6 +125,8 @@ private: std::unique_ptr<InputProcessorInterface> mProcessor; std::unique_ptr<InputDeviceMetricsCollectorInterface> mCollector; std::unique_ptr<InputDispatcherInterface> mDispatcher; }; Loading Loading
services/inputflinger/Android.bp +2 −0 Original line number Diff line number Diff line Loading @@ -60,6 +60,7 @@ filegroup { name: "libinputflinger_sources", srcs: [ "InputCommonConverter.cpp", "InputDeviceMetricsCollector.cpp", "InputProcessor.cpp", "PreferStylusOverTouchBlocker.cpp", "UnwantedInteractionBlocker.cpp", Loading Loading @@ -129,6 +130,7 @@ cc_library_shared { "libinputflinger_base", "libinputreader", "libinputreporter", "libPlatformProperties", ], static_libs: [ "libinputdispatcher", Loading
services/inputflinger/InputDeviceMetricsCollector.cpp 0 → 100644 +68 −0 Original line number Diff line number Diff line /* * Copyright 2023 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #define LOG_TAG "InputDeviceMetricsCollector" #include "InputDeviceMetricsCollector.h" namespace android { InputDeviceMetricsCollector::InputDeviceMetricsCollector(InputListenerInterface& listener) : mNextListener(listener){}; void InputDeviceMetricsCollector::notifyInputDevicesChanged( const NotifyInputDevicesChangedArgs& args) { mNextListener.notify(args); } void InputDeviceMetricsCollector::notifyConfigurationChanged( const NotifyConfigurationChangedArgs& args) { mNextListener.notify(args); } void InputDeviceMetricsCollector::notifyKey(const NotifyKeyArgs& args) { mNextListener.notify(args); } void InputDeviceMetricsCollector::notifyMotion(const NotifyMotionArgs& args) { mNextListener.notify(args); } void InputDeviceMetricsCollector::notifySwitch(const NotifySwitchArgs& args) { mNextListener.notify(args); } void InputDeviceMetricsCollector::notifySensor(const NotifySensorArgs& args) { mNextListener.notify(args); } void InputDeviceMetricsCollector::notifyVibratorState(const NotifyVibratorStateArgs& args) { mNextListener.notify(args); } void InputDeviceMetricsCollector::notifyDeviceReset(const NotifyDeviceResetArgs& args) { mNextListener.notify(args); } void InputDeviceMetricsCollector::notifyPointerCaptureChanged( const NotifyPointerCaptureChangedArgs& args) { mNextListener.notify(args); } void InputDeviceMetricsCollector::dump(std::string& dump) { dump += "InputDeviceMetricsCollector:\n"; } } // namespace android
services/inputflinger/InputDeviceMetricsCollector.h 0 → 100644 +58 −0 Original line number Diff line number Diff line /* * Copyright 2023 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #pragma once #include "InputListener.h" namespace android { /** * Logs metrics about registered input devices and their usages. * * Not thread safe. Must be called from a single thread. */ class InputDeviceMetricsCollectorInterface : public InputListenerInterface { public: /** * Dump the state of the interaction blocker. * This method may be called on any thread (usually by the input manager on a binder thread). */ virtual void dump(std::string& dump) = 0; }; class InputDeviceMetricsCollector : public InputDeviceMetricsCollectorInterface { public: explicit InputDeviceMetricsCollector(InputListenerInterface& listener); ~InputDeviceMetricsCollector() override = default; void notifyInputDevicesChanged(const NotifyInputDevicesChangedArgs& args) override; void notifyConfigurationChanged(const NotifyConfigurationChangedArgs& args) override; void notifyKey(const NotifyKeyArgs& args) override; void notifyMotion(const NotifyMotionArgs& args) override; void notifySwitch(const NotifySwitchArgs& args) override; void notifySensor(const NotifySensorArgs& args) override; void notifyVibratorState(const NotifyVibratorStateArgs& args) override; void notifyDeviceReset(const NotifyDeviceResetArgs& args) override; void notifyPointerCaptureChanged(const NotifyPointerCaptureChangedArgs& args) override; void dump(std::string& dump) override; private: InputListenerInterface& mNextListener; }; } // namespace android
services/inputflinger/InputManager.cpp +20 −2 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ #include "InputReaderFactory.h" #include "UnwantedInteractionBlocker.h" #include <android/sysprop/InputProperties.sysprop.h> #include <binder/IPCThreadState.h> #include <log/log.h> Loading @@ -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) { Loading @@ -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); } Loading Loading @@ -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'; } Loading
services/inputflinger/InputManager.h +4 −1 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ * Native input manager. */ #include "InputDeviceMetricsCollector.h" #include "InputProcessor.h" #include "InputReaderBase.h" #include "include/UnwantedInteractionBlockerInterface.h" Loading Loading @@ -82,7 +83,7 @@ public: /* Gets the input reader. */ virtual InputReaderInterface& getReader() = 0; /* Gets the input processor */ /* Gets the input processor. */ virtual InputProcessorInterface& getProcessor() = 0; /* Gets the input dispatcher. */ Loading Loading @@ -124,6 +125,8 @@ private: std::unique_ptr<InputProcessorInterface> mProcessor; std::unique_ptr<InputDeviceMetricsCollectorInterface> mCollector; std::unique_ptr<InputDispatcherInterface> mDispatcher; }; Loading