Add GLOBAL_STYLUS_BLOCKS_TOUCH flag
This flag will allow internal windows, like TaskBar and StatusBar, to
ignore touch while stylus is down anywhere on screen.
This is needed to reduce the chance of unintentional clicks.
Bug: 211379801
Test: TEST=inputflinger_tests; m $TEST && $ANDROID_HOST_OUT/nativetest64/$TEST/$TEST
Change-Id: I4382b390f69094b4db8928b5caf9e9251723d32e
diff --git a/services/inputflinger/dispatcher/TouchedWindow.cpp b/services/inputflinger/dispatcher/TouchedWindow.cpp
index 5914808..037d7c8 100644
--- a/services/inputflinger/dispatcher/TouchedWindow.cpp
+++ b/services/inputflinger/dispatcher/TouchedWindow.cpp
@@ -162,6 +162,22 @@
}
}
+bool TouchedWindow::hasActiveStylus() const {
+ for (const auto& [_, state] : mDeviceStates) {
+ for (const PointerProperties& properties : state.touchingPointers) {
+ if (properties.toolType == ToolType::STYLUS) {
+ return true;
+ }
+ }
+ for (const PointerProperties& properties : state.hoveringPointers) {
+ if (properties.toolType == ToolType::STYLUS) {
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
std::set<DeviceId> TouchedWindow::getTouchingDeviceIds() const {
std::set<DeviceId> deviceIds;
for (const auto& [deviceId, deviceState] : mDeviceStates) {