This cl implements CommandSection and use it to add procrank.proto Section
Bug: 63863444
Test: manual - create gtests for CommandSection and Procrank Parser following
instructions in the README.md of incidentd and incident_helper on how to
run them.
Change-Id: I099808fd13bf9ed9a564b122f1126b1691a83291
diff --git a/cmds/incidentd/src/Section.h b/cmds/incidentd/src/Section.h
index 35740e9..93b4848 100644
--- a/cmds/incidentd/src/Section.h
+++ b/cmds/incidentd/src/Section.h
@@ -19,22 +19,26 @@
#include "FdBuffer.h"
+#include <stdarg.h>
#include <utils/String8.h>
#include <utils/String16.h>
#include <utils/Vector.h>
using namespace android;
+const int64_t REMOTE_CALL_TIMEOUT_MS = 10 * 1000; // 10 seconds
+
/**
* Base class for sections
*/
class Section
{
public:
- int id;
+ const int id;
+ const int64_t timeoutMs; // each section must have a timeout
String8 name;
- Section(int id);
+ Section(int id, const int64_t timeoutMs = REMOTE_CALL_TIMEOUT_MS);
virtual ~Section();
virtual status_t Execute(ReportRequestSet* requests) const = 0;
@@ -48,7 +52,7 @@
class FileSection : public Section
{
public:
- FileSection(int id, const char* filename);
+ FileSection(int id, const char* filename, const int64_t timeoutMs = 5000 /* 5 seconds */);
virtual ~FileSection();
virtual status_t Execute(ReportRequestSet* requests) const;
@@ -77,13 +81,18 @@
class CommandSection : public Section
{
public:
- CommandSection(int id, const char* first, ...);
+ CommandSection(int id, const int64_t timeoutMs, const char* command, ...);
+
+ CommandSection(int id, const char* command, ...);
+
virtual ~CommandSection();
virtual status_t Execute(ReportRequestSet* requests) const;
private:
const char** mCommand;
+
+ void init(const char* command, va_list args);
};
/**