Add functions to handle idle maintenance
runIdleMaint is equivalent with:
1. echo 1 > /sys/fs/f2fs/sdX/gc_urgent
2. wait until /sys/fs/f2fs/sdX/dirty_segments
<= threshold or timeout
3. echo 0 > /sys/fs/f2fs/sdX/gc_urgent
4. fstrim
abortIdleMaint forces the wait loop above to exit and
skips fstrim. However, if fstrim is already running,
abortIdleMaint will just leave it run to completion.
Test: adb shell sm idle-maint [run|abort]
Bug: 67776637
Change-Id: I4adff8d9b6bbd63bce41368cea55dc9e9b117eb6
diff --git a/VoldNativeService.cpp b/VoldNativeService.cpp
index d7a6576..e8e151f 100644
--- a/VoldNativeService.cpp
+++ b/VoldNativeService.cpp
@@ -481,6 +481,28 @@
return ok();
}
+binder::Status VoldNativeService::runIdleMaint(
+ const android::sp<android::os::IVoldTaskListener>& listener) {
+ ENFORCE_UID(AID_SYSTEM);
+ ACQUIRE_LOCK;
+
+ std::thread([=]() {
+ android::vold::RunIdleMaint(listener);
+ }).detach();
+ return ok();
+}
+
+binder::Status VoldNativeService::abortIdleMaint(
+ const android::sp<android::os::IVoldTaskListener>& listener) {
+ ENFORCE_UID(AID_SYSTEM);
+ ACQUIRE_LOCK;
+
+ std::thread([=]() {
+ android::vold::AbortIdleMaint(listener);
+ }).detach();
+ return ok();
+}
+
binder::Status VoldNativeService::mountAppFuse(int32_t uid, int32_t pid, int32_t mountId,
android::base::unique_fd* _aidl_return) {
ENFORCE_UID(AID_SYSTEM);