summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Sahana Rao <sahanas@google.com> 2019-07-22 16:49:34 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2019-07-22 16:49:34 +0000
commit8536c373fcf68333b8c2d1efa85001b90aa6892c (patch)
tree117dea3956eb84e30d20efa117f7528c53efb54c
parentb1bcbb51454f59e15cfd1aaa628e7b20dbb2535f (diff)
parentf35ed4393db016b19d3d254840200722afa4a0cb (diff)
Merge "Hold a wake lock when taking bug report"
-rw-r--r--cmds/dumpstate/Android.bp1
-rw-r--r--cmds/dumpstate/DumpstateInternal.cpp8
-rw-r--r--cmds/dumpstate/dumpstate.cpp10
3 files changed, 18 insertions, 1 deletions
diff --git a/cmds/dumpstate/Android.bp b/cmds/dumpstate/Android.bp
index bdd03f96a2..8d383f501a 100644
--- a/cmds/dumpstate/Android.bp
+++ b/cmds/dumpstate/Android.bp
@@ -86,6 +86,7 @@ cc_defaults {
"libdumpstateaidl",
"libdumpstateutil",
"libdumputils",
+ "libhardware_legacy",
"libhidlbase",
"libhidltransport",
"liblog",
diff --git a/cmds/dumpstate/DumpstateInternal.cpp b/cmds/dumpstate/DumpstateInternal.cpp
index 33e35f7274..bbc724c4c0 100644
--- a/cmds/dumpstate/DumpstateInternal.cpp
+++ b/cmds/dumpstate/DumpstateInternal.cpp
@@ -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));
diff --git a/cmds/dumpstate/dumpstate.cpp b/cmds/dumpstate/dumpstate.cpp
index 72f64eae1f..ae08f95cbb 100644
--- a/cmds/dumpstate/dumpstate.cpp
+++ b/cmds/dumpstate/dumpstate.cpp
@@ -68,6 +68,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>
@@ -174,6 +175,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 {
@@ -2431,6 +2434,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?