[sf] Use layer id as snapshot ids
Flicker tests rely on layer ids for some assertions. So when possible
use the layer id for the snapshot used to generate layer traces.
Also keep track of the order in which layers are added so its easier to
write tests.
Test: atest FlickerTests w/new fe
Bug: 238781169
Change-Id: Ie0f93ca956e6d043c9d95d00bc205d242e47c4cc
diff --git a/services/surfaceflinger/FrontEnd/LayerSnapshot.cpp b/services/surfaceflinger/FrontEnd/LayerSnapshot.cpp
index 1e931a7..a992584 100644
--- a/services/surfaceflinger/FrontEnd/LayerSnapshot.cpp
+++ b/services/surfaceflinger/FrontEnd/LayerSnapshot.cpp
@@ -27,7 +27,6 @@
LayerSnapshot::LayerSnapshot(const RequestedLayerState& state,
const LayerHierarchy::TraversalPath& path)
: path(path) {
- static uint32_t sUniqueSequenceId = 0;
// Provide a unique id for all snapshots.
// A front end layer can generate multiple snapshots if its mirrored.
// Additionally, if the layer is not reachable, we may choose to destroy
@@ -35,7 +34,12 @@
// change. The consumer shouldn't tie any lifetimes to this unique id but
// register a LayerLifecycleManager::ILifecycleListener or get a list of
// destroyed layers from LayerLifecycleManager.
- uniqueSequence = sUniqueSequenceId++;
+ if (path.isClone()) {
+ uniqueSequence =
+ LayerCreationArgs::getInternalLayerId(LayerCreationArgs::sInternalSequence++);
+ } else {
+ uniqueSequence = state.id;
+ }
sequence = static_cast<int32_t>(state.id);
name = state.name;
textureName = state.textureName;