Don't allow both setRelative and setLayer for the same surface.
Both setRelativeLayer and setLayer are used to set z order. The two will
conflict if set on the same transaction for the same surface.
SurfaceFlinger will just apply setRelativeLayer since it's second in the
setClientState order. Instead, the code should only apply the
transaction that was requested last. This change removes the
setRelativeLayer flag if the setLayer flag is added and vice-versa.
Fixes: 131834423
Test: Steps from bug
Test: LayerTypeTransactionTest.SetLayerAndRelative
Change-Id: Ib14aa5c666e74455e5ccb26a0fea94699bcc5771
diff --git a/libs/gui/SurfaceComposerClient.cpp b/libs/gui/SurfaceComposerClient.cpp
index 5d4367d..d059861 100644
--- a/libs/gui/SurfaceComposerClient.cpp
+++ b/libs/gui/SurfaceComposerClient.cpp
@@ -611,6 +611,7 @@
return *this;
}
s->what |= layer_state_t::eLayerChanged;
+ s->what &= ~layer_state_t::eRelativeLayerChanged;
s->z = z;
registerSurfaceControlForCallback(sc);
@@ -624,6 +625,7 @@
mStatus = BAD_INDEX;
}
s->what |= layer_state_t::eRelativeLayerChanged;
+ s->what &= ~layer_state_t::eLayerChanged;
s->relativeLayerHandle = relativeTo;
s->z = z;