Add a flag to enable/disable the diskstats logging service.
am: 88e45dcd1f
Change-Id: Ie822eea68dc0a02c8fad1a838ff9bf23f738106f
This commit is contained in:
@@ -9473,6 +9473,12 @@ public final class Settings {
|
|||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public static final String WARNING_TEMPERATURE = "warning_temperature";
|
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";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import android.app.job.JobParameters;
|
|||||||
import android.app.job.JobScheduler;
|
import android.app.job.JobScheduler;
|
||||||
import android.app.job.JobService;
|
import android.app.job.JobService;
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
|
import android.content.ContentResolver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.pm.PackageStats;
|
import android.content.pm.PackageStats;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
@@ -28,6 +29,7 @@ import android.os.BatteryManager;
|
|||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
import android.os.Environment.UserEnvironment;
|
import android.os.Environment.UserEnvironment;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
|
import android.provider.Settings;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.android.internal.annotations.VisibleForTesting;
|
import com.android.internal.annotations.VisibleForTesting;
|
||||||
@@ -54,7 +56,7 @@ public class DiskStatsLoggingService extends JobService {
|
|||||||
public boolean onStartJob(JobParameters params) {
|
public boolean onStartJob(JobParameters params) {
|
||||||
// We need to check the preconditions again because they may not be enforced for
|
// We need to check the preconditions again because they may not be enforced for
|
||||||
// subsequent runs.
|
// subsequent runs.
|
||||||
if (!isCharging(this)) {
|
if (!isCharging(this) || !isDumpsysTaskEnabled(getContentResolver())) {
|
||||||
jobFinished(params, true);
|
jobFinished(params, true);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -104,6 +106,12 @@ public class DiskStatsLoggingService extends JobService {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@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
|
@VisibleForTesting
|
||||||
static class LogRunnable implements Runnable {
|
static class LogRunnable implements Runnable {
|
||||||
private static final long TIMEOUT_MILLIS = TimeUnit.MINUTES.toMillis(10);
|
private static final long TIMEOUT_MILLIS = TimeUnit.MINUTES.toMillis(10);
|
||||||
|
|||||||
Reference in New Issue
Block a user