Run cleanup at low priority

pull/153/head
M66B 6 years ago
parent d062974f55
commit 3f2c34fbf5

@ -21,6 +21,8 @@ import androidx.work.WorkManager;
import androidx.work.Worker; import androidx.work.Worker;
import androidx.work.WorkerParameters; import androidx.work.WorkerParameters;
import static android.os.Process.THREAD_PRIORITY_BACKGROUND;
public class WorkerCleanup extends Worker { public class WorkerCleanup extends Worker {
private static final int CLEANUP_INTERVAL = 4; // hours private static final int CLEANUP_INTERVAL = 4; // hours
private static final long CACHE_IMAGE_DURATION = 3 * 24 * 3600 * 1000L; // milliseconds private static final long CACHE_IMAGE_DURATION = 3 * 24 * 3600 * 1000L; // milliseconds
@ -41,6 +43,7 @@ public class WorkerCleanup extends Worker {
static void cleanup(Context context, boolean manual) { static void cleanup(Context context, boolean manual) {
DB db = DB.getInstance(context); DB db = DB.getInstance(context);
try { try {
Thread.currentThread().setPriority(THREAD_PRIORITY_BACKGROUND);
Log.i("Start cleanup manual=" + manual); Log.i("Start cleanup manual=" + manual);
// Cleanup folders // Cleanup folders

Loading…
Cancel
Save