Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3581ce1b authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Crash if can't add window infos listener" into main

parents ebdcfb29 8c38c679
Loading
Loading
Loading
Loading
+11 −18
Original line number Diff line number Diff line
@@ -14,6 +14,7 @@
 * limitations under the License.
 */

#include <android-base/logging.h>
#include <android/gui/ISurfaceComposer.h>
#include <android/gui/IWindowInfosListener.h>
#include <gui/AidlUtil.h>
@@ -35,29 +36,21 @@ sp<WindowInfosListenerReporter> WindowInfosListenerReporter::getInstance() {
android::base::Result<gui::WindowInfosUpdate> WindowInfosListenerReporter::addWindowInfosListener(
        sp<WindowInfosListener> windowInfosListener,
        const sp<gui::ISurfaceComposer>& surfaceComposer) {
    status_t status = OK;
    {
    std::scoped_lock lock(mListenersMutex);
    if (mWindowInfosListeners.empty()) {
        gui::WindowInfosListenerInfo listenerInfo;
            binder::Status s = surfaceComposer->addWindowInfosListener(this, &listenerInfo);
            status = statusTFromBinderStatus(s);
            if (status == OK) {
        binder::Status status = surfaceComposer->addWindowInfosListener(this, &listenerInfo);
        LOG_IF(FATAL, !status.isOk()) << "Can't register window infos listener for pid " << getpid()
                                      << ". Device won't be usable";

        mWindowInfosPublisher = std::move(listenerInfo.windowInfosPublisher);
        mListenerId = listenerInfo.listenerId;
    }
        }

        if (status == OK) {
    mWindowInfosListeners.emplace(std::move(windowInfosListener));
        }

    return mLastUpdate;
}

    return android::base::Error(status);
}

status_t WindowInfosListenerReporter::removeWindowInfosListener(
        const sp<WindowInfosListener>& windowInfosListener,
        const sp<gui::ISurfaceComposer>& surfaceComposer) {