Replace syncInputWindows with addWindowInfosReportedListener

Bug: 222421815
Change-Id: Ica0b6aa0f4c2c0405cc34acf0147b0fffe439076
Test: manual
diff --git a/libs/gui/SurfaceComposerClient.cpp b/libs/gui/SurfaceComposerClient.cpp
index 16dbc92..d365851 100644
--- a/libs/gui/SurfaceComposerClient.cpp
+++ b/libs/gui/SurfaceComposerClient.cpp
@@ -636,8 +636,7 @@
         mDesiredPresentTime(other.mDesiredPresentTime),
         mIsAutoTimestamp(other.mIsAutoTimestamp),
         mFrameTimelineInfo(other.mFrameTimelineInfo),
-        mApplyToken(other.mApplyToken),
-        mWindowInfosReportedEvent(other.mWindowInfosReportedEvent) {
+        mApplyToken(other.mApplyToken) {
     mDisplayStates = other.mDisplayStates;
     mComposerStates = other.mComposerStates;
     mInputWindowCommands = other.mInputWindowCommands;
@@ -881,9 +880,6 @@
     mEarlyWakeupStart = mEarlyWakeupStart || other.mEarlyWakeupStart;
     mEarlyWakeupEnd = mEarlyWakeupEnd || other.mEarlyWakeupEnd;
     mApplyToken = other.mApplyToken;
-    if (other.mWindowInfosReportedEvent) {
-        mWindowInfosReportedEvent = std::move(other.mWindowInfosReportedEvent);
-    }
 
     mergeFrameTimelineInfo(mFrameTimelineInfo, other.mFrameTimelineInfo);
 
@@ -906,7 +902,6 @@
     mIsAutoTimestamp = true;
     clearFrameTimelineInfo(mFrameTimelineInfo);
     mApplyToken = nullptr;
-    mWindowInfosReportedEvent = nullptr;
 }
 
 uint64_t SurfaceComposerClient::Transaction::getId() {
@@ -1053,10 +1048,6 @@
                             hasListenerCallbacks, listenerCallbacks, mId);
     mId = generateId();
 
-    if (mWindowInfosReportedEvent && !mWindowInfosReportedEvent->wait()) {
-        ALOGE("Timed out waiting for window infos to be reported.");
-    }
-
     // Clear the current states and flags
     clear();
 
@@ -1743,25 +1734,10 @@
     return *this;
 }
 
-class NotifyWindowInfosReported : public gui::BnWindowInfosReportedListener {
-public:
-    NotifyWindowInfosReported(
-            std::shared_ptr<SurfaceComposerClient::Event> windowInfosReportedEvent)
-          : mWindowInfosReportedEvent(windowInfosReportedEvent) {}
-
-    binder::Status onWindowInfosReported() {
-        mWindowInfosReportedEvent->set();
-        return binder::Status::ok();
-    }
-
-private:
-    std::shared_ptr<SurfaceComposerClient::Event> mWindowInfosReportedEvent;
-};
-
-SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::syncInputWindows() {
-    mWindowInfosReportedEvent = std::make_shared<Event>();
-    mInputWindowCommands.windowInfosReportedListeners.insert(
-            sp<NotifyWindowInfosReported>::make(mWindowInfosReportedEvent));
+SurfaceComposerClient::Transaction&
+SurfaceComposerClient::Transaction::addWindowInfosReportedListener(
+        sp<gui::IWindowInfosReportedListener> windowInfosReportedListener) {
+    mInputWindowCommands.windowInfosReportedListeners.insert(windowInfosReportedListener);
     return *this;
 }
 
@@ -2849,17 +2825,4 @@
     }
 }
 
-// ---------------------------------------------------------------------------------
-
-void SurfaceComposerClient::Event::set() {
-    std::lock_guard<std::mutex> lock(mMutex);
-    mComplete = true;
-    mConditionVariable.notify_all();
-}
-
-bool SurfaceComposerClient::Event::wait() {
-    std::unique_lock<std::mutex> lock(mMutex);
-    return mConditionVariable.wait_for(lock, sTimeout, [this] { return mComplete; });
-}
-
 } // namespace android