summaryrefslogtreecommitdiff
path: root/services/inputflinger/UnwantedInteractionBlocker.cpp
diff options
context:
space:
mode:
author Siarhei Vishniakou <svv@google.com> 2022-02-10 19:46:34 -0800
committer Siarhei Vishniakou <svv@google.com> 2022-03-02 22:43:24 +0000
commitf6db4c395d2fc0821a6a42aaeb88154eb7183aae (patch)
tree9402b92676ca4d1d335f24c3124840fa07623381 /services/inputflinger/UnwantedInteractionBlocker.cpp
parent1077ad7fe5a1fc7d5323a049b4e8935f60329457 (diff)
Block touches when stylus is down
Since we haven't yet added simultaneous touch and stylus support, let's improve the user experience by blocking all touch when the stylus is down. Bug: 210159205 Test: atest inputflinger_tests Change-Id: Id6a6467d7feb7c7d91770ddbd63b92583832d504 (cherry picked from commit a3c8e51901d17f696838d3e8260464f7437468a5)
Diffstat (limited to 'services/inputflinger/UnwantedInteractionBlocker.cpp')
-rw-r--r--services/inputflinger/UnwantedInteractionBlocker.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/services/inputflinger/UnwantedInteractionBlocker.cpp b/services/inputflinger/UnwantedInteractionBlocker.cpp
index 64dbb8ceb4..f904bfd82e 100644
--- a/services/inputflinger/UnwantedInteractionBlocker.cpp
+++ b/services/inputflinger/UnwantedInteractionBlocker.cpp
@@ -44,7 +44,8 @@ static std::string toLower(std::string s) {
}
static bool isFromTouchscreen(int32_t source) {
- return isFromSource(source, AINPUT_SOURCE_TOUCHSCREEN);
+ return isFromSource(source, AINPUT_SOURCE_TOUCHSCREEN) &&
+ !isFromSource(source, AINPUT_SOURCE_STYLUS);
}
static ::base::TimeTicks toChromeTimestamp(nsecs_t eventTime) {
@@ -367,6 +368,14 @@ void UnwantedInteractionBlocker::notifyKey(const NotifyKeyArgs* args) {
}
void UnwantedInteractionBlocker::notifyMotion(const NotifyMotionArgs* args) {
+ ftl::StaticVector<NotifyMotionArgs, 2> processedArgs =
+ mPreferStylusOverTouchBlocker.processMotion(*args);
+ for (const NotifyMotionArgs& loopArgs : processedArgs) {
+ notifyMotionInner(&loopArgs);
+ }
+}
+
+void UnwantedInteractionBlocker::notifyMotionInner(const NotifyMotionArgs* args) {
auto it = mPalmRejectors.find(args->deviceId);
const bool sendToPalmRejector = it != mPalmRejectors.end() && isFromTouchscreen(args->source);
if (!sendToPalmRejector) {
@@ -440,6 +449,8 @@ void UnwantedInteractionBlocker::notifyInputDevicesChanged(
void UnwantedInteractionBlocker::dump(std::string& dump) {
dump += "UnwantedInteractionBlocker:\n";
+ dump += " mPreferStylusOverTouchBlocker:\n";
+ dump += addPrefix(mPreferStylusOverTouchBlocker.dump(), " ");
dump += StringPrintf(" mEnablePalmRejection: %s\n", toString(mEnablePalmRejection));
dump += StringPrintf(" isPalmRejectionEnabled (flag value): %s\n",
toString(isPalmRejectionEnabled()));