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

Commit 84bb59bc authored by Kevin Jeon's avatar Kevin Jeon Committed by Automerger Merge Worker
Browse files

Merge "Add sysprop for identifying strict-run bugreports" into main am:...

Merge "Add sysprop for identifying strict-run bugreports" into main am: e0f7ccc6 am: 14fb28fb am: b4aa7dae am: 2cf4cd34

Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/2679475



Change-Id: Iede5b5d7eba0b3e11999e907638832aaa0cd93b0
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 41f47a35 2cf4cd34
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -207,6 +207,7 @@ std::string PropertiesHelper::build_type_ = "";
int PropertiesHelper::dry_run_ = -1;
int PropertiesHelper::unroot_ = -1;
int PropertiesHelper::parallel_run_ = -1;
int PropertiesHelper::strict_run_ = -1;

bool PropertiesHelper::IsUserBuild() {
    if (build_type_.empty()) {
@@ -237,6 +238,14 @@ bool PropertiesHelper::IsParallelRun() {
    return parallel_run_ == 1;
}

bool PropertiesHelper::IsStrictRun() {
    if (strict_run_ == -1) {
        // Defaults to using stricter timeouts.
        strict_run_ = android::base::GetBoolProperty("dumpstate.strict_run", true) ? 1 : 0;
    }
    return strict_run_ == 1;
}

int DumpFileToFd(int out_fd, const std::string& title, const std::string& path) {
    android::base::unique_fd fd(TEMP_FAILURE_RETRY(open(path.c_str(), O_RDONLY | O_NONBLOCK | O_CLOEXEC)));
    if (fd.get() < 0) {
+8 −0
Original line number Diff line number Diff line
@@ -193,11 +193,19 @@ class PropertiesHelper {
     */
    static bool IsParallelRun();

    /*
     * Strict-run mode is determined by the `dumpstate.strict_run` sysprop which
     * will default to true. This results in shortened timeouts for flaky
     * sections.
     */
    static bool IsStrictRun();

  private:
    static std::string build_type_;
    static int dry_run_;
    static int unroot_;
    static int parallel_run_;
    static int strict_run_;
};

/*
+14 −4
Original line number Diff line number Diff line
@@ -822,9 +822,12 @@ void Dumpstate::PrintHeader() const {
    RunCommandToFd(STDOUT_FILENO, "", {"uptime", "-p"},
                   CommandOptions::WithTimeout(1).Always().Build());
    printf("Bugreport format version: %s\n", version_.c_str());
    printf("Dumpstate info: id=%d pid=%d dry_run=%d parallel_run=%d args=%s bugreport_mode=%s\n",
    printf(
        "Dumpstate info: id=%d pid=%d dry_run=%d parallel_run=%d strict_run=%d args=%s "
        "bugreport_mode=%s\n",
        id_, pid_, PropertiesHelper::IsDryRun(), PropertiesHelper::IsParallelRun(),
           options_->args.c_str(), options_->bugreport_mode_string.c_str());
        PropertiesHelper::IsStrictRun(), options_->args.c_str(),
        options_->bugreport_mode_string.c_str());
    printf("\n");
}

@@ -1046,7 +1049,8 @@ static void DumpIncidentReport() {
        MYLOGE("Could not open %s to dump incident report.\n", path.c_str());
        return;
    }
    RunCommandToFd(fd, "", {"incident", "-u"}, CommandOptions::WithTimeout(20).Build());
    RunCommandToFd(fd, "", {"incident", "-u"},
                   CommandOptions::WithTimeout(PropertiesHelper::IsStrictRun() ? 20 : 120).Build());
    bool empty = 0 == lseek(fd, 0, SEEK_END);
    if (!empty) {
        // Use a different name from "incident.proto"
@@ -3141,6 +3145,12 @@ Dumpstate::RunStatus Dumpstate::RunInternal(int32_t calling_uid,
        MYLOGI("Running on dry-run mode (to disable it, call 'setprop dumpstate.dry_run false')\n");
    }

    if (PropertiesHelper::IsStrictRun()) {
        MYLOGI(
            "Running on strict-run mode, which has shorter timeouts "
            "(to disable, call 'setprop dumpstate.strict_run false')\n");
    }

    MYLOGI("dumpstate info: id=%d, args='%s', bugreport_mode= %s bugreport format version: %s\n",
           id_, options_->args.c_str(), options_->bugreport_mode_string.c_str(), version_.c_str());