Remove TouchState::down variable
This variable determines whether touch is currently down. However, we
are already storing the pointers that are down for each window. We can
just check whether any of the touched windows have pointers inside to
replace it.
Bug: 211379801
Test: m inputflinger_tests && adb sync data && adb shell -t /data/nativetest64/inputflinger_tests/inputflinger_tests
Change-Id: I4137e180835da1e689c89feff7c8f223b79aa85e
diff --git a/services/inputflinger/dispatcher/TouchState.cpp b/services/inputflinger/dispatcher/TouchState.cpp
index a3f45cf..f5b7cb8 100644
--- a/services/inputflinger/dispatcher/TouchState.cpp
+++ b/services/inputflinger/dispatcher/TouchState.cpp
@@ -138,4 +138,9 @@
return nullptr;
}
+bool TouchState::isDown() const {
+ return std::any_of(windows.begin(), windows.end(),
+ [](const TouchedWindow& window) { return !window.pointerIds.isEmpty(); });
+}
+
} // namespace android::inputdispatcher