Hold a wake lock when taking bug report
Bug: 128012377
Test: Turn the screen off after initiating bugreport,
Bugreport takes 2-5 minutes now, same takes around 30-40 minutes
without wake lock.
Test: Added debug messages in SystemSuspend logs to confirm
wake lock cleanup on dumpstate crash/exit.
Change-Id: Idbd2466e1d67e0157657f587cf951e9bc4a1ea05
diff --git a/cmds/dumpstate/dumpstate.cpp b/cmds/dumpstate/dumpstate.cpp
index 1fc8107..483cb9e 100644
--- a/cmds/dumpstate/dumpstate.cpp
+++ b/cmds/dumpstate/dumpstate.cpp
@@ -58,6 +58,7 @@
#include <debuggerd/client.h>
#include <dumpsys.h>
#include <dumputils/dump_utils.h>
+#include <hardware_legacy/power.h>
#include <hidl/ServiceManagement.h>
#include <openssl/sha.h>
#include <private/android_filesystem_config.h>
@@ -144,6 +145,8 @@
func_ptr(__VA_ARGS__); \
RETURN_IF_USER_DENIED_CONSENT();
+static const char* WAKE_LOCK_NAME = "dumpstate_wakelock";
+
namespace android {
namespace os {
namespace {
@@ -2405,6 +2408,13 @@
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?