Hold a wakelock during dumpstate.
am: d7803db0e9
Change-Id: I134c8cc5a656bc2d24e58d2dd8a4d200784e1049
diff --git a/cmds/dumpstate/Android.mk b/cmds/dumpstate/Android.mk
index 0433f31..e478651 100644
--- a/cmds/dumpstate/Android.mk
+++ b/cmds/dumpstate/Android.mk
@@ -10,7 +10,7 @@
LOCAL_MODULE := dumpstate
-LOCAL_SHARED_LIBRARIES := libcutils liblog libselinux libbase
+LOCAL_SHARED_LIBRARIES := libcutils liblog libselinux libbase libhardware_legacy
# ZipArchive support, the order matters here to get all symbols.
LOCAL_STATIC_LIBRARIES := libziparchive libz libcrypto_static
LOCAL_HAL_STATIC_LIBRARIES := libdumpstate
diff --git a/cmds/dumpstate/dumpstate.cpp b/cmds/dumpstate/dumpstate.cpp
index 65ba576..1aad6ae 100644
--- a/cmds/dumpstate/dumpstate.cpp
+++ b/cmds/dumpstate/dumpstate.cpp
@@ -38,6 +38,7 @@
#include <android-base/unique_fd.h>
#include <android-base/file.h>
#include <cutils/properties.h>
+#include <hardware_legacy/power.h>
#include "private/android_filesystem_config.h"
@@ -82,6 +83,7 @@
#define TOMBSTONE_MAX_LEN (sizeof(TOMBSTONE_FILE_PREFIX) + 4)
#define NUM_TOMBSTONES 10
#define WLUTIL "/vendor/xbin/wlutil"
+#define WAKE_LOCK_NAME "dumpstate_wakelock"
typedef struct {
char name[TOMBSTONE_MAX_LEN];
@@ -1202,6 +1204,10 @@
return std::string(hash_buffer);
}
+static void wake_lock_releaser() {
+ release_wake_lock(WAKE_LOCK_NAME);
+}
+
int main(int argc, char *argv[]) {
struct sigaction sigact;
int do_add_date = 0;
@@ -1220,6 +1226,9 @@
MYLOGI("begin\n");
+ acquire_wake_lock(PARTIAL_WAKE_LOCK, WAKE_LOCK_NAME);
+ atexit(wake_lock_releaser);
+
/* gets the sequential id */
char last_id[PROPERTY_VALUE_MAX];
property_get("dumpstate.last_id", last_id, "0");