Support dumpsys timeouts in milliseconds
- add new dumpsys argument to specify timeouts in milliseconds
- use milliseconds to define timeouts in dumpstate
- minor dumpsys output format changes:
"SERVICE '<service_name>' DUMP TIMEOUT (1s) EXPIRED" ->
"SERVICE '<service_name>' DUMP TIMEOUT (1000ms) EXPIRED"
Bug: 27429130
Test: mmm -j32 frameworks/native/cmds/dumpsys && \
mmm -j32 frameworks/native/cmds/dumpstate && \
adb sync data && adb shell /data/nativetest/dumpsys_test/dumpsys_test && \
adb shell /data/nativetest64/dumpsys_test/dumpsys_test && \
adb shell /data/nativetest/dumpstate_test/dumpstate_test && \
adb shell /data/nativetest64/dumpstate_test/dumpstate_test && \
printf "\n\n#### ALL TESTS PASSED ####\n"
Change-Id: Ibc96ad030bb2c6d880b8201c9b6241fce20b284f
Change-Id: I6ef2ff19787f2b6d940d56e453a1a7462a8c854a
diff --git a/cmds/dumpstate/DumpstateUtil.h b/cmds/dumpstate/DumpstateUtil.h
index 698ceff..8342099 100644
--- a/cmds/dumpstate/DumpstateUtil.h
+++ b/cmds/dumpstate/DumpstateUtil.h
@@ -19,6 +19,16 @@
#include <cstdint>
#include <string>
+/*
+ * Converts seconds to milliseconds.
+ */
+#define SEC_TO_MSEC(second) (second * 1000)
+
+/*
+ * Converts milliseconds to seconds.
+ */
+#define MSEC_TO_SEC(millisecond) (millisecond / 1000)
+
namespace android {
namespace os {
namespace dumpstate {
@@ -66,9 +76,9 @@
private:
class CommandOptionsValues {
private:
- CommandOptionsValues(int64_t timeout);
+ CommandOptionsValues(int64_t timeout_ms);
- int64_t timeout_;
+ int64_t timeout_ms_;
bool always_;
PrivilegeMode account_mode_;
OutputMode output_mode_;
@@ -102,13 +112,15 @@
CommandOptions Build();
private:
- CommandOptionsBuilder(int64_t timeout);
+ CommandOptionsBuilder(int64_t timeout_ms);
CommandOptionsValues values;
friend class CommandOptions;
};
- /** Gets the command timeout, in seconds. */
+ /** Gets the command timeout in seconds. */
int64_t Timeout() const;
+ /** Gets the command timeout in milliseconds. */
+ int64_t TimeoutInMs() const;
/* Checks whether the command should always be run, even on dry-run mode. */
bool Always() const;
/** Gets the PrivilegeMode of the command. */
@@ -118,8 +130,11 @@
/** Gets the logging message header, it any. */
std::string LoggingMessage() const;
- /** Creates a builder with the requied timeout. */
- static CommandOptionsBuilder WithTimeout(int64_t timeout);
+ /** Creates a builder with the requied timeout in seconds. */
+ static CommandOptionsBuilder WithTimeout(int64_t timeout_sec);
+
+ /** Creates a builder with the requied timeout in milliseconds. */
+ static CommandOptionsBuilder WithTimeoutInMs(int64_t timeout_ms);
// Common options.
static CommandOptions DEFAULT;