Fix file permissions of generated layers trace
Fix: 305129514
Test: adb shell rm /data/misc/wmtrace/layers_trace_from_transactions.winscope \
&& adb bugreport \
&& check generated bugreport contains FS/data/misc/wmtrace/layers_trace_from_transactions.winscope
Change-Id: I7cf087265df9ce1cc5da8536d6b03285685cd26e
diff --git a/services/surfaceflinger/Tracing/tools/main.cpp b/services/surfaceflinger/Tracing/tools/main.cpp
index 698ef06..18022b1 100644
--- a/services/surfaceflinger/Tracing/tools/main.cpp
+++ b/services/surfaceflinger/Tracing/tools/main.cpp
@@ -64,8 +64,17 @@
if (!LayerTraceGenerator().generate(transactionTraceFile, traceFlags, layerTracing,
generateLastEntryOnly)) {
- std::cout << "Error: Failed to generate layers trace " << outputLayersTracePath;
+ std::cout << "Error: Failed to generate layers trace " << outputLayersTracePath << "\n";
return -1;
}
+
+ // Set output file permissions (-rw-r--r--)
+ outStream.close();
+ const mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
+ if (chmod(outputLayersTracePath, mode) != 0) {
+ std::cout << "Error: Failed to set permissions of " << outputLayersTracePath << "\n";
+ return -1;
+ }
+
return 0;
}