[metrics] Change -Xwrite-metrics-to-statsd to take explicit argument

Previously, we enabled statsd reporting by checking for the presence
of the -Xwrite-metrics-to-statsd argument. This makes it so we cannot
turn it off if we change to on by default. This CL changes the
argument to be -Xwrite-metrics-to-statsd=_, which allows us to force
the setting to either on or off.

Test instructions:

    adb shell setprop dalvik.vm.extra-opts \
        -Xwrite-metrics-to-statsd=true
    adb shell stop && adb shell start
    statsd_testdrive 332

Test: manual, see above
Bug: 170149255
Change-Id: Ie43618cf0b454b0986119fc6e501c035f971af15
diff --git a/runtime/metrics/reporter.cc b/runtime/metrics/reporter.cc
index a393f1b..745b9b1 100644
--- a/runtime/metrics/reporter.cc
+++ b/runtime/metrics/reporter.cc
@@ -137,7 +137,7 @@
   using M = RuntimeArgumentMap;
   return {
       .dump_to_logcat = args.Exists(M::WriteMetricsToLog),
-      .dump_to_statsd = args.Exists(M::WriteMetricsToStatsd),
+      .dump_to_statsd = args.GetOrDefault(M::WriteMetricsToStatsd),
       .dump_to_file = args.GetOptional(M::WriteMetricsToFile),
       .report_metrics_on_shutdown = !args.Exists(M::DisableFinalMetricsReport),
       .periodic_report_seconds = args.GetOptional(M::MetricsReportingPeriod),
diff --git a/runtime/parsed_options.cc b/runtime/parsed_options.cc
index fa52139..2a5bc9f 100644
--- a/runtime/parsed_options.cc
+++ b/runtime/parsed_options.cc
@@ -397,7 +397,9 @@
       .Define("-Xwrite-metrics-to-log")
           .WithHelp("Enables writing ART metrics to logcat")
           .IntoKey(M::WriteMetricsToLog)
-      .Define("-Xwrite-metrics-to-statsd")
+      .Define("-Xwrite-metrics-to-statsd=_")
+          .WithType<bool>()
+          .WithValueMap({{"false", false}, {"true", true}})
           .WithHelp("Enables writing ART metrics to statsd")
           .IntoKey(M::WriteMetricsToStatsd)
       .Define("-Xwrite-metrics-to-file=_")
diff --git a/runtime/runtime_options.def b/runtime/runtime_options.def
index 9552d50..b58d924 100644
--- a/runtime/runtime_options.def
+++ b/runtime/runtime_options.def
@@ -188,7 +188,7 @@
 
 // Metrics configuration settings
 RUNTIME_OPTIONS_KEY (Unit,                WriteMetricsToLog)
-RUNTIME_OPTIONS_KEY (Unit,                WriteMetricsToStatsd)
+RUNTIME_OPTIONS_KEY (bool,                WriteMetricsToStatsd,           false)
 RUNTIME_OPTIONS_KEY (std::string,         WriteMetricsToFile)
 RUNTIME_OPTIONS_KEY (Unit,                DisableFinalMetricsReport)
 RUNTIME_OPTIONS_KEY (unsigned int,        MetricsReportingPeriod)