diff options
| author | 2023-03-03 13:41:37 -0600 | |
|---|---|---|
| committer | 2023-03-03 20:10:06 +0000 | |
| commit | 30df05414700592d9eb0e60a6d34598034b2c052 (patch) | |
| tree | 9318dd961c8e14776b680ce08f860e4c79a9803d | |
| parent | c1270f0f0f19a795b2c9259072336d9946e3c69c (diff) | |
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
| -rw-r--r-- | libs/gui/WindowInfosListenerReporter.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/libs/gui/WindowInfosListenerReporter.cpp b/libs/gui/WindowInfosListenerReporter.cpp index 01e865da6a..2b34a0fc47 100644 --- a/libs/gui/WindowInfosListenerReporter.cpp +++ b/libs/gui/WindowInfosListenerReporter.cpp @@ -62,6 +62,10 @@ status_t WindowInfosListenerReporter::removeWindowInfosListener( 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); |