|
|
|
@ -166,6 +166,7 @@ public class WorkerCleanup extends Worker {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void queue(Context context) {
|
|
|
|
|
try {
|
|
|
|
|
Log.i("Queuing " + getName() + " every " + CLEANUP_INTERVAL + " hours");
|
|
|
|
|
|
|
|
|
|
PeriodicWorkRequest workRequest =
|
|
|
|
@ -175,12 +176,20 @@ public class WorkerCleanup extends Worker {
|
|
|
|
|
.enqueueUniquePeriodicWork(getName(), ExistingPeriodicWorkPolicy.REPLACE, workRequest);
|
|
|
|
|
|
|
|
|
|
Log.i("Queued " + getName());
|
|
|
|
|
} catch (IllegalStateException ex) {
|
|
|
|
|
// https://issuetracker.google.com/issues/138465476
|
|
|
|
|
Log.w(ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void cancel(Context context) {
|
|
|
|
|
try {
|
|
|
|
|
Log.i("Cancelling " + getName());
|
|
|
|
|
WorkManager.getInstance(context).cancelUniqueWork(getName());
|
|
|
|
|
Log.i("Cancelled " + getName());
|
|
|
|
|
} catch (IllegalStateException ex) {
|
|
|
|
|
Log.w(ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static String getName() {
|
|
|
|
|