Fix lambda capture

The scheduled takeLayersSnapshotProto() call is not waited anymore
(see deadlock fix for b/313130597), hence the traceFlags local
variable must be captured by value to avoid referencing it after
it goes out of scope.

Fix: 370018409
Flag: EXEMPT bugfix
Test: presubmit
Change-Id: I0285ba70475cec3e4c54787303aea535bf866d72
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 06560d0..692d0f4 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -952,7 +952,7 @@
                 // Do not wait the future to avoid deadlocks
                 // between main and Perfetto threads (b/313130597)
                 static_cast<void>(mScheduler->schedule(
-                        [&, onLayersSnapshot]() FTL_FAKE_GUARD(mStateLock)
+                        [&, traceFlags, onLayersSnapshot]() FTL_FAKE_GUARD(mStateLock)
                                 FTL_FAKE_GUARD(kMainThreadContext) {
                                     auto snapshot =
                                             takeLayersSnapshotProto(traceFlags, TimePoint::now(),