summaryrefslogtreecommitdiff
path: root/storaged
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2018-01-18 02:50:48 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2018-01-18 02:50:48 +0000
commit7b94ae273b78ec038d66967b531c922c4a614bc6 (patch)
tree4ee7bb0ce33d4d067fe29fe333987254f8107916 /storaged
parentc4ef39ad5e543043ef45db5dadbe08f32520bb29 (diff)
parent37b912b8055468c4ab17300165d355fb0a13cff6 (diff)
downloadcore-7b94ae273b78ec038d66967b531c922c4a614bc6.tar.gz
Merge "Provide Recent Disk Perf via IStoraged"
Diffstat (limited to 'storaged')
-rw-r--r--storaged/binder/android/os/IStoraged.aidl1
-rw-r--r--storaged/include/storaged.h2
-rw-r--r--storaged/include/storaged_info.h1
-rw-r--r--storaged/include/storaged_service.h1
-rw-r--r--storaged/storaged_info.cpp7
-rw-r--r--storaged/storaged_service.cpp10
6 files changed, 22 insertions, 0 deletions
diff --git a/storaged/binder/android/os/IStoraged.aidl b/storaged/binder/android/os/IStoraged.aidl
index f81e90403..0bcc70c36 100644
--- a/storaged/binder/android/os/IStoraged.aidl
+++ b/storaged/binder/android/os/IStoraged.aidl
@@ -20,4 +20,5 @@ package android.os;
interface IStoraged {
void onUserStarted(int userId);
void onUserStopped(int userId);
+ int getRecentPerf();
} \ No newline at end of file
diff --git a/storaged/include/storaged.h b/storaged/include/storaged.h
index c5cac27e4..7b27988b4 100644
--- a/storaged/include/storaged.h
+++ b/storaged/include/storaged.h
@@ -119,6 +119,8 @@ class storaged_t : public android::hardware::health::V2_0::IHealthInfoCallback,
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);
diff --git a/storaged/include/storaged_info.h b/storaged/include/storaged_info.h
index 3a6a0d48c..88a53deb2 100644
--- a/storaged/include/storaged_info.h
+++ b/storaged/include/storaged_info.h
@@ -78,6 +78,7 @@ class storage_info_t {
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 {
diff --git a/storaged/include/storaged_service.h b/storaged/include/storaged_service.h
index 05c3b9469..7ec686415 100644
--- a/storaged/include/storaged_service.h
+++ b/storaged/include/storaged_service.h
@@ -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 {
diff --git a/storaged/storaged_info.cpp b/storaged/storaged_info.cpp
index b6dd16462..055f3751f 100644
--- a/storaged/storaged_info.cpp
+++ b/storaged/storaged_info.cpp
@@ -219,6 +219,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())
diff --git a/storaged/storaged_service.cpp b/storaged/storaged_service.cpp
index 3c790e687..17ea25b82 100644
--- a/storaged/storaged_service.cpp
+++ b/storaged/storaged_service.cpp
@@ -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();
}