Provide Recent Disk Perf via IStoraged

Expose recent disk write performance to Java side services.

Bug: 62393328
Test: manual
Change-Id: I6002681b17e7f5b9538b4dc9e312843cf838e467
This commit is contained in:
Michael Wachenschwanz 2017-12-14 18:20:26 -08:00
parent baca81639c
commit 37b912b805
6 changed files with 22 additions and 0 deletions

View file

@ -20,4 +20,5 @@ package android.os;
interface IStoraged {
void onUserStarted(int userId);
void onUserStopped(int userId);
int getRecentPerf();
}

View file

@ -116,6 +116,8 @@ public:
return storage_info->get_perf_history();
}
uint32_t get_recent_perf(void) { return storage_info->get_recent_perf(); }
map<uint64_t, struct uid_records> get_uid_records(
double hours, uint64_t threshold, bool force_report) {
return mUidm.dump(hours, threshold, force_report);

View file

@ -75,6 +75,7 @@ public:
void update_perf_history(uint32_t bw,
const time_point<system_clock>& tp);
vector<int> get_perf_history();
uint32_t get_recent_perf();
};
class emmc_info_t : public storage_info_t {

View file

@ -39,6 +39,7 @@ public:
binder::Status onUserStarted(int32_t userId);
binder::Status onUserStopped(int32_t userId);
binder::Status getRecentPerf(int32_t* _aidl_return);
};
class StoragedPrivateService : public BinderService<StoragedPrivateService>, public BnStoragedPrivate {

View file

@ -213,6 +213,13 @@ vector<int> storage_info_t::get_perf_history()
return ret;
}
uint32_t storage_info_t::get_recent_perf() {
Mutex::Autolock _l(si_mutex);
if (recent_perf.size() == 0) return 0;
return accumulate(recent_perf.begin(), recent_perf.end(), recent_perf.size() / 2) /
recent_perf.size();
}
void emmc_info_t::report()
{
if (!report_sysfs() && !report_debugfs())

View file

@ -174,6 +174,16 @@ binder::Status StoragedService::onUserStopped(int32_t userId) {
return binder::Status::ok();
}
binder::Status StoragedService::getRecentPerf(int32_t* _aidl_return) {
uint32_t recent_perf = storaged_sp->get_recent_perf();
if (recent_perf > INT32_MAX) {
*_aidl_return = INT32_MAX;
} else {
*_aidl_return = static_cast<int32_t>(recent_perf);
}
return binder::Status::ok();
}
status_t StoragedPrivateService::start() {
return BinderService<StoragedPrivateService>::publish();
}