Fixed polling

This commit is contained in:
M66B
2020-03-21 09:39:46 +01:00
parent 0451d7f176
commit 0859a88ee4
3 changed files with 11 additions and 10 deletions

View File

@@ -1804,25 +1804,25 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
am.cancel(pi);
boolean enabled;
boolean poll;
long[] schedule = getSchedule(context);
if (schedule == null)
enabled = false;
poll = true;
else {
long now = new Date().getTime();
long next = (now < schedule[0] ? schedule[0] : schedule[1]);
enabled = (now >= schedule[0] && now < schedule[1]);
poll = (now >= schedule[0] && now < schedule[1]);
Log.i("Schedule now=" + new Date(now));
Log.i("Schedule start=" + new Date(schedule[0]));
Log.i("Schedule end=" + new Date(schedule[1]));
Log.i("Schedule next=" + new Date(next));
Log.i("Schedule enabled=" + enabled);
Log.i("Schedule poll=" + poll);
AlarmManagerCompat.setAndAllowWhileIdle(am, AlarmManager.RTC_WAKEUP, next, pi);
}
ServiceUI.schedule(context, enabled);
ServiceUI.schedule(context, poll);
}
static long[] getSchedule(Context context) {