summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Siarhei Vishniakou <svv@google.com> 2023-11-17 17:09:08 -0800
committer Siarhei Vishniakou <svv@google.com> 2023-11-20 16:47:56 +0000
commit7be50c9b94191ddcecd4cacdfcb8fee2589ccd12 (patch)
tree27ef46a33ca23d4d184557773fb994a5a58ae8a1
parentd1a34bff5ab6914f08110ab6c93e3919b51366b7 (diff)
Move hover rejection to an earlier part of the function
Hover events from the same device are rejected if this device is already down. Before this CL, this rejection took place later in the pipeline, after many other computations were already performed. In this CL, this check is going to be done earlier. This helps separate the logic a bit, because now there will not be any return statements after the injection result is set to succeeded. Bug: 211379801 Test: TEST=inputflinger_tests; m $TEST && $ANDROID_HOST_OUT/nativetest64/$TEST/$TEST Change-Id: Ib0f1ad750a8bd172decc63c82289ef014b8e470d
-rw-r--r--services/inputflinger/dispatcher/InputDispatcher.cpp17
1 files changed, 8 insertions, 9 deletions
diff --git a/services/inputflinger/dispatcher/InputDispatcher.cpp b/services/inputflinger/dispatcher/InputDispatcher.cpp
index 7f4de7a5a3..2a71125661 100644
--- a/services/inputflinger/dispatcher/InputDispatcher.cpp
+++ b/services/inputflinger/dispatcher/InputDispatcher.cpp
@@ -2305,6 +2305,13 @@ std::vector<InputTarget> InputDispatcher::findTouchedWindowTargetsLocked(
}
if (isHoverAction) {
+ if (wasDown) {
+ // Started hovering, but the device is already down: reject the hover event
+ LOG(ERROR) << "Got hover event " << entry.getDescription()
+ << " but the device is already down " << oldState->dump();
+ outInjectionResult = InputEventInjectionResult::FAILED;
+ return {};
+ }
// For hover actions, we will treat 'tempTouchState' as a new state, so let's erase
// all of the existing hovering pointers and recompute.
tempTouchState.clearHoveringPointers(entry.deviceId);
@@ -2687,15 +2694,7 @@ std::vector<InputTarget> InputDispatcher::findTouchedWindowTargetsLocked(
}
// Update final pieces of touch state if the injector had permission.
- if (isHoverAction) {
- if (oldState && oldState->isDown(entry.deviceId)) {
- // Started hovering, but the device is already down: reject the hover event
- LOG(ERROR) << "Got hover event " << entry.getDescription()
- << " but the device is already down " << oldState->dump();
- outInjectionResult = InputEventInjectionResult::FAILED;
- return {};
- }
- } else if (maskedAction == AMOTION_EVENT_ACTION_UP) {
+ if (maskedAction == AMOTION_EVENT_ACTION_UP) {
// Pointer went up.
tempTouchState.removeTouchingPointer(entry.deviceId, entry.pointerProperties[0].id);
} else if (maskedAction == AMOTION_EVENT_ACTION_CANCEL) {