Add notification_title and notification_description to dumpstate
Initiator of dumpstate can set dumpstate.options.title and
dumpstate.options.description properties to notify dumpstate the details
that will be used to file a bug. dumpstate will send this information
along with the BUGREPORT_FINISHED intent.
Bug: 33561517
Test: Use the new API to invoke bugreport from TelephonyMonitor and
ensure that the bugreport is taken and title and description are
updated properly in the notification. Run dumpstate and
BugreportReceiver unit tests
Change-Id: Ia23a3ef4d5751be14f347ac38ef7c8a18f79799d
diff --git a/cmds/dumpstate/DumpstateService.cpp b/cmds/dumpstate/DumpstateService.cpp
index 5430956..efe0466 100644
--- a/cmds/dumpstate/DumpstateService.cpp
+++ b/cmds/dumpstate/DumpstateService.cpp
@@ -97,6 +97,8 @@
dprintf(fd, "now: %ld\n", ds_.now_);
dprintf(fd, "is_zipping: %s\n", ds_.IsZipping() ? "true" : "false");
dprintf(fd, "listener: %s\n", ds_.listener_name_.c_str());
+ dprintf(fd, "notification title: %s\n", ds_.notification_title.c_str());
+ dprintf(fd, "notification description: %s\n", ds_.notification_description.c_str());
return NO_ERROR;
}
diff --git a/cmds/dumpstate/dumpstate.cpp b/cmds/dumpstate/dumpstate.cpp
index 4812de5..f898b90 100644
--- a/cmds/dumpstate/dumpstate.cpp
+++ b/cmds/dumpstate/dumpstate.cpp
@@ -116,6 +116,8 @@
static constexpr char PROPERTY_EXTRA_OPTIONS[] = "dumpstate.options";
static constexpr char PROPERTY_LAST_ID[] = "dumpstate.last_id";
static constexpr char PROPERTY_VERSION[] = "dumpstate.version";
+static constexpr char PROPERTY_EXTRA_TITLE[] = "dumpstate.options.title";
+static constexpr char PROPERTY_EXTRA_DESCRIPTION[] = "dumpstate.options.description";
static const CommandOptions AS_ROOT_20 = CommandOptions::WithTimeout(20).AsRoot().Build();
@@ -1437,6 +1439,20 @@
android::base::SetProperty(PROPERTY_EXTRA_OPTIONS, "");
}
+ ds.notification_title = android::base::GetProperty(PROPERTY_EXTRA_TITLE, "");
+ if (!ds.notification_title.empty()) {
+ // Reset the property
+ android::base::SetProperty(PROPERTY_EXTRA_TITLE, "");
+
+ ds.notification_description = android::base::GetProperty(PROPERTY_EXTRA_DESCRIPTION, "");
+ if (!ds.notification_description.empty()) {
+ // Reset the property
+ android::base::SetProperty(PROPERTY_EXTRA_DESCRIPTION, "");
+ }
+ MYLOGD("notification (title: %s, description: %s)\n",
+ ds.notification_title.c_str(), ds.notification_description.c_str());
+ }
+
if ((do_zip_file || do_add_date || ds.update_progress_ || do_broadcast) && !use_outfile) {
ExitOnInvalidArgs();
}
@@ -1799,6 +1815,16 @@
am_args.push_back("android.intent.extra.SCREENSHOT");
am_args.push_back(ds.screenshot_path_);
}
+ if (!ds.notification_title.empty()) {
+ am_args.push_back("--es");
+ am_args.push_back("android.intent.extra.TITLE");
+ am_args.push_back(ds.notification_title);
+ if (!ds.notification_description.empty()) {
+ am_args.push_back("--es");
+ am_args.push_back("android.intent.extra.DESCRIPTION");
+ am_args.push_back(ds.notification_description);
+ }
+ }
if (is_remote_mode) {
am_args.push_back("--es");
am_args.push_back("android.intent.extra.REMOTE_BUGREPORT_HASH");
diff --git a/cmds/dumpstate/dumpstate.h b/cmds/dumpstate/dumpstate.h
index 7fcb980..f02303b 100644
--- a/cmds/dumpstate/dumpstate.h
+++ b/cmds/dumpstate/dumpstate.h
@@ -333,6 +333,10 @@
android::sp<android::os::IDumpstateListener> listener_;
std::string listener_name_;
+ // Notification title and description
+ std::string notification_title;
+ std::string notification_description;
+
private:
// Used by GetInstance() only.
Dumpstate(const std::string& version = VERSION_CURRENT);