Check if WindowInfosListener is present during remove
This makes it safe for removeWindowInfosListener to be called more than once on the same listener. This may happen if removeWindowInfosListener is called by the client and then from WindowInfosListener's destructor.
Bug: 263311858
Test: presumbits
Change-Id: I90f1b50ab7faa538b866ada65e7bb312b7c30ce0
diff --git a/libs/gui/WindowInfosListenerReporter.cpp b/libs/gui/WindowInfosListenerReporter.cpp
index 01e865d..2b34a0f 100644
--- a/libs/gui/WindowInfosListenerReporter.cpp
+++ b/libs/gui/WindowInfosListenerReporter.cpp
@@ -62,6 +62,10 @@
status_t status = OK;
{
std::scoped_lock lock(mListenersMutex);
+ if (mWindowInfosListeners.find(windowInfosListener) == mWindowInfosListeners.end()) {
+ return status;
+ }
+
if (mWindowInfosListeners.size() == 1) {
binder::Status s = surfaceComposer->removeWindowInfosListener(this);
status = statusTFromBinderStatus(s);