vold: add gc period in setGCUrgentPace am: 7c788fc3e9 am: 81ba5bcf1c

Original change: https://android-review.googlesource.com/c/platform/system/vold/+/2032446

Change-Id: I2ec34972e89ecf6872dece12b0ab05bc9a07511c
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/IdleMaint.cpp b/IdleMaint.cpp
index 2fc0d4b..597d609 100644
--- a/IdleMaint.cpp
+++ b/IdleMaint.cpp
@@ -87,7 +87,7 @@
 static const int DEVGC_TIMEOUT_SEC = 120;
 static const int KBYTES_IN_SEGMENT = 2048;
 static const int MIN_GC_URGENT_SLEEP_TIME = 500;
-static const int ONE_HOUR_IN_MS = 3600000;
+static const int ONE_MINUTE_IN_MS = 60000;
 static const int GC_NORMAL_MODE = 0;
 static const int GC_URGENT_MID_MODE = 3;
 
@@ -531,7 +531,7 @@
 }
 
 void SetGCUrgentPace(int32_t neededSegments, int32_t minSegmentThreshold, float dirtyReclaimRate,
-                     float reclaimWeight) {
+                     float reclaimWeight, int32_t gcPeriod) {
     std::list<std::string> paths;
     bool needGC = true;
 
@@ -586,7 +586,7 @@
     if (neededSegments == 0) {
         sleepTime = MIN_GC_URGENT_SLEEP_TIME;
     } else {
-        sleepTime = ONE_HOUR_IN_MS / neededSegments;
+        sleepTime = gcPeriod * ONE_MINUTE_IN_MS / neededSegments;
         if (sleepTime < MIN_GC_URGENT_SLEEP_TIME) {
             sleepTime = MIN_GC_URGENT_SLEEP_TIME;
         }
diff --git a/IdleMaint.h b/IdleMaint.h
index ae70b63..9a2af4a 100644
--- a/IdleMaint.h
+++ b/IdleMaint.h
@@ -27,7 +27,7 @@
 int AbortIdleMaint(const android::sp<android::os::IVoldTaskListener>& listener);
 int32_t GetStorageLifeTime();
 void SetGCUrgentPace(int32_t neededSegments, int32_t minSegmentThreshold, float dirtyReclaimRate,
-                     float reclaimWeight);
+                     float reclaimWeight, int32_t gcPeriod);
 void RefreshLatestWrite();
 int32_t GetWriteAmount();
 
diff --git a/VoldNativeService.cpp b/VoldNativeService.cpp
index ce6e6fc..8ba3aaf 100644
--- a/VoldNativeService.cpp
+++ b/VoldNativeService.cpp
@@ -494,11 +494,12 @@
 
 binder::Status VoldNativeService::setGCUrgentPace(int32_t neededSegments,
                                                   int32_t minSegmentThreshold,
-                                                  float dirtyReclaimRate, float reclaimWeight) {
+                                                  float dirtyReclaimRate, float reclaimWeight,
+                                                  int32_t gcPeriod) {
     ENFORCE_SYSTEM_OR_ROOT;
     ACQUIRE_LOCK;
 
-    SetGCUrgentPace(neededSegments, minSegmentThreshold, dirtyReclaimRate, reclaimWeight);
+    SetGCUrgentPace(neededSegments, minSegmentThreshold, dirtyReclaimRate, reclaimWeight, gcPeriod);
     return Ok();
 }
 
diff --git a/VoldNativeService.h b/VoldNativeService.h
index cb42973..423e8f9 100644
--- a/VoldNativeService.h
+++ b/VoldNativeService.h
@@ -90,7 +90,7 @@
     binder::Status abortIdleMaint(const android::sp<android::os::IVoldTaskListener>& listener);
     binder::Status getStorageLifeTime(int32_t* _aidl_return);
     binder::Status setGCUrgentPace(int32_t neededSegments, int32_t minSegmentThreshold,
-                                   float dirtyReclaimRate, float reclaimWeight);
+                                   float dirtyReclaimRate, float reclaimWeight, int32_t gcPeriod);
     binder::Status refreshLatestWrite();
     binder::Status getWriteAmount(int32_t* _aidl_return);
 
diff --git a/binder/android/os/IVold.aidl b/binder/android/os/IVold.aidl
index 05da7b0..d77c7da 100644
--- a/binder/android/os/IVold.aidl
+++ b/binder/android/os/IVold.aidl
@@ -68,7 +68,8 @@
     void abortIdleMaint(IVoldTaskListener listener);
     int getStorageLifeTime();
     void setGCUrgentPace(int neededSegments, int minSegmentThreshold,
-                         float dirtyReclaimRate, float reclaimWeight);
+                         float dirtyReclaimRate, float reclaimWeight,
+                         int gcPeriod);
     void refreshLatestWrite();
     int getWriteAmount();