Fix rescheduling of jobs with large periods.

We were accidentally skipping execution windows of jobs with large
periods if the job was deferred by 30+ minutes, even if the next window
would have been days later. For example, if a periodic job with a period of
7 days and flex of 1 day was scheduled at t0, its original window would
be [t6, t7]. If it ended up running at t7+35minutes, JS would reschedule
the next iteration for [t20, t21], even though it would be safe to
schedule it for [t13, t14]. This change fixes the rescheduling so we
don't skip the next window unless we are actually close to the start of
the next window.

Bug: 229135653
Test: atest FrameworksMockingServicesTests:JobSchedulerServiceTest
Change-Id: I068628e96529b834c5b68e9e25fa130f40f0eef9
2 files changed