Increase daily job interval, schedule on boot/update only

pull/145/head
M66B 6 years ago
parent 8068b296df
commit 420acdc1fe

@ -35,11 +35,13 @@ import java.util.concurrent.Executors;
public class JobDaily extends JobService {
private ExecutorService executor = Executors.newSingleThreadExecutor(Helper.backgroundThreadFactory);
private static final long CLEANUP_INTERVAL = 4 * 3600 * 1000L; // milliseconds
public static void schedule(Context context) {
Log.i(Helper.TAG, "Scheduling daily job");
JobInfo.Builder job = new JobInfo.Builder(Helper.JOB_DAILY, new ComponentName(context, JobDaily.class))
.setPeriodic(24 * 3600 * 1000L)
.setPeriodic(CLEANUP_INTERVAL)
.setRequiresDeviceIdle(true);
JobScheduler scheduler = context.getSystemService(JobScheduler.class);
@ -47,7 +49,7 @@ public class JobDaily extends JobService {
if (scheduler.schedule(job.build()) == JobScheduler.RESULT_SUCCESS)
Log.i(Helper.TAG, "Scheduled daily job");
else
Log.e(Helper.TAG, "Failed to schedule daily job");
Log.e(Helper.TAG, "Scheduling daily job failed");
}
@Override

@ -36,6 +36,7 @@ public class ReceiverAutostart extends BroadcastReceiver {
Log.i(Helper.TAG, "Synchronizing accounts=" + synchronizing);
if (synchronizing > 0)
ServiceSynchronize.start(context);
JobDaily.schedule(context);
}
}).start();
}

@ -2034,7 +2034,6 @@ public class ServiceSynchronize extends LifecycleService {
public static void start(Context context) {
ContextCompat.startForegroundService(context, new Intent(context, ServiceSynchronize.class));
JobDaily.schedule(context);
}
public static void reload(Context context, String reason) {

Loading…
Cancel
Save