SurfaceFlinger: Fix removal check when adding child layers.
Traversing the current state has the same problem we had in other
CL's with relative Z. In this case if there was a parent that
was relative-Zed then it's Z relative is removed, we will be unable
to add children to it until we assign it a new layer. However there's
no reason to traverse, we can just use the new "isPendingRemoval"
flag to detect this state.
Bug: 69633137
Test: Existing tests pass.
Change-Id: I4584f051346fe77c3e6158a04dd1279a86164476
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index ec2a459..0351b9f 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -2869,14 +2869,7 @@
if (parent == nullptr) {
mCurrentState.layersSortedByZ.add(lbc);
} else {
- bool found = false;
- mCurrentState.traverseInZOrder([&](Layer* layer) {
- if (layer == parent.get()) {
- found = true;
- }
- });
-
- if (!found) {
+ if (parent->isPendingRemoval()) {
ALOGE("addClientLayer called with a removed parent");
return NAME_NOT_FOUND;
}