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
diff --git a/libs/gui/include/gui/SurfaceComposerClient.h b/libs/gui/include/gui/SurfaceComposerClient.h
index 24399ff..d5f4414 100644
--- a/libs/gui/include/gui/SurfaceComposerClient.h
+++ b/libs/gui/include/gui/SurfaceComposerClient.h
@@ -387,22 +387,6 @@
std::unordered_set<sp<SurfaceControl>, SCHash> surfaceControls;
};
- // TODO(b/222421815) this class should be removed when
- // SurfaceComposerClient::Transaction::syncInputWindows is removed and replaced with a method
- // for adding callbacks to InputWindowCommands.
- class Event {
- private:
- static constexpr std::chrono::seconds sTimeout{5};
-
- bool mComplete = false;
- std::condition_variable mConditionVariable;
- std::mutex mMutex;
-
- public:
- void set();
- bool wait();
- };
-
class Transaction : public Parcelable {
private:
void releaseBufferIfOverwriting(const layer_state_t& state);
@@ -452,8 +436,6 @@
InputWindowCommands mInputWindowCommands;
int mStatus = NO_ERROR;
- std::shared_ptr<Event> mWindowInfosReportedEvent = nullptr;
-
layer_state_t* getLayerState(const sp<SurfaceControl>& sc);
DisplayState& getDisplayState(const sp<IBinder>& token);
@@ -588,7 +570,9 @@
Transaction& setInputWindowInfo(const sp<SurfaceControl>& sc, const gui::WindowInfo& info);
Transaction& setFocusedWindow(const gui::FocusRequest& request);
- Transaction& syncInputWindows();
+
+ Transaction& addWindowInfosReportedListener(
+ sp<gui::IWindowInfosReportedListener> windowInfosReportedListener);
// Set a color transform matrix on the given layer on the built-in display.
Transaction& setColorTransform(const sp<SurfaceControl>& sc, const mat3& matrix,