Loading services/inputflinger/InputFilter.cpp +24 −8 Original line number Diff line number Diff line Loading @@ -22,16 +22,19 @@ namespace android { using aidl::com::android::server::inputflinger::IInputFilter; using AidlKeyEvent = aidl::com::android::server::inputflinger::KeyEvent; using aidl::com::android::server::inputflinger::KeyEventAction; using AidlDeviceInfo = aidl::com::android::server::inputflinger::DeviceInfo; using aidl::android::hardware::input::common::Source; AidlKeyEvent notifyKeyArgsToKeyEvent(const NotifyKeyArgs& args) { AidlKeyEvent event; event.id = args.id; event.eventTime = args.eventTime; event.deviceId = args.deviceId; event.source = args.source; event.source = static_cast<Source>(args.source); event.displayId = args.displayId; event.policyFlags = args.policyFlags; event.action = args.action; event.action = static_cast<KeyEventAction>(args.action); event.flags = args.flags; event.keyCode = args.keyCode; event.scanCode = args.scanCode; Loading @@ -42,9 +45,10 @@ AidlKeyEvent notifyKeyArgsToKeyEvent(const NotifyKeyArgs& args) { } NotifyKeyArgs keyEventToNotifyKeyArgs(const AidlKeyEvent& event) { return NotifyKeyArgs(event.id, event.eventTime, event.readTime, event.deviceId, event.source, event.displayId, event.policyFlags, event.action, event.flags, event.keyCode, event.scanCode, event.metaState, event.downTime); return NotifyKeyArgs(event.id, event.eventTime, event.readTime, event.deviceId, static_cast<uint32_t>(event.source), event.displayId, event.policyFlags, static_cast<int32_t>(event.action), event.flags, event.keyCode, event.scanCode, event.metaState, event.downTime); } namespace { Loading @@ -71,11 +75,14 @@ InputFilter::InputFilter(InputListenerInterface& listener, IInputFlingerRust& ru void InputFilter::notifyInputDevicesChanged(const NotifyInputDevicesChangedArgs& args) { if (isFilterEnabled()) { std::vector<int32_t> deviceIds; std::vector<AidlDeviceInfo> deviceInfos; for (auto info : args.inputDeviceInfos) { deviceIds.push_back(info.getId()); AidlDeviceInfo aidlInfo; aidlInfo.deviceId = info.getId(); aidlInfo.external = info.isExternal(); deviceInfos.push_back(aidlInfo); } LOG_ALWAYS_FATAL_IF(!mInputFilterRust->notifyInputDevicesChanged(deviceIds).isOk()); LOG_ALWAYS_FATAL_IF(!mInputFilterRust->notifyInputDevicesChanged(deviceInfos).isOk()); } mNextListener.notify(args); } Loading Loading @@ -122,6 +129,15 @@ bool InputFilter::isFilterEnabled() { return result; } void InputFilter::setAccessibilityBounceKeysThreshold(nsecs_t threshold) { std::scoped_lock _l(mLock); if (mConfig.bounceKeysThresholdNs != threshold) { mConfig.bounceKeysThresholdNs = threshold; LOG_ALWAYS_FATAL_IF(!mInputFilterRust->notifyConfigurationChanged(mConfig).isOk()); } } void InputFilter::dump(std::string& dump) { dump += "InputFilter:\n"; } Loading services/inputflinger/InputFilter.h +7 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ #pragma once #include <aidl/com/android/server/inputflinger/IInputFlingerRust.h> #include <utils/Mutex.h> #include "InputListener.h" #include "NotifyArgs.h" Loading @@ -31,6 +32,7 @@ public: * This method may be called on any thread (usually by the input manager on a binder thread). */ virtual void dump(std::string& dump) = 0; virtual void setAccessibilityBounceKeysThreshold(nsecs_t threshold) = 0; }; class InputFilter : public InputFilterInterface { Loading @@ -39,6 +41,8 @@ public: using IInputFilter = aidl::com::android::server::inputflinger::IInputFilter; using IInputFilterCallbacks = aidl::com::android::server::inputflinger::IInputFilter::IInputFilterCallbacks; using InputFilterConfiguration = aidl::com::android::server::inputflinger::InputFilterConfiguration; explicit InputFilter(InputListenerInterface& listener, IInputFlingerRust&); ~InputFilter() override = default; Loading @@ -51,12 +55,15 @@ public: void notifyVibratorState(const NotifyVibratorStateArgs& args) override; void notifyDeviceReset(const NotifyDeviceResetArgs& args) override; void notifyPointerCaptureChanged(const NotifyPointerCaptureChangedArgs& args) override; void setAccessibilityBounceKeysThreshold(nsecs_t threshold) override; void dump(std::string& dump) override; private: InputListenerInterface& mNextListener; std::shared_ptr<IInputFilterCallbacks> mCallbacks; std::shared_ptr<IInputFilter> mInputFilterRust; mutable std::mutex mLock; InputFilterConfiguration mConfig GUARDED_BY(mLock); bool isFilterEnabled(); }; Loading services/inputflinger/InputManager.cpp +4 −0 Original line number Diff line number Diff line Loading @@ -224,6 +224,10 @@ InputDispatcherInterface& InputManager::getDispatcher() { return *mDispatcher; } InputFilterInterface& InputManager::getInputFilter() { return *mInputFilter; } void InputManager::monitor() { mReader->monitor(); mBlocker->monitor(); Loading services/inputflinger/InputManager.h +4 −0 Original line number Diff line number Diff line Loading @@ -102,6 +102,9 @@ public: /* Gets the input dispatcher. */ virtual InputDispatcherInterface& getDispatcher() = 0; /* Gets the input filter */ virtual InputFilterInterface& getInputFilter() = 0; /* Check that the input stages have not deadlocked. */ virtual void monitor() = 0; Loading @@ -126,6 +129,7 @@ public: InputProcessorInterface& getProcessor() override; InputDeviceMetricsCollectorInterface& getMetricsCollector() override; InputDispatcherInterface& getDispatcher() override; InputFilterInterface& getInputFilter() override; void monitor() override; void dump(std::string& dump) override; Loading services/inputflinger/aidl/Android.bp +3 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,9 @@ aidl_interface { srcs: ["**/*.aidl"], unstable: true, host_supported: true, imports: [ "android.hardware.input.common-V1", ], backend: { cpp: { enabled: false, Loading Loading
services/inputflinger/InputFilter.cpp +24 −8 Original line number Diff line number Diff line Loading @@ -22,16 +22,19 @@ namespace android { using aidl::com::android::server::inputflinger::IInputFilter; using AidlKeyEvent = aidl::com::android::server::inputflinger::KeyEvent; using aidl::com::android::server::inputflinger::KeyEventAction; using AidlDeviceInfo = aidl::com::android::server::inputflinger::DeviceInfo; using aidl::android::hardware::input::common::Source; AidlKeyEvent notifyKeyArgsToKeyEvent(const NotifyKeyArgs& args) { AidlKeyEvent event; event.id = args.id; event.eventTime = args.eventTime; event.deviceId = args.deviceId; event.source = args.source; event.source = static_cast<Source>(args.source); event.displayId = args.displayId; event.policyFlags = args.policyFlags; event.action = args.action; event.action = static_cast<KeyEventAction>(args.action); event.flags = args.flags; event.keyCode = args.keyCode; event.scanCode = args.scanCode; Loading @@ -42,9 +45,10 @@ AidlKeyEvent notifyKeyArgsToKeyEvent(const NotifyKeyArgs& args) { } NotifyKeyArgs keyEventToNotifyKeyArgs(const AidlKeyEvent& event) { return NotifyKeyArgs(event.id, event.eventTime, event.readTime, event.deviceId, event.source, event.displayId, event.policyFlags, event.action, event.flags, event.keyCode, event.scanCode, event.metaState, event.downTime); return NotifyKeyArgs(event.id, event.eventTime, event.readTime, event.deviceId, static_cast<uint32_t>(event.source), event.displayId, event.policyFlags, static_cast<int32_t>(event.action), event.flags, event.keyCode, event.scanCode, event.metaState, event.downTime); } namespace { Loading @@ -71,11 +75,14 @@ InputFilter::InputFilter(InputListenerInterface& listener, IInputFlingerRust& ru void InputFilter::notifyInputDevicesChanged(const NotifyInputDevicesChangedArgs& args) { if (isFilterEnabled()) { std::vector<int32_t> deviceIds; std::vector<AidlDeviceInfo> deviceInfos; for (auto info : args.inputDeviceInfos) { deviceIds.push_back(info.getId()); AidlDeviceInfo aidlInfo; aidlInfo.deviceId = info.getId(); aidlInfo.external = info.isExternal(); deviceInfos.push_back(aidlInfo); } LOG_ALWAYS_FATAL_IF(!mInputFilterRust->notifyInputDevicesChanged(deviceIds).isOk()); LOG_ALWAYS_FATAL_IF(!mInputFilterRust->notifyInputDevicesChanged(deviceInfos).isOk()); } mNextListener.notify(args); } Loading Loading @@ -122,6 +129,15 @@ bool InputFilter::isFilterEnabled() { return result; } void InputFilter::setAccessibilityBounceKeysThreshold(nsecs_t threshold) { std::scoped_lock _l(mLock); if (mConfig.bounceKeysThresholdNs != threshold) { mConfig.bounceKeysThresholdNs = threshold; LOG_ALWAYS_FATAL_IF(!mInputFilterRust->notifyConfigurationChanged(mConfig).isOk()); } } void InputFilter::dump(std::string& dump) { dump += "InputFilter:\n"; } Loading
services/inputflinger/InputFilter.h +7 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ #pragma once #include <aidl/com/android/server/inputflinger/IInputFlingerRust.h> #include <utils/Mutex.h> #include "InputListener.h" #include "NotifyArgs.h" Loading @@ -31,6 +32,7 @@ public: * This method may be called on any thread (usually by the input manager on a binder thread). */ virtual void dump(std::string& dump) = 0; virtual void setAccessibilityBounceKeysThreshold(nsecs_t threshold) = 0; }; class InputFilter : public InputFilterInterface { Loading @@ -39,6 +41,8 @@ public: using IInputFilter = aidl::com::android::server::inputflinger::IInputFilter; using IInputFilterCallbacks = aidl::com::android::server::inputflinger::IInputFilter::IInputFilterCallbacks; using InputFilterConfiguration = aidl::com::android::server::inputflinger::InputFilterConfiguration; explicit InputFilter(InputListenerInterface& listener, IInputFlingerRust&); ~InputFilter() override = default; Loading @@ -51,12 +55,15 @@ public: void notifyVibratorState(const NotifyVibratorStateArgs& args) override; void notifyDeviceReset(const NotifyDeviceResetArgs& args) override; void notifyPointerCaptureChanged(const NotifyPointerCaptureChangedArgs& args) override; void setAccessibilityBounceKeysThreshold(nsecs_t threshold) override; void dump(std::string& dump) override; private: InputListenerInterface& mNextListener; std::shared_ptr<IInputFilterCallbacks> mCallbacks; std::shared_ptr<IInputFilter> mInputFilterRust; mutable std::mutex mLock; InputFilterConfiguration mConfig GUARDED_BY(mLock); bool isFilterEnabled(); }; Loading
services/inputflinger/InputManager.cpp +4 −0 Original line number Diff line number Diff line Loading @@ -224,6 +224,10 @@ InputDispatcherInterface& InputManager::getDispatcher() { return *mDispatcher; } InputFilterInterface& InputManager::getInputFilter() { return *mInputFilter; } void InputManager::monitor() { mReader->monitor(); mBlocker->monitor(); Loading
services/inputflinger/InputManager.h +4 −0 Original line number Diff line number Diff line Loading @@ -102,6 +102,9 @@ public: /* Gets the input dispatcher. */ virtual InputDispatcherInterface& getDispatcher() = 0; /* Gets the input filter */ virtual InputFilterInterface& getInputFilter() = 0; /* Check that the input stages have not deadlocked. */ virtual void monitor() = 0; Loading @@ -126,6 +129,7 @@ public: InputProcessorInterface& getProcessor() override; InputDeviceMetricsCollectorInterface& getMetricsCollector() override; InputDispatcherInterface& getDispatcher() override; InputFilterInterface& getInputFilter() override; void monitor() override; void dump(std::string& dump) override; Loading
services/inputflinger/aidl/Android.bp +3 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,9 @@ aidl_interface { srcs: ["**/*.aidl"], unstable: true, host_supported: true, imports: [ "android.hardware.input.common-V1", ], backend: { cpp: { enabled: false, Loading