InputDispatcher: Do not synthesize cancelations for zombie connections
When an input channel is removed, we mark it as a zombie connection in
Dispatcher.
Whenever we leave a critical section inside Dispatcher, it is possible
for an input channel to be removed. When handling fallback keys, we make
a policy call synchronously while processing the unhandled key
by releasing the lock. After returning from the policy call, it's
possible the input channel was removed, leaving the connection in a
zombie state.
When in this state, if we try to synthesize a cancelation event, we
would end up crashing. To avoid this, ensure we don't try to synthesize
cancelations for channels that aren't normal (i.e. broken or zombie
channels).
Bug: 319186639
Test: atest inputflinger_tests
Change-Id: I05a9b001de19bf26d81ea50a511d84bc3a2045d2
diff --git a/services/inputflinger/dispatcher/InputDispatcher.cpp b/services/inputflinger/dispatcher/InputDispatcher.cpp
index 768ed82..6319322 100644
--- a/services/inputflinger/dispatcher/InputDispatcher.cpp
+++ b/services/inputflinger/dispatcher/InputDispatcher.cpp
@@ -4002,7 +4002,7 @@
void InputDispatcher::synthesizeCancelationEventsForConnectionLocked(
const std::shared_ptr<Connection>& connection, const CancelationOptions& options) {
- if (connection->status == Connection::Status::BROKEN) {
+ if (connection->status != Connection::Status::NORMAL) {
return;
}