Delete TouchState::deviceId
We are doing per-device pointer tracking now, so this CL helps remove
the assumptions around having a single active device.
For now, the behaviour is preserved. In the future, we will not need to
check the currently active device at the TouchState level.
Bug: 211379801
Test: m inputflinger_tests && $ANDROID_HOST_OUT/nativetest64/inputflinger_tests/inputflinger_tests
Change-Id: Ie13e9c93eefc04c2955de3b8a06c9c2da28c9d72
diff --git a/services/inputflinger/dispatcher/TouchState.cpp b/services/inputflinger/dispatcher/TouchState.cpp
index ef188c7..dcbb366 100644
--- a/services/inputflinger/dispatcher/TouchState.cpp
+++ b/services/inputflinger/dispatcher/TouchState.cpp
@@ -31,6 +31,21 @@
*this = TouchState();
}
+std::set<int32_t> TouchState::getActiveDeviceIds() const {
+ std::set<int32_t> out;
+ for (const TouchedWindow& w : windows) {
+ std::set<int32_t> deviceIds = w.getActiveDeviceIds();
+ out.insert(deviceIds.begin(), deviceIds.end());
+ }
+ return out;
+}
+
+bool TouchState::hasTouchingPointers(int32_t deviceId) const {
+ return std::any_of(windows.begin(), windows.end(), [&](const TouchedWindow& window) {
+ return window.hasTouchingPointers(deviceId);
+ });
+}
+
void TouchState::removeTouchingPointer(int32_t removedDeviceId, int32_t pointerId) {
for (TouchedWindow& touchedWindow : windows) {
touchedWindow.removeTouchingPointer(removedDeviceId, pointerId);
@@ -262,8 +277,7 @@
std::string TouchState::dump() const {
std::string out;
- out += StringPrintf("deviceId=%d, source=%s\n", deviceId,
- inputEventSourceToString(source).c_str());
+ out += StringPrintf("source=%s\n", inputEventSourceToString(source).c_str());
if (!windows.empty()) {
out += " Windows:\n";
for (size_t i = 0; i < windows.size(); i++) {