summaryrefslogtreecommitdiff
path: root/cmds/incident
diff options
context:
space:
mode:
Diffstat (limited to 'cmds/incident')
-rw-r--r--cmds/incident/Android.bp2
-rw-r--r--cmds/incident/main.cpp23
2 files changed, 23 insertions, 2 deletions
diff --git a/cmds/incident/Android.bp b/cmds/incident/Android.bp
index f56f101465eb..9e9dac14c802 100644
--- a/cmds/incident/Android.bp
+++ b/cmds/incident/Android.bp
@@ -30,7 +30,7 @@ cc_binary {
],
static_libs: [
- "libplatformprotos",
+ "libprotoutil",
],
cflags: [
diff --git a/cmds/incident/main.cpp b/cmds/incident/main.cpp
index eca781fd4e4f..13e707bc341d 100644
--- a/cmds/incident/main.cpp
+++ b/cmds/incident/main.cpp
@@ -21,6 +21,7 @@
#include <android/os/BnIncidentReportStatusListener.h>
#include <android/os/IIncidentManager.h>
#include <android/os/IncidentReportArgs.h>
+#include <android/util/ProtoOutputStream.h>
#include <binder/IPCThreadState.h>
#include <binder/IServiceManager.h>
#include <utils/Looper.h>
@@ -36,6 +37,9 @@ using namespace android;
using namespace android::base;
using namespace android::binder;
using namespace android::os;
+using android::util::FIELD_COUNT_SINGLE;
+using android::util::FIELD_TYPE_STRING;
+using android::util::ProtoOutputStream;
// ================================================================================
class StatusListener : public BnIncidentReportStatusListener {
@@ -208,6 +212,7 @@ usage(FILE* out)
fprintf(out, "and one of these destinations:\n");
fprintf(out, " -b (default) print the report to stdout (in proto format)\n");
fprintf(out, " -d send the report into dropbox\n");
+ fprintf(out, " -r REASON human readable description of why the report is taken.\n");
fprintf(out, " -s PKG/CLS send broadcast to the broadcast receiver.\n");
fprintf(out, "\n");
fprintf(out, " SECTION the field numbers of the incident report fields to include\n");
@@ -221,11 +226,12 @@ main(int argc, char** argv)
IncidentReportArgs args;
enum { DEST_UNSET, DEST_DROPBOX, DEST_STDOUT, DEST_BROADCAST } destination = DEST_UNSET;
int privacyPolicy = PRIVACY_POLICY_AUTOMATIC;
+ string reason;
string receiverArg;
// Parse the args
int opt;
- while ((opt = getopt(argc, argv, "bhdlp:s:")) != -1) {
+ while ((opt = getopt(argc, argv, "bhdlp:r:s:")) != -1) {
switch (opt) {
case 'h':
usage(stdout);
@@ -250,6 +256,13 @@ main(int argc, char** argv)
case 'p':
privacyPolicy = get_privacy_policy(optarg);
break;
+ case 'r':
+ if (reason.size() > 0) {
+ usage(stderr);
+ return 1;
+ }
+ reason = optarg;
+ break;
case 's':
if (destination != DEST_UNSET) {
usage(stderr);
@@ -301,6 +314,14 @@ main(int argc, char** argv)
}
args.setPrivacyPolicy(privacyPolicy);
+ if (reason.size() > 0) {
+ ProtoOutputStream proto;
+ proto.write(/* reason field id */ 2 | FIELD_TYPE_STRING | FIELD_COUNT_SINGLE, reason);
+ vector<uint8_t> header;
+ proto.serializeToVector(&header);
+ args.addHeader(header);
+ }
+
// Start the thread pool.
sp<ProcessState> ps(ProcessState::self());
ps->startThreadPool();