Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b53a1c9b authored by Naveen Kalla's avatar Naveen Kalla
Browse files

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
parent ba56f5ea
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -97,6 +97,8 @@ status_t DumpstateService::dump(int fd, const Vector<String16>&) {
    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;
}
+26 −0
Original line number Diff line number Diff line
@@ -116,6 +116,8 @@ static const std::string kDumpstateBoardPath = "/bugreports/dumpstate_board.txt"
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 @@ int main(int argc, char *argv[]) {
        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 @@ int main(int argc, char *argv[]) {
                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");
+4 −0
Original line number Diff line number Diff line
@@ -333,6 +333,10 @@ class Dumpstate {
    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);