Revert "Remove filterNonTouchAsIs function"
This reverts commit 719f50602d24d9b180762ac8687d4b643f657566.
Reason for revert: Testing breakages in b/266911763
Change-Id: Id03395f06fc1fca7a290978b18ebbda3b234124d
diff --git a/services/inputflinger/dispatcher/InputDispatcher.cpp b/services/inputflinger/dispatcher/InputDispatcher.cpp
index a97fda0..dc9f02a 100644
--- a/services/inputflinger/dispatcher/InputDispatcher.cpp
+++ b/services/inputflinger/dispatcher/InputDispatcher.cpp
@@ -2441,14 +2441,15 @@
}
// Update dispatching for hover enter and exit.
- std::vector<TouchedWindow> hoveringWindows =
- getHoveringWindowsLocked(oldState, tempTouchState, entry);
- for (const TouchedWindow& touchedWindow : hoveringWindows) {
- addWindowTargetLocked(touchedWindow.windowHandle, touchedWindow.targetFlags,
- touchedWindow.pointerIds, touchedWindow.firstDownTimeInTarget,
- targets);
+ {
+ std::vector<TouchedWindow> hoveringWindows =
+ getHoveringWindowsLocked(oldState, tempTouchState, entry);
+ for (const TouchedWindow& touchedWindow : hoveringWindows) {
+ addWindowTargetLocked(touchedWindow.windowHandle, touchedWindow.targetFlags,
+ touchedWindow.pointerIds, touchedWindow.firstDownTimeInTarget,
+ targets);
+ }
}
-
// Ensure that we have at least one foreground window or at least one window that cannot be a
// foreground target. If we only have windows that are not receiving foreground touches (e.g. we
// only have windows getting ACTION_OUTSIDE), then drop the event, because there is no window
@@ -2514,6 +2515,9 @@
}
outInjectionResult = InputEventInjectionResult::SUCCEEDED;
+ // Drop the outside or hover touch windows since we will not care about them
+ // in the next iteration.
+ tempTouchState.filterNonAsIsTouchWindows();
// Update final pieces of touch state if the injector had permission.
if (switchedDevice) {
diff --git a/services/inputflinger/dispatcher/TouchState.cpp b/services/inputflinger/dispatcher/TouchState.cpp
index 6cfb915..ad37d02 100644
--- a/services/inputflinger/dispatcher/TouchState.cpp
+++ b/services/inputflinger/dispatcher/TouchState.cpp
@@ -112,6 +112,20 @@
}
}
+void TouchState::filterNonAsIsTouchWindows() {
+ for (size_t i = 0; i < windows.size();) {
+ TouchedWindow& window = windows[i];
+ if (window.targetFlags.any(InputTarget::Flags::DISPATCH_AS_IS |
+ InputTarget::Flags::DISPATCH_AS_SLIPPERY_ENTER)) {
+ window.targetFlags.clear(InputTarget::DISPATCH_MASK);
+ window.targetFlags |= InputTarget::Flags::DISPATCH_AS_IS;
+ i += 1;
+ } else {
+ windows.erase(windows.begin() + i);
+ }
+ }
+}
+
void TouchState::cancelPointersForWindowsExcept(const BitSet32 pointerIds,
const sp<IBinder>& token) {
if (pointerIds.isEmpty()) return;