summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJin Qian2017-02-10 19:23:16 -0600
committerJin Qian2017-02-10 19:25:34 -0600
commitdd41d6b17115f5592f184b17351383c1b06d6336 (patch)
tree8862d05133b32b933d5f4bbffa9ab98f4600074f /storaged
parent1275b1b6aaf417243ff3be17a400a21e26c42f39 (diff)
downloadplatform-system-core-dd41d6b17115f5592f184b17351383c1b06d6336.tar.gz
platform-system-core-dd41d6b17115f5592f184b17351383c1b06d6336.tar.xz
platform-system-core-dd41d6b17115f5592f184b17351383c1b06d6336.zip
storaged: allow dump window to be less than an hour
This is useful for CTS where we just need dump from last few minutes. Bug: 34198239 Bug: 34845096 Change-Id: Ic543e7184606f419f8989bf0cb992cd46e48845c
Diffstat (limited to 'storaged')
-rw-r--r--storaged/include/storaged.h2
-rw-r--r--storaged/include/storaged_uid_monitor.h2
-rw-r--r--storaged/storaged_service.cpp4
-rw-r--r--storaged/storaged_uid_monitor.cpp4
4 files changed, 6 insertions, 6 deletions
diff --git a/storaged/include/storaged.h b/storaged/include/storaged.h
index 0bdff7483..591719e74 100644
--- a/storaged/include/storaged.h
+++ b/storaged/include/storaged.h
@@ -302,7 +302,7 @@ public:
302 return mUidm.get_uid_io_stats(); 302 return mUidm.get_uid_io_stats();
303 } 303 }
304 std::map<uint64_t, std::vector<struct uid_record>> get_uid_records( 304 std::map<uint64_t, std::vector<struct uid_record>> get_uid_records(
305 int hours, uint64_t threshold, bool force_report) { 305 double hours, uint64_t threshold, bool force_report) {
306 return mUidm.dump(hours, threshold, force_report); 306 return mUidm.dump(hours, threshold, force_report);
307 } 307 }
308 void update_uid_io_interval(int interval) { 308 void update_uid_io_interval(int interval) {
diff --git a/storaged/include/storaged_uid_monitor.h b/storaged/include/storaged_uid_monitor.h
index f6250ae7b..031b7c4ee 100644
--- a/storaged/include/storaged_uid_monitor.h
+++ b/storaged/include/storaged_uid_monitor.h
@@ -92,7 +92,7 @@ public:
92 std::unordered_map<uint32_t, struct uid_info> get_uid_io_stats(); 92 std::unordered_map<uint32_t, struct uid_info> get_uid_io_stats();
93 // called by dumpsys 93 // called by dumpsys
94 std::map<uint64_t, std::vector<struct uid_record>> dump( 94 std::map<uint64_t, std::vector<struct uid_record>> dump(
95 int hours, uint64_t threshold, bool force_report); 95 double hours, uint64_t threshold, bool force_report);
96 // called by battery properties listener 96 // called by battery properties listener
97 void set_charger_state(charger_stat_t stat); 97 void set_charger_state(charger_stat_t stat);
98 // called by storaged periodic_chore or dump with force_report 98 // called by storaged periodic_chore or dump with force_report
diff --git a/storaged/storaged_service.cpp b/storaged/storaged_service.cpp
index 8624b3b6b..9c8cbf0e8 100644
--- a/storaged/storaged_service.cpp
+++ b/storaged/storaged_service.cpp
@@ -88,7 +88,7 @@ status_t Storaged::dump(int fd, const Vector<String16>& args) {
88 return PERMISSION_DENIED; 88 return PERMISSION_DENIED;
89 } 89 }
90 90
91 int hours = 0; 91 double hours = 0;
92 int time_window = 0; 92 int time_window = 0;
93 uint64_t threshold = 0; 93 uint64_t threshold = 0;
94 bool force_report = false; 94 bool force_report = false;
@@ -97,7 +97,7 @@ status_t Storaged::dump(int fd, const Vector<String16>& args) {
97 if (arg == String16("--hours")) { 97 if (arg == String16("--hours")) {
98 if (++i >= args.size()) 98 if (++i >= args.size())
99 break; 99 break;
100 hours = stoi(String16::std_string(args[i])); 100 hours = stod(String16::std_string(args[i]));
101 continue; 101 continue;
102 } 102 }
103 if (arg == String16("--time_window")) { 103 if (arg == String16("--time_window")) {
diff --git a/storaged/storaged_uid_monitor.cpp b/storaged/storaged_uid_monitor.cpp
index 2c20dba1d..3b893b506 100644
--- a/storaged/storaged_uid_monitor.cpp
+++ b/storaged/storaged_uid_monitor.cpp
@@ -150,7 +150,7 @@ void uid_monitor::add_records_locked(uint64_t curr_ts)
150} 150}
151 151
152std::map<uint64_t, std::vector<struct uid_record>> uid_monitor::dump( 152std::map<uint64_t, std::vector<struct uid_record>> uid_monitor::dump(
153 int hours, uint64_t threshold, bool force_report) 153 double hours, uint64_t threshold, bool force_report)
154{ 154{
155 if (force_report) { 155 if (force_report) {
156 report(); 156 report();
@@ -162,7 +162,7 @@ std::map<uint64_t, std::vector<struct uid_record>> uid_monitor::dump(
162 uint64_t first_ts = 0; 162 uint64_t first_ts = 0;
163 163
164 if (hours != 0) { 164 if (hours != 0) {
165 first_ts = time(NULL) - (uint64_t)hours * HOUR_TO_SEC; 165 first_ts = time(NULL) - hours * HOUR_TO_SEC;
166 } 166 }
167 167
168 for (auto it = records.lower_bound(first_ts); it != records.end(); ++it) { 168 for (auto it = records.lower_bound(first_ts); it != records.end(); ++it) {