Refactor options parsing in dumpstate

Dumpstate binder service is currently used only in the interactive
mode. It needs to be a proper binder service to support the new
bugreporting API. To do that the code needs to be more modular
and reusable.

BUG: 111441001
Test: mmm -j frameworks/native/cmds/dumpstate/ && \
  adb push ${OUT}/data/nativetest64/dumpstate_test* \
  /data/nativetest64 && \
  adb shell /data/nativetest64/dumpstate_test/dumpstate_test
Test: adb shell /data/nativetest64/dumpstate_smoke_test/dumpstate_smoke_test
Test: adb bugreport

Change-Id: Iebee8bfb533dc1d7c152d82fca1bbf9cc105bf34
diff --git a/cmds/dumpstate/Android.bp b/cmds/dumpstate/Android.bp
index c852df1..5acc09d 100644
--- a/cmds/dumpstate/Android.bp
+++ b/cmds/dumpstate/Android.bp
@@ -133,6 +133,7 @@
     name: "dumpstate_test",
     defaults: ["dumpstate_defaults"],
     srcs: [
+        "dumpstate.cpp",
         "tests/dumpstate_test.cpp",
     ],
     static_libs: ["libgmock"],