Ensure wallpaper connection is valid before canceling its events
The InputDispatcher function
'synthesizeCancelationEventsForConnectionLocked' expects non-null
connection. Ideally, we would refactor this function to receive
Connection&. However, this connection needs to be passed to other
functions called within, so for simplicity, we are keeping the incoming
parameter as sp<Connection>.
That means that the called must ensure that the connection is not null.
Fix the previous wallpaper CL by checking if the connection is null.
Bug: 206651192
Test: atest inputflinger_tests
Change-Id: Id6d9235144606a629dfbd2614e211412def1a68e
diff --git a/services/inputflinger/dispatcher/InputDispatcher.cpp b/services/inputflinger/dispatcher/InputDispatcher.cpp
index 7bef775..d5d906b 100644
--- a/services/inputflinger/dispatcher/InputDispatcher.cpp
+++ b/services/inputflinger/dispatcher/InputDispatcher.cpp
@@ -4689,8 +4689,10 @@
if (wallpaper != nullptr) {
sp<Connection> wallpaperConnection =
getConnectionLocked(wallpaper->getToken());
- synthesizeCancelationEventsForConnectionLocked(wallpaperConnection,
- options);
+ if (wallpaperConnection != nullptr) {
+ synthesizeCancelationEventsForConnectionLocked(wallpaperConnection,
+ options);
+ }
}
}
}