[sf] provide a unique id for snapshots
Input and layer tracing relies on the fact that all layers
have a unique id. Because mirror layers are no longer
implemented by duplicating layers, we can have multiple
snapshots with the same id. To fix this, provide a unique
id that can be used by consumers who require them.
Test: atest FlickerTest
Bug: 238781169
Change-Id: Ibe54154b6e14f72bfe73a15faa0e7e0d19293e36
diff --git a/services/surfaceflinger/LayerProtoHelper.cpp b/services/surfaceflinger/LayerProtoHelper.cpp
index 1a828bf..55281fa 100644
--- a/services/surfaceflinger/LayerProtoHelper.cpp
+++ b/services/surfaceflinger/LayerProtoHelper.cpp
@@ -260,6 +260,7 @@
frontend::LayerSnapshot* snapshot = snapshotBuilder.getSnapshot(layer.id);
if (!snapshot) {
+ defaultSnapshot.uniqueSequence = layer.id;
snapshot = &defaultSnapshot;
}
writeSnapshotToProto(layerProto, layer, *snapshot, traceFlags);
@@ -343,7 +344,7 @@
[&]() { return layerInfo->mutable_corner_radius_crop(); });
layerInfo->set_shadow_radius(snapshot.shadowRadius);
- layerInfo->set_id(requestedState.id);
+ layerInfo->set_id(snapshot.uniqueSequence);
layerInfo->set_name(requestedState.name);
layerInfo->set_type("Layer");