Sets dumpstate version using system properties.

Android N introduced a '-V' argument to change dumpstate's version, but
such argument can only be used when running dumpstate directly (as
root).
This CL uses a system property instead (dumpstate.version), so different
versions can be used while taking bugreports.

It also introduces a '-v' argument line to display the dumpstate header,
and removes the redundant dry_run check from _dump_file_from_fd().

Test: DumpstateTest passes
Change-Id: I46ec4bca133d16d8431358bb9f16eb89bb082be1
diff --git a/cmds/dumpstate/utils.cpp b/cmds/dumpstate/utils.cpp
index 527cf91..31c8697 100644
--- a/cmds/dumpstate/utils.cpp
+++ b/cmds/dumpstate/utils.cpp
@@ -163,12 +163,13 @@
     return CommandOptions::CommandOptionsBuilder(timeout);
 }
 
-Dumpstate::Dumpstate(bool dry_run, const std::string& build_type)
-    : now_(time(nullptr)), dry_run_(dry_run), build_type_(build_type) {
+Dumpstate::Dumpstate(const std::string& version, bool dry_run, const std::string& build_type)
+    : version_(version), now_(time(nullptr)), dry_run_(dry_run), build_type_(build_type) {
 }
 
 Dumpstate& Dumpstate::GetInstance() {
-    static Dumpstate singleton_(android::base::GetBoolProperty("dumpstate.dry_run", false),
+    static Dumpstate singleton_(android::base::GetProperty("dumpstate.version", VERSION_CURRENT),
+                                android::base::GetBoolProperty("dumpstate.dry_run", false),
                                 android::base::GetProperty("ro.build.type", "(unknown)"));
     return singleton_;
 }
@@ -546,11 +547,6 @@
         }
         printf(") ------\n");
     }
-    if (IsDryRun()) {
-        UpdateProgress(WEIGHT_FILE);
-        close(fd);
-        return 0;
-    }
 
     bool newline = false;
     fd_set read_set;