Add synchronous transaction to wait for setInputWindow to complete (4/n)
Wait for callback from InputDispatcher before returning to client.
If the request to SF has the flag syncInputWindows, wait until the
callback setInputWindowsFinished has been called from InputDispatcher
before returning to the client.
Bug: 123041491
Test: Builds, runs
Change-Id: I9d3fb83442cf344c43449bb072a1c31b300b2879
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 3f2f79b..ff6660c 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -2952,6 +2952,10 @@
if (mVisibleRegionsDirty || mInputInfoChanged) {
mInputInfoChanged = false;
updateInputWindowInfo();
+ } else if (mInputWindowCommands.syncInputWindows) {
+ // If the caller requested to sync input windows, but there are no
+ // changes to input windows, notify immediately.
+ setInputWindowsFinished();
}
executeInputWindowCommands();
@@ -3681,13 +3685,16 @@
if (flags & eAnimation) {
mAnimTransactionPending = true;
}
- while (mTransactionPending) {
+
+ mPendingSyncInputWindows = mPendingInputWindowCommands.syncInputWindows;
+ while (mTransactionPending || mPendingSyncInputWindows) {
status_t err = mTransactionCV.waitRelative(mStateLock, s2ns(5));
if (CC_UNLIKELY(err != NO_ERROR)) {
// just in case something goes wrong in SF, return to the
// called after a few seconds.
ALOGW_IF(err == TIMED_OUT, "setTransactionState timed out!");
mTransactionPending = false;
+ mPendingSyncInputWindows = false;
break;
}
}
@@ -5657,7 +5664,12 @@
return NO_ERROR;
}
-void SurfaceFlinger::setInputWindowsFinished() {}
+void SurfaceFlinger::setInputWindowsFinished() {
+ Mutex::Autolock _l(mStateLock);
+
+ mPendingSyncInputWindows = false;
+ mTransactionCV.broadcast();
+}
// ---------------------------------------------------------------------------