Add synchronous transaction to wait for setInputWindow to complete (1/n)
Add SurfaceFlinger callback to notify when input windows have been set.
The call to set input windows from SF to InputDispatcher is one way.
Therefore, it won't wait to ensure the windows have been set. Add a
callback method to allow InputDispatcher to notify SF when it's finished
setting the input windows, allowing SF to block if needed.
Bug: 123041491
Test: Builds and runs
Change-Id: Ia4196d2e517c07d94ab9da71beab057d5d6fcf1c
diff --git a/libs/gui/ISurfaceComposer.cpp b/libs/gui/ISurfaceComposer.cpp
index f77eeb2..9197262 100644
--- a/libs/gui/ISurfaceComposer.cpp
+++ b/libs/gui/ISurfaceComposer.cpp
@@ -806,6 +806,12 @@
}
return error;
}
+
+ virtual void setInputWindowsFinished() {
+ Parcel data, reply;
+ data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
+ remote()->transact(BnSurfaceComposer::SET_INPUT_WINDOWS_FINISHED, data, &reply);
+ }
};
// Out-of-line virtual method definition to trigger vtable emission in this
@@ -1317,6 +1323,11 @@
}
return removeRegionSamplingListener(listener);
}
+ case SET_INPUT_WINDOWS_FINISHED: {
+ CHECK_INTERFACE(ISurfaceComposer, data, reply);
+ setInputWindowsFinished();
+ return NO_ERROR;
+ }
default: {
return BBinder::onTransact(code, data, reply, flags);
}
diff --git a/libs/gui/include/gui/ISurfaceComposer.h b/libs/gui/include/gui/ISurfaceComposer.h
index 1a0b6bb..c2d7d28 100644
--- a/libs/gui/include/gui/ISurfaceComposer.h
+++ b/libs/gui/include/gui/ISurfaceComposer.h
@@ -359,6 +359,8 @@
* Removes a listener that was streaming median luma updates from SurfaceFlinger.
*/
virtual status_t removeRegionSamplingListener(const sp<IRegionSamplingListener>& listener) = 0;
+
+ virtual void setInputWindowsFinished() = 0;
};
// ----------------------------------------------------------------------------
@@ -406,6 +408,8 @@
GET_PHYSICAL_DISPLAY_IDS,
ADD_REGION_SAMPLING_LISTENER,
REMOVE_REGION_SAMPLING_LISTENER,
+ SET_INPUT_WINDOWS_FINISHED,
+
// Always append new enum to the end.
};
diff --git a/libs/gui/tests/Surface_test.cpp b/libs/gui/tests/Surface_test.cpp
index f127853..8225647 100644
--- a/libs/gui/tests/Surface_test.cpp
+++ b/libs/gui/tests/Surface_test.cpp
@@ -679,6 +679,8 @@
return NO_ERROR;
}
+ void setInputWindowsFinished() override {}
+
protected:
IBinder* onAsBinder() override { return nullptr; }
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index dc3409b..a4f6005 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -5154,7 +5154,8 @@
case GET_COLOR_MANAGEMENT:
case GET_COMPOSITION_PREFERENCE:
case GET_PROTECTED_CONTENT_SUPPORT:
- case IS_WIDE_COLOR_DISPLAY: {
+ case IS_WIDE_COLOR_DISPLAY:
+ case SET_INPUT_WINDOWS_FINISHED: {
return OK;
}
case CAPTURE_LAYERS:
@@ -5887,6 +5888,8 @@
return NO_ERROR;
}
+void SurfaceFlinger::setInputWindowsFinished() {}
+
// ---------------------------------------------------------------------------
void SurfaceFlinger::State::traverseInZOrder(const LayerVector::Visitor& visitor) const {
diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h
index 02898b2..2d53eb8 100644
--- a/services/surfaceflinger/SurfaceFlinger.h
+++ b/services/surfaceflinger/SurfaceFlinger.h
@@ -479,6 +479,7 @@
status_t addRegionSamplingListener(const Rect& samplingArea, const sp<IBinder>& stopLayerHandle,
const sp<IRegionSamplingListener>& listener) override;
status_t removeRegionSamplingListener(const sp<IRegionSamplingListener>& listener) override;
+ void setInputWindowsFinished() override;
/* ------------------------------------------------------------------------
* DeathRecipient interface
*/