Winscope: Prevent layers trace from capturing entries once its disabled

Bug: 110052395
Test: manually capture Layers trace and check results
Test: run atest FlickerTest:CloseImeWindowToHomeTest
(some test runs were failing due to this issue)

Change-Id: Iadbc1894721e72f951ebdf127691010df4eb2bb9
diff --git a/services/surfaceflinger/SurfaceTracing.cpp b/services/surfaceflinger/SurfaceTracing.cpp
index f8c466e..0e9b04e 100644
--- a/services/surfaceflinger/SurfaceTracing.cpp
+++ b/services/surfaceflinger/SurfaceTracing.cpp
@@ -58,7 +58,9 @@
 
 void SurfaceTracing::traceLayers(const char* where, LayersProto layers) {
     std::lock_guard<std::mutex> protoGuard(mTraceMutex);
-
+    if (!mEnabled) {
+        return;
+    }
     LayersTraceProto* entry = mTrace.add_entry();
     entry->set_elapsed_realtime_nanos(elapsedRealtimeNano());
     entry->set_where(where);