Increase daily job interval, schedule on boot/update only

This commit is contained in:
M66B 2018-09-22 07:42:02 +00:00
parent 8068b296df
commit 420acdc1fe
3 changed files with 5 additions and 3 deletions

View File

@ -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

View File

@ -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();
}

View File

@ -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) {