Improve binder_record and analyzer tools
- Make use of interfaceName being std::string
- Add list command when analyzers are present instead of removing when
they are not.
- Add newline after "Unrecognized command: " output
Test: Use the `binder_record` command on a device. Also build and run an
analyzer e.g. `m android.hardware.power-cpp-analyzer`
Change-Id: I0a76ac968ccd2ccf2651f83d4d0383fa9e4ccfac
diff --git a/analyzer/analyzerMain.cpp b/analyzer/analyzerMain.cpp
index 01a36df..515df5e 100644
--- a/analyzer/analyzerMain.cpp
+++ b/analyzer/analyzerMain.cpp
@@ -99,7 +99,7 @@
void printTransaction(const RecordedTransaction& transaction) {
auto& analyzers = Analyzer::getAnalyzers();
- auto analyzer = analyzers.find(std::string(transaction.getInterfaceName()));
+ auto analyzer = analyzers.find(transaction.getInterfaceName());
if (analyzer != analyzers.end()) {
(analyzer->second)
->getAnalyzeFunction()(transaction.getCode(), transaction.getDataParcel(),
@@ -328,9 +328,7 @@
auto& commands = *new std::map<std::string, AnalyzerCommand>{
{"start", startCommand}, {"stop", stopCommand}, {"inspect", inspectCommand},
- {"listen", listenCommand}, {"replay", replayCommand}, {"list", listCommand},
- {"help", helpCommand},
-};
+ {"listen", listenCommand}, {"replay", replayCommand}, {"help", helpCommand}};
void printGeneralHelp(std::string& toolName) {
std::cout << "USAGE: " << toolName << " <command> [<args>]\n\n";
@@ -371,7 +369,7 @@
auto command = commands.find(commandName);
if (command == commands.end()) {
- std::cout << "Unrecognized command: " << commandName;
+ std::cout << "Unrecognized command: " << commandName << "\n";
printGeneralHelp(toolName);
return -1;
}
@@ -390,8 +388,8 @@
std::string toolName = argv[0];
auto& analyzers = Analyzer::getAnalyzers();
- if (analyzers.size() == 0) {
- commands.erase("list");
+ if (analyzers.size() >= 1) {
+ commands["list"] = listCommand;
}
if (argc < 2 ||