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
This commit is contained in:
Jin Qian 2017-02-10 17:23:16 -08:00
parent 1275b1b6aa
commit dd41d6b171
4 changed files with 6 additions and 6 deletions

View File

@ -302,7 +302,7 @@ public:
return mUidm.get_uid_io_stats();
}
std::map<uint64_t, std::vector<struct uid_record>> get_uid_records(
int hours, uint64_t threshold, bool force_report) {
double hours, uint64_t threshold, bool force_report) {
return mUidm.dump(hours, threshold, force_report);
}
void update_uid_io_interval(int interval) {

View File

@ -92,7 +92,7 @@ public:
std::unordered_map<uint32_t, struct uid_info> get_uid_io_stats();
// called by dumpsys
std::map<uint64_t, std::vector<struct uid_record>> dump(
int hours, uint64_t threshold, bool force_report);
double hours, uint64_t threshold, bool force_report);
// called by battery properties listener
void set_charger_state(charger_stat_t stat);
// called by storaged periodic_chore or dump with force_report

View File

@ -88,7 +88,7 @@ status_t Storaged::dump(int fd, const Vector<String16>& args) {
return PERMISSION_DENIED;
}
int hours = 0;
double hours = 0;
int time_window = 0;
uint64_t threshold = 0;
bool force_report = false;
@ -97,7 +97,7 @@ status_t Storaged::dump(int fd, const Vector<String16>& args) {
if (arg == String16("--hours")) {
if (++i >= args.size())
break;
hours = stoi(String16::std_string(args[i]));
hours = stod(String16::std_string(args[i]));
continue;
}
if (arg == String16("--time_window")) {

View File

@ -150,7 +150,7 @@ void uid_monitor::add_records_locked(uint64_t curr_ts)
}
std::map<uint64_t, std::vector<struct uid_record>> uid_monitor::dump(
int hours, uint64_t threshold, bool force_report)
double hours, uint64_t threshold, bool force_report)
{
if (force_report) {
report();
@ -162,7 +162,7 @@ std::map<uint64_t, std::vector<struct uid_record>> uid_monitor::dump(
uint64_t first_ts = 0;
if (hours != 0) {
first_ts = time(NULL) - (uint64_t)hours * HOUR_TO_SEC;
first_ts = time(NULL) - hours * HOUR_TO_SEC;
}
for (auto it = records.lower_bound(first_ts); it != records.end(); ++it) {