Clear TrustedPresentationListener when a new listener is set
If a TrustedPresentationListener is overwritten for a Layer, the last
trusted presentation states need to be cleared.
It also needs to make sure composite is called after setting a
TrustedPresentationListener since the layer may already be in the
presented state and there's nothing new to compose. We need to make sure
the presentation state is computed at least once after setting the
TrustedPresentationListener
Test: TrustedPresentationCallbackTest
Bug: 256993331
Change-Id: I5cd344e9609d96c961fc70093ea705ee48f46817
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 5f95859..6f05894 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -4848,8 +4848,10 @@
}
if (what & layer_state_t::eTrustedPresentationInfoChanged) {
- layer->setTrustedPresentationInfo(s.trustedPresentationThresholds,
- s.trustedPresentationListener);
+ if (layer->setTrustedPresentationInfo(s.trustedPresentationThresholds,
+ s.trustedPresentationListener)) {
+ flags |= eTraversalNeeded;
+ }
}
if (what & layer_state_t::eFlushJankData) {
@@ -4951,8 +4953,10 @@
}
if (what & layer_state_t::eTrustedPresentationInfoChanged) {
- layer->setTrustedPresentationInfo(s.trustedPresentationThresholds,
- s.trustedPresentationListener);
+ if (layer->setTrustedPresentationInfo(s.trustedPresentationThresholds,
+ s.trustedPresentationListener)) {
+ flags |= eTraversalNeeded;
+ }
}
const auto& snapshot = mLayerSnapshotBuilder.getSnapshot(layer->getSequence());