Add a flag to enable/disable the diskstats logging service.
am: 88e45dcd1f
Change-Id: Ie822eea68dc0a02c8fad1a838ff9bf23f738106f
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index b721a2e..d93cd57 100755
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -9473,6 +9473,12 @@
* @hide
*/
public static final String WARNING_TEMPERATURE = "warning_temperature";
+
+ /**
+ * Whether the diskstats logging task is enabled/disabled.
+ * @hide
+ */
+ public static final String ENABLE_DISKSTATS_LOGGING = "enable_diskstats_logging";
}
/**
diff --git a/services/core/java/com/android/server/storage/DiskStatsLoggingService.java b/services/core/java/com/android/server/storage/DiskStatsLoggingService.java
index 0a3abf3..7c43162 100644
--- a/services/core/java/com/android/server/storage/DiskStatsLoggingService.java
+++ b/services/core/java/com/android/server/storage/DiskStatsLoggingService.java
@@ -21,6 +21,7 @@
import android.app.job.JobScheduler;
import android.app.job.JobService;
import android.content.ComponentName;
+import android.content.ContentResolver;
import android.content.Context;
import android.content.pm.PackageStats;
import android.os.AsyncTask;
@@ -28,6 +29,7 @@
import android.os.Environment;
import android.os.Environment.UserEnvironment;
import android.os.UserHandle;
+import android.provider.Settings;
import android.util.Log;
import com.android.internal.annotations.VisibleForTesting;
@@ -54,7 +56,7 @@
public boolean onStartJob(JobParameters params) {
// We need to check the preconditions again because they may not be enforced for
// subsequent runs.
- if (!isCharging(this)) {
+ if (!isCharging(this) || !isDumpsysTaskEnabled(getContentResolver())) {
jobFinished(params, true);
return false;
}
@@ -105,6 +107,12 @@
}
@VisibleForTesting
+ static boolean isDumpsysTaskEnabled(ContentResolver resolver) {
+ // The default is to treat the task as enabled.
+ return Settings.Global.getInt(resolver, Settings.Global.ENABLE_DISKSTATS_LOGGING, 1) != 0;
+ }
+
+ @VisibleForTesting
static class LogRunnable implements Runnable {
private static final long TIMEOUT_MILLIS = TimeUnit.MINUTES.toMillis(10);