Fixed and improve RunCommand() when running as root.

Improved it by not try to run 'su root' on user builds.
Fixed the logic that creates the args.

BUG: 29319732
BUG: 26379932
Test: manual

Change-Id: I6b39abc8ee907f638905913425218c0a50d767c6
diff --git a/cmds/dumpstate/dumpstate.h b/cmds/dumpstate/dumpstate.h
index bfa894e..9292cb4 100644
--- a/cmds/dumpstate/dumpstate.h
+++ b/cmds/dumpstate/dumpstate.h
@@ -215,6 +215,11 @@
     bool IsDryRun();
 
     /*
+     * Gets whether device is running a `user` build.
+     */
+    bool IsUserBuild();
+
+    /*
      * Forks a command, waits for it to finish, and returns its status.
      *
      * |title| description of the command printed on `stdout` (or empty to skip
@@ -235,8 +240,8 @@
      * description).
      * |dumpsys_args| `dumpsys` arguments (except `-t`).
      * |options| optional argument defining the command's behavior.
- * |dumpsysTimeout| when > 0, defines the value passed to `dumpsys -t` (otherwise it uses the
- * timeout from `options`)
+     * |dumpsysTimeout| when > 0, defines the value passed to `dumpsys -t` (otherwise it uses the
+     * timeout from `options`)
      */
     void RunDumpsys(const std::string& title, const std::vector<std::string>& dumpsysArgs,
                     const CommandOptions& options = CommandOptions::DEFAULT_DUMPSYS,