Add ChromeOS palm rejection model
This model will be used to block palm presses. It takes in a stream of
evdev events, and reports back the pointers which should be considered
palm.
Bug: 198472780
Test: atest libpalmrejection_test inputflinger_tests
Test: "adb shell device_config put input_native_boot
palm_rejection_enabled 0" and make sure that "adb shell dumpsys input"
shows that there aren't any palm rejectors inside
UnwantedInteractionBlocker
Change-Id: If979d335af29cf5e93b26336fea56a3a895cc562
diff --git a/services/inputflinger/InputManager.cpp b/services/inputflinger/InputManager.cpp
index 221e193..7a9862d 100644
--- a/services/inputflinger/InputManager.cpp
+++ b/services/inputflinger/InputManager.cpp
@@ -21,6 +21,7 @@
#include "InputManager.h"
#include "InputDispatcherFactory.h"
#include "InputReaderFactory.h"
+#include "UnwantedInteractionBlocker.h"
#include <binder/IPCThreadState.h>
@@ -54,12 +55,17 @@
}
}
+/**
+ * The event flow is via the "InputListener" interface, as follows:
+ * InputReader -> UnwantedInteractionBlocker -> InputClassifier -> InputDispatcher
+ */
InputManager::InputManager(
const sp<InputReaderPolicyInterface>& readerPolicy,
const sp<InputDispatcherPolicyInterface>& dispatcherPolicy) {
mDispatcher = createInputDispatcher(dispatcherPolicy);
mClassifier = std::make_unique<InputClassifier>(*mDispatcher);
- mReader = createInputReader(readerPolicy, *mClassifier);
+ mUnwantedInteractionBlocker = std::make_unique<UnwantedInteractionBlocker>(*mClassifier);
+ mReader = createInputReader(readerPolicy, *mUnwantedInteractionBlocker);
}
InputManager::~InputManager() {
@@ -106,6 +112,10 @@
return *mReader;
}
+UnwantedInteractionBlockerInterface& InputManager::getUnwantedInteractionBlocker() {
+ return *mUnwantedInteractionBlocker;
+}
+
InputClassifierInterface& InputManager::getClassifier() {
return *mClassifier;
}