Create record_binder tool

record_binder is a tool for starting and stopping the recording of
binder transactions for a service.

record_binder is the same aidl analyzer binary with no analyzers. When
no analyzers are present, the list command is removed. Without
analyzers, thus no definition of specific transactions, record_binder
cannot inspect transactions in detail. All the rest of the functionality
probably still makes sense for record_binder, including the planned
support for replaying recorded transactions.

Test: Make a fresh image. Use and explore with `record_binder`
Change-Id: Ie678419d63e5d7777ee77826fcf3adba6875dcb9
diff --git a/Android.bp b/Android.bp
index f9179de..232ed5d 100644
--- a/Android.bp
+++ b/Android.bp
@@ -865,3 +865,13 @@
     ],
     export_include_dirs: ["analyzer/include"],
 }
+
+cc_binary {
+    name: "record_binder",
+    whole_static_libs: ["aidl-analyzer-main"],
+    shared_libs: [
+        "libbase",
+        "libbinder",
+        "libutils"
+    ],
+}
diff --git a/analyzer/analyzerMain.cpp b/analyzer/analyzerMain.cpp
index e13eba8..01a36df 100644
--- a/analyzer/analyzerMain.cpp
+++ b/analyzer/analyzerMain.cpp
@@ -326,7 +326,7 @@
     "  <service>\t?\n"
     "  <file-name>\tThe name of a file in /data/local/recordings/"};
 
-const auto& commands = *new std::map<std::string, AnalyzerCommand>{
+auto& commands = *new std::map<std::string, AnalyzerCommand>{
     {"start", startCommand},   {"stop", stopCommand},     {"inspect", inspectCommand},
     {"listen", listenCommand}, {"replay", replayCommand}, {"list", listCommand},
     {"help", helpCommand},
@@ -389,6 +389,11 @@
 int main(int argc, char* argv[]) {
   std::string toolName = argv[0];
 
+  auto& analyzers = Analyzer::getAnalyzers();
+  if (analyzers.size() == 0) {
+    commands.erase("list");
+  }
+
   if (argc < 2 ||
       (argc >= 2 && ((strcmp(argv[1], "--help") == 0) || (strcmp(argv[1], "-h") == 0)))) {
     // General help