/** * {@hide} */ public static long computeNextCycleBoundary(long currentTime, NetworkPolicy policy) { if (policy.cycleDay == CYCLE_NONE) { throw new IllegalArgumentException("Unable to compute boundary without cycleDay"); } final Time now = new Time(policy.cycleTimezone); now.set(currentTime); // first, find cycle boundary for current month final Time cycle = new Time(now); cycle.hour = cycle.minute = cycle.second = 0; snapToCycleDay(cycle, policy.cycleDay); if (Time.compare(cycle, now) <= 0) { // cycle boundary is before now, use next cycle boundary; start by // pushing ourselves squarely into next month. final Time nextMonth = new Time(now); nextMonth.hour = nextMonth.minute = nextMonth.second = 0; nextMonth.monthDay = 1; nextMonth.month += 1; nextMonth.normalize(true); cycle.set(nextMonth); snapToCycleDay(cycle, policy.cycleDay); } return cycle.toMillis(true); }
snapToCycleDay(cycle, policy.cycleDay); snapToCycleDay(cycle, policy.cycleDay);