Let dumpstate call "cmd window trace save-for-bugreport"
This is a preparation to rework our previous CL [1], which enabled
"adb bugreport" to include winscope tracing files into bugreport.
In that CL, we used dumpsys with "--dump-priority CRITICAL" and
"--proto" options as a trigger to save winscope files for bugreport.
In this CL, we let dumpstate explicitly call the following shell command
cmd window tracing save-for-bugreport
inspired by how Perfetto tracing is auto-included in bugreport [2].
void Dumpstate::MaybeSnapshotSystemTrace() {
...
int res = RunCommand(
"SERIALIZE PERFETTO TRACE",
{"perfetto", "--save-for-bugreport"},
CommandOptions::WithTimeout(10)
.DropRoot()
.CloseAllFileDescriptorsOnExec()
.Build());
has_system_trace_ = res == 0;
...
}
Note that with this CL winscope tracing files may contain more events
after saving WindowManager critical dump, it is supposed to be
ignorable as the command will be called immediately after taking
critical dumpsys.
On branches where WindowManagerService does not support the above
command, this CL will have no-op except for the following one-line log
will be seen in logcat.
02-20 00:56:30.754 root 5325 5325 E dumpstate: \
*** command 'cmd window tracing save-for-bugreport' \
failed: exit code 255
To summarize, WinScope logs continue to be dumped under
"/data/misc/wmtrace/"
in the bugreport, and size impact also remains to be the same.
wm_trace.pb: At most 2MB by default
wm_log.pb : At most 1MB by default
[1]: I102bc4afab5efff361633d75c09af1df4a11812e
9e2604688d4c64ea95128f9d8b3b08da508532dd
Bug: 177462676
Test: Manually done as follows.
1. adb logcat -d -s WindowTracing:*
Make sure wintrace is not yet running
2. adb logcat -d -s WindowTracing:*
Make sure there is no additional message
3. adb shell cmd window tracing start
4. adb logcat -d -s WindowTracing:*
Make sure wintrace is running
5. adb bugreport bugreport.zip
6. adb logcat -d -s WindowTracing:*
Make sure wintrace stopped then restarted if
WMS supports "tracing save-for-bugreport".
7. unzip -v bugreport.zip | grep wm_trace.pb
Make sure "wm_trace.pb" is included if
WMS supports "tracing save-for-bugreport"
Change-Id: I8be9dee9aa36c2b085596d58e418f8613d874500
diff --git a/cmds/dumpstate/dumpstate.h b/cmds/dumpstate/dumpstate.h
index f83968b..83e6787 100644
--- a/cmds/dumpstate/dumpstate.h
+++ b/cmds/dumpstate/dumpstate.h
@@ -549,6 +549,7 @@
void MaybeTakeEarlyScreenshot();
void MaybeSnapshotSystemTrace();
+ void MaybeSnapshotWinTrace();
void onUiIntensiveBugreportDumpsFinished(int32_t calling_uid);