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

Commit 2788b5ea authored by Sahana Rao's avatar Sahana Rao Committed by android-build-merger
Browse files

Merge "Hold a wake lock when taking bug report" am: 8536c373

am: 8f660f5f

Change-Id: I35f04bc8e5b78c1f06b67745fdb5a4bfdfdaeee6
parents b852fc5c 8f660f5f
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -86,6 +86,7 @@ cc_defaults {
        "libdumpstateaidl",
        "libdumpstateutil",
        "libdumputils",
        "libhardware_legacy",
        "libhidlbase",
        "libhidltransport",
        "liblog",
+7 −1
Original line number Diff line number Diff line
@@ -68,7 +68,8 @@ bool DropRootUser() {
    }

    static const std::vector<std::string> group_names{
        "log", "sdcard_r", "sdcard_rw", "mount", "inet", "net_bw_stats", "readproc", "bluetooth"};
        "log", "sdcard_r", "sdcard_rw", "mount", "inet", "net_bw_stats",
            "readproc", "bluetooth", "wakelock"};
    std::vector<gid_t> groups(group_names.size(), 0);
    for (size_t i = 0; i < group_names.size(); ++i) {
        grp = getgrnam(group_names[i].c_str());
@@ -116,6 +117,11 @@ bool DropRootUser() {
        capdata[cap_syslog_index].effective |= cap_syslog_mask;
    }

    const uint32_t cap_block_suspend_mask = CAP_TO_MASK(CAP_BLOCK_SUSPEND);
    const uint32_t cap_block_suspend_index = CAP_TO_INDEX(CAP_BLOCK_SUSPEND);
    capdata[cap_block_suspend_index].permitted |= cap_block_suspend_mask;
    capdata[cap_block_suspend_index].effective |= cap_block_suspend_mask;

    if (capset(&capheader, &capdata[0]) != 0) {
        MYLOGE("capset({%#x, %#x}) failed: %s\n", capdata[0].effective,
               capdata[1].effective, strerror(errno));
+10 −0
Original line number Diff line number Diff line
@@ -71,6 +71,7 @@
#include <debuggerd/client.h>
#include <dumpsys.h>
#include <dumputils/dump_utils.h>
#include <hardware_legacy/power.h>
#include <hidl/ServiceManagement.h>
#include <log/log.h>
#include <openssl/sha.h>
@@ -177,6 +178,8 @@ static const std::string ANR_FILE_PREFIX = "anr_";
    func_ptr(__VA_ARGS__);                                  \
    RETURN_IF_USER_DENIED_CONSENT();

static const char* WAKE_LOCK_NAME = "dumpstate_wakelock";

namespace android {
namespace os {
namespace {
@@ -2468,6 +2471,13 @@ Dumpstate::RunStatus Dumpstate::RunInternal(int32_t calling_uid,

    MYLOGI("begin\n");

    if (acquire_wake_lock(PARTIAL_WAKE_LOCK, WAKE_LOCK_NAME) < 0) {
        MYLOGE("Failed to acquire wake lock: %s\n", strerror(errno));
    } else {
        // Wake lock will be released automatically on process death
        MYLOGD("Wake lock acquired.\n");
    }

    register_sig_handler();

    // TODO(b/111441001): maybe skip if already started?