Let dumpstate also call "cmd input_method tracing save-for-bugreport"

This is a follow up CL to previous CL [1], which was to include
winscope tracing files from WindowManagerService into bugreport.

What this CL aims to do is also supporting InputMethodManagerService,
which is going to support winscope-compatible tracing protocol.  With
this CL Dumpstate::MaybeSnapshotSystemTrace() starts calling the
following two shell commands:

  cmd window tracing save-for-bugreport
  cmd input_method tracing save-for-bugreport

On branches where InputMethodManagerService 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 input_method tracing save-for-bugreport'  \
        failed: exit code 255

Like existing winscope tracing files, IME tracing files will be stored
in "/data/misc/wmtrace/" in the bugreport.

Here are upper limit of those tracing files.
  ime_trace_clients.pb:        4MB
  ime_trace_service.pb:        4MB
  ime_trace_managerservice.pb: 4MB

 [1]: I8be9dee9aa36c2b085596d58e418f8613d874500
      95305b3ba7bf18bc7ed3a07c67f84b1c2f4586f4

Bug: 177462676
Test: Manually made sure as follows that wintrace log from
      WindowManagerService is still included in the bugreport
      if WMS supports "tracing save-for-bugreport".
  1. adb logcat -d -s WindowTracing:*
       Make sure wintrace is not yet running
  2. adb shell cmd window tracing start
  3. adb logcat -d -s WindowTracing:*
       Make sure wintrace is running
  4. adb bugreport bugreport.zip
  5. adb logcat -d -s WindowTracing:*
       Make sure wintrace stopped then restarted.
  6. unzip -v bugreport.zip | grep wm_
       Make sure "wm_{trace,log}.pb" are included.
Test: Manually made sure as follows that wintrace log from
      InputMethodManagerService is included in the bugreport
      if IMMS supports "tracing save-for-bugreport".
  1. adb logcat -d -s imeTracing:*
       Make sure ime tracing is not yet running
  2. adb shell cmd input_method tracing start
  3. adb logcat -d -s imeTracing:*
       Make sure ime tracing is running
  4. adb bugreport bugreport.zip
  5. adb logcat -d -s imeTracing:*
       Make sure ime tracing is dumped and still running.
  6. unzip -v bugreport.zip | grep ime_trace_
       Make sure ime_trace_{clients,service,managerservice}.pb are
       included.
Change-Id: I62105334e4efbb4514390ffa8be5416482ca3b29
diff --git a/cmds/dumpstate/dumpstate.cpp b/cmds/dumpstate/dumpstate.cpp
index f553697..8fd05fb 100644
--- a/cmds/dumpstate/dumpstate.cpp
+++ b/cmds/dumpstate/dumpstate.cpp
@@ -3024,11 +3024,14 @@
 }
 
 void Dumpstate::MaybeSnapshotWinTrace() {
-    RunCommand(
-        // Empty name because it's not intended to be classified as a bugreport section.
-        // Actual tracing files can be found in "/data/misc/wmtrace/" in the bugreport.
-        "", {"cmd", "window", "tracing", "save-for-bugreport"},
-        CommandOptions::WithTimeout(10).Always().DropRoot().RedirectStderr().Build());
+    // Currently WindowManagerService and InputMethodManagerSerivice support WinScope protocol.
+    for (const auto& service : {"window", "input_method"}) {
+        RunCommand(
+            // Empty name because it's not intended to be classified as a bugreport section.
+            // Actual tracing files can be found in "/data/misc/wmtrace/" in the bugreport.
+            "", {"cmd", service, "tracing", "save-for-bugreport"},
+            CommandOptions::WithTimeout(10).Always().DropRoot().RedirectStderr().Build());
+    }
 }
 
 void Dumpstate::onUiIntensiveBugreportDumpsFinished(int32_t calling_uid) {