Esempio n. 1
0
 public int getDueDay() {
   Time time = getTime(taskData.end_date);
   Time now = new Time();
   now.setToNow();
   long diff = time.toMillis(true) - now.toMillis(true);
   return (int) (diff / (1000 * 60 * 60 * 24));
 }
  private void populateWhen() {
    long startMillis = mStartTime.toMillis(false /* use isDst */);
    long endMillis = mDueTime.toMillis(false /* use isDst */);
    setDate(mStartDateButton, startMillis, mShowStart);
    setDate(mDueDateButton, endMillis, mShowDue);

    setTime(mStartTimeButton, startMillis, mShowStart);
    setTime(mDueTimeButton, endMillis, mShowDue);
  }
Esempio n. 3
0
        /**
         * Get the due date to show. It returns just a time for tasks that are due today and a date
         * otherwise.
         *
         * @param due The due date to format.
         * @return A String with the formatted date.
         */
        private String makeDueDate(Time due) {
          if (!due.allDay) {
            due.switchTimezone(TimeZone.getDefault().getID());
          }

          if (due.year == mNow.year && due.yearDay == mNow.yearDay) {
            return mTimeFormatter.format(new Date(due.toMillis(false)));
          } else {
            return mDateFormatter.format(new Date(due.toMillis(false)));
          }
        }
Esempio n. 4
0
    /** Parses an SC timestamp and returns a currentTimeMillis()-style timestamp */
    long getSCTimestampMillis() {
      // TP-Service-Centre-Time-Stamp
      int year = IccUtils.gsmBcdByteToInt(mPdu[mCur++]);
      int month = IccUtils.gsmBcdByteToInt(mPdu[mCur++]);
      int day = IccUtils.gsmBcdByteToInt(mPdu[mCur++]);
      int hour = IccUtils.gsmBcdByteToInt(mPdu[mCur++]);
      int minute = IccUtils.gsmBcdByteToInt(mPdu[mCur++]);
      int second = IccUtils.gsmBcdByteToInt(mPdu[mCur++]);

      // For the timezone, the most significant bit of the
      // least significant nibble is the sign byte
      // (meaning the max range of this field is 79 quarter-hours,
      // which is more than enough)

      byte tzByte = mPdu[mCur++];

      // Mask out sign bit.
      int timezoneOffset = IccUtils.gsmBcdByteToInt((byte) (tzByte & (~0x08)));

      timezoneOffset = ((tzByte & 0x08) == 0) ? timezoneOffset : -timezoneOffset;

      Time time = new Time(Time.TIMEZONE_UTC);

      // It's 2006.  Should I really support years < 2000?
      time.year = year >= 90 ? year + 1900 : year + 2000;
      time.month = month - 1;
      time.monthDay = day;
      time.hour = hour;
      time.minute = minute;
      time.second = second;

      // Timezone offset is in quarter hours.
      return time.toMillis(true) - (timezoneOffset * 15 * 60 * 1000);
    }
Esempio n. 5
0
    @Override
    public boolean equals(Object obj) {
      if (this == obj) return true;
      if (obj == null) return false;
      if (getClass() != obj.getClass()) return false;
      QuerySpec other = (QuerySpec) obj;
      if (end != other.end
          || queryStartMillis != other.queryStartMillis
          || queryType != other.queryType
          || start != other.start
          || Utils.equals(searchQuery, other.searchQuery)
          || id != other.id) {
        return false;
      }

      if (goToTime != null) {
        if (goToTime.toMillis(false) != other.goToTime.toMillis(false)) {
          return false;
        }
      } else {
        if (other.goToTime != null) {
          return false;
        }
      }
      return true;
    }
Esempio n. 6
0
 // Helper functions to convert the DB DepartureTime value
 public static long convertDBToTime(int minutes) {
   // This converts the minutes-to-midnight to a time of the current
   // day.
   Time t = new Time();
   t.setToNow();
   t.set(0, minutes, 0, t.monthDay, t.month, t.year);
   return t.toMillis(false);
 }
Esempio n. 7
0
  /*
     Denne konstructør skal anvendes når der startes et nyt løb.
     her new'es nyt uuid op, og tiden sættes.
  */
  public LoebsAktivitet() {

    pointInfoList = new ArrayList<PointInfo>();
    Time time = new Time();
    time.setToNow();
    starttidspunkt = time.toMillis(false);
    loebsAktivitetUuid = UUID.randomUUID();
    loebsDato = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
  }
Esempio n. 8
0
  public static void registerAlarm(Context context) {
    Time fire = new Time();
    fire.setToNow();
    fire.hour = HOUR;
    fire.minute = MINUTE;
    fire.second = SECOND;

    if (fire.toMillis(true) <= System.currentTimeMillis()) fire.monthDay++;

    long time = fire.toMillis(true);

    AlarmManager alarm = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
    // One day is not always 24 hours (consider DST), so we use set instead of setRepeating,
    // and set the next alarm in onReceive.
    alarm.set(AlarmManager.RTC_WAKEUP, time, getSender(context));

    Log.d(PurgeActivity.TAG, String.format("registered alarm with time %d", time));
  }
    public void onDateSet(DatePicker view, int year, int month, int monthDay) {
      // Cache the member variables locally to avoid inner class overhead.
      Time startTime = mStartTime;
      Time dueTime = mDueTime;

      // Cache the start and due millis so that we limit the number
      // of calls to normalize() and toMillis(), which are fairly
      // expensive.
      long startMillis;
      long dueMillis;
      if (mView == mStartDateButton) {
        // The start date was changed.
        int yearDuration = dueTime.year - startTime.year;
        int monthDuration = dueTime.month - startTime.month;
        int monthDayDuration = dueTime.monthDay - startTime.monthDay;

        startTime.year = year;
        startTime.month = month;
        startTime.monthDay = monthDay;
        startMillis = startTime.normalize(true);
        mShowStart = true;

        // Also update the end date to keep the duration constant.
        dueTime.year = year + yearDuration;
        dueTime.month = month + monthDuration;
        dueTime.monthDay = monthDay + monthDayDuration;
        dueMillis = dueTime.normalize(true);
        mShowDue = true;
      } else {
        // The end date was changed.
        startMillis = startTime.toMillis(true);
        dueTime.year = year;
        dueTime.month = month;
        dueTime.monthDay = monthDay;
        dueMillis = dueTime.normalize(true);
        mShowDue = true;

        if (mShowStart) {
          // Do not allow an event to have an end time before the start time.
          if (dueTime.before(startTime)) {
            dueTime.set(startTime);
            dueMillis = startMillis;
          }
        } else {
          // if start time is not shown, default it to be the same as due time
          startTime.set(dueTime);
          mShowStart = true;
        }
      }

      // update all 4 buttons in case visibility has changed
      setDate(mStartDateButton, startMillis, mShowStart);
      setTime(mStartTimeButton, startMillis, mShowStart);
      setDate(mDueDateButton, dueMillis, mShowDue);
      setTime(mDueTimeButton, dueMillis, mShowDue);
      updateCalendarPanel();
    }
Esempio n. 10
0
  public static void setLoggedInRightNow(SharedPreferences loginSettings) {
    Time now = new Time();
    now.setToNow();
    long milliseconds = now.toMillis(false) + 10800000; // 3 hours expired sessions

    Editor editor = loginSettings.edit();
    editor.putLong("timeLoggedIn", milliseconds);
    editor.commit();
  }
  private void schedule1(Cursor c, Time tNow, long now) {
    final String tripId = c.getString(COL_ID);
    final String stopId = c.getString(COL_STOP_ID);
    final Uri tripUri = ObaContract.Trips.buildUri(tripId, stopId);

    final int departureMins = c.getInt(COL_DEPARTURE);
    final long reminderMS = c.getInt(COL_REMINDER) * ONE_MINUTE;
    if (reminderMS == 0) {
      return;
    }
    final int days = c.getInt(COL_DAYS);
    if (days == 0) {
      Time tmp = new Time();
      tmp.set(0, departureMins, 0, tNow.monthDay, tNow.month, tNow.year);
      tmp.normalize(false);
      long remindTime = tmp.toMillis(false) - reminderMS;
      long triggerTime = remindTime - LOOKAHEAD_DURATION_MS;

      if (!scheduleAlert(tripUri, tripId, stopId, triggerTime)) {
        // If we failed to schedule a one-off alert, then it's
        // probably been cancelled or in the past and we should
        // just delete it.
        mCR.delete(tripUri, null, null);
      }
    } else {
      final int currentWeekDay = tNow.weekDay;
      for (int i = 0; i < 7; ++i) {
        final int day = (currentWeekDay + i) % 7;
        final int bit = ObaContract.Trips.getDayBit(day);
        if ((days & bit) == bit) {
          Time tmp = new Time();
          tmp.set(0, departureMins, 0, tNow.monthDay + i, tNow.month, tNow.year);
          tmp.normalize(false);
          long remindTime = tmp.toMillis(false) - reminderMS;
          long triggerTime = remindTime - LOOKAHEAD_DURATION_MS;

          if (scheduleAlert(tripUri, tripId, stopId, triggerTime)) {
            return;
          }
        }
      }
    }
  }
Esempio n. 12
0
 private static int getNumberOfLastIntakesByCount(
     Time dtStart, String recurrenceRule, int dailyIntakes) {
   long[] dates = expand(dtStart, recurrenceRule, dtStart.toMillis(false), -1);
   int length = dates.length;
   if (length > 0) {
     int result = length % dailyIntakes;
     return (result == 0) ? dailyIntakes : result;
   }
   return 0;
 }
Esempio n. 13
0
  /**
   * Parse a NWS date string into a Unix timestamp. Assumes incoming values are in the format
   * "2009-03-23T18:00:00-07:00", which we adjust slightly to correctly follow RFC 3339 before
   * parsing.
   */
  private static long parseDate(String raw) throws TimeFormatException {
    // Inject milliseconds so that NWS dates follow RFC
    sEditable.clear();
    sEditable.append(raw);
    sEditable.insert(19, ".000");

    String rfcFormat = sEditable.toString();
    sTime.parse3339(rfcFormat);
    return sTime.toMillis(false);
  }
Esempio n. 14
0
 private String getReportFileName(CrashReportData crashData) {
   final Time now = new Time();
   now.setToNow();
   final long timestamp = now.toMillis(false);
   final String isSilent = crashData.getProperty(IS_SILENT);
   return ""
       + timestamp
       + (isSilent != null ? ACRAConstants.SILENT_SUFFIX : "")
       + ACRAConstants.REPORTFILE_EXTENSION;
 }
Esempio n. 15
0
  /**
   * Format the given due date. The result depends on the current date and on the all-day flag of
   * the due date.
   *
   * <p>If the due date it today the format will contain "today" instead of the date. Allday dates
   * won't contain a time.
   *
   * @param dueDate The due date to format.
   * @return A string with the formatted due date.
   */
  public String format(Time dueDate) {
    mNow.clear(TimeZone.getDefault().getID());
    mNow.setToNow();

    if (!dueDate.allDay) {
      dueDate.switchTimezone(TimeZone.getDefault().getID());
    }

    // normalize time to ensure yearDay is set properly
    dueDate.normalize(false);

    if (dueDate.year == mNow.year && dueDate.yearDay == mNow.yearDay) {
      if (dueDate.allDay) {
        return mContext.getString(R.string.today);
      } else {
        return mContext.getString(R.string.today)
            + ", "
            + mTimeFormatter.format(new Date(dueDate.toMillis(false)));
      }
    } else {
      return mDateFormatter.format(new Date(dueDate.toMillis(false)));
    }
  }
Esempio n. 16
0
 private String formatDateString(int julianDay) {
   Time time = new Time(mTimeZone);
   time.setJulianDay(julianDay);
   long millis = time.toMillis(false);
   mStringBuilder.setLength(0);
   return DateUtils.formatDateRange(
           mContext,
           mFormatter,
           millis,
           millis,
           DateUtils.FORMAT_SHOW_YEAR | DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_ABBREV_MONTH,
           mTimeZone)
       .toString();
 }
 /** @param tz */
 public boolean updateToday(String tz) {
   mToday.timezone = tz;
   mToday.setToNow();
   mToday.normalize(true);
   int julianToday = Time.getJulianDay(mToday.toMillis(false), mToday.gmtoff);
   if (julianToday >= mFirstJulianDay && julianToday < mFirstJulianDay + mNumDays) {
     mHasToday = true;
     mTodayIndex = julianToday - mFirstJulianDay;
   } else {
     mHasToday = false;
     mTodayIndex = -1;
   }
   return mHasToday;
 }
Esempio n. 18
0
  private AgendaItem buildAgendaItemFromCursor(
      final Cursor cursor, int cursorPosition, boolean isDayHeader) {
    if (cursorPosition == -1) {
      cursor.moveToFirst();
    } else {
      cursor.moveToPosition(cursorPosition);
    }
    AgendaItem agendaItem = new AgendaItem();
    agendaItem.begin = cursor.getLong(AgendaWindowAdapter.INDEX_BEGIN);
    agendaItem.end = cursor.getLong(AgendaWindowAdapter.INDEX_END);
    agendaItem.startDay = cursor.getInt(AgendaWindowAdapter.INDEX_START_DAY);
    agendaItem.allDay = cursor.getInt(AgendaWindowAdapter.INDEX_ALL_DAY) != 0;
    if (agendaItem.allDay) { // UTC to Local time conversion
      Time time = new Time(mTimeZone);
      time.setJulianDay(Time.getJulianDay(agendaItem.begin, 0));
      agendaItem.begin = time.toMillis(false /* use isDst */);
    } else if (isDayHeader) { // Trim to midnight.
      Time time = new Time(mTimeZone);
      time.set(agendaItem.begin);
      time.hour = 0;
      time.minute = 0;
      time.second = 0;
      agendaItem.begin = time.toMillis(false /* use isDst */);
    }

    // If this is not a day header, then it's an event.
    if (!isDayHeader) {
      agendaItem.id = cursor.getLong(AgendaWindowAdapter.INDEX_EVENT_ID);
      if (agendaItem.allDay) {
        Time time = new Time(mTimeZone);
        time.setJulianDay(Time.getJulianDay(agendaItem.end, 0));
        agendaItem.end = time.toMillis(false /* use isDst */);
      }
    }
    return agendaItem;
  }
Esempio n. 19
0
  public static boolean isSessionExpired(SharedPreferences loginSettings) {
    Time now = new Time();
    now.setToNow();
    long milliseconds = now.toMillis(false);

    long milliSessionExpires = loginSettings.getLong("timeLoggedIn", 0);

    if (milliseconds >= milliSessionExpires) {
      Log.i("isSessionExpired", "yes");
      return true;
    } else {
      Log.i("isSessionExpired", "not");
      return false;
    }
  }
Esempio n. 20
0
  public void deleteOldAlerts() {

    SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences((Context) this);
    int maxAge = sharedPrefs.getInt("max_age", AlertsContract.DEFAULT_MAX_AGE);
    long maxAgeSeconds = maxAge * 24 * 60 * 60 * 1000;

    Time today = new Time(Time.getCurrentTimezone());
    today.setToNow();
    long olderThan = today.toMillis(true) - maxAgeSeconds;

    String selection = AlertsContract.RECEIVED_AT + " < ?";
    String[] selectionArgs = {String.valueOf(olderThan)};

    getContentResolver().delete(AlertsContract.CONTENT_URI_ALERTS, selection, selectionArgs);
  }
  /** Refresh month title text view when user swipe */
  protected void refreshMonthTitleTextView() {
    // Refresh title view
    firstMonthTime.year = year;
    firstMonthTime.month = month - 2;
    firstMonthTime.monthDay = 1;
    long millis = firstMonthTime.toMillis(true);

    // This is the method used by the platform Calendar app to get a
    // correctly localized month name for display on a wall calendar
    monthYearStringBuilder.setLength(0);
    String monthTitle =
        DateUtils.formatDateRange(
                getActivity(), monthYearFormatter, millis, millis, MONTH_YEAR_FLAG)
            .toString();

    monthTitleTextView.setText(monthTitle);
  }
Esempio n. 22
0
 @Override
 public int hashCode() {
   final int prime = 31;
   int result = 1;
   result = prime * result + end;
   result = prime * result + (int) (queryStartMillis ^ (queryStartMillis >>> 32));
   result = prime * result + queryType;
   result = prime * result + start;
   if (searchQuery != null) {
     result = prime * result + searchQuery.hashCode();
   }
   if (goToTime != null) {
     long goToTimeMillis = goToTime.toMillis(false);
     result = prime * result + (int) (goToTimeMillis ^ (goToTimeMillis >>> 32));
   }
   result = prime * result + (int) id;
   return result;
 }
 @Override
 public boolean onHoverEvent(MotionEvent event) {
   Context context = getContext();
   // only send accessibility events if accessibility and exploration are
   // on.
   AccessibilityManager am =
       (AccessibilityManager) context.getSystemService(Service.ACCESSIBILITY_SERVICE);
   if (!am.isEnabled() || !am.isTouchExplorationEnabled()) {
     return super.onHoverEvent(event);
   }
   if (event.getAction() != MotionEvent.ACTION_HOVER_EXIT) {
     Time hover = getDayFromLocation(event.getX());
     if (hover != null && (mLastHoverTime == null || Time.compare(hover, mLastHoverTime) != 0)) {
       Long millis = hover.toMillis(true);
       String date = Utils.formatDateRange(context, millis, millis, DateUtils.FORMAT_SHOW_DATE);
       AccessibilityEvent accessEvent =
           AccessibilityEvent.obtain(AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED);
       accessEvent.getText().add(date);
       if (mShowDetailsInMonth && mEvents != null) {
         int dayStart = SPACING_WEEK_NUMBER + mPadding;
         int dayPosition =
             (int) ((event.getX() - dayStart) * mNumDays / (mWidth - dayStart - mPadding));
         ArrayList<Event> events = mEvents.get(dayPosition);
         List<CharSequence> text = accessEvent.getText();
         for (Event e : events) {
           text.add(e.getTitleAndLocation() + ". ");
           int flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_YEAR;
           if (!e.allDay) {
             flags |= DateUtils.FORMAT_SHOW_TIME;
             if (DateFormat.is24HourFormat(context)) {
               flags |= DateUtils.FORMAT_24HOUR;
             }
           } else {
             flags |= DateUtils.FORMAT_UTC;
           }
           text.add(Utils.formatDateRange(context, e.startMillis, e.endMillis, flags) + ". ");
         }
       }
       sendAccessibilityEventUnchecked(accessEvent);
       mLastHoverTime = hover;
     }
   }
   return true;
 }
  @Override
  public void onReceive(Context context, Intent intent) {
    String state = intent.getStringExtra(TelephonyManager.EXTRA_STATE);

    if (state.equals(TelephonyManager.EXTRA_STATE_RINGING)) {

      ContentValues values = new ContentValues();

      Time ahora = new Time();
      ahora.setToNow();

      values.put(
          IncommingTable.COLUMN_PHONE,
          intent.getStringExtra(TelephonyManager.EXTRA_INCOMING_NUMBER));
      values.put(IncommingTable.COLUMN_CALL_DATE, ahora.toMillis(true));

      context.getContentResolver().insert(IncommingTable.getUri(), values);
    }
  }
  private void scheduleNextUpdate() {
    Intent intent = new Intent(this, this.getClass());
    PendingIntent pendingIntent =
        PendingIntent.getService(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);

    long currentTimeMillis = System.currentTimeMillis();
    long nextUpdateTimeMillis = currentTimeMillis + 3 * DateUtils.MINUTE_IN_MILLIS;
    Time nextUpdateTime = new Time();
    nextUpdateTime.set(nextUpdateTimeMillis);

    if (nextUpdateTime.hour < 8 || nextUpdateTime.hour >= 18) {
      nextUpdateTime.hour = 8;
      nextUpdateTime.minute = 0;
      nextUpdateTime.second = 0;
      nextUpdateTimeMillis = nextUpdateTime.toMillis(false) + DateUtils.DAY_IN_MILLIS;
    }
    AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
    alarmManager.set(AlarmManager.RTC, nextUpdateTimeMillis, pendingIntent);
  }
Esempio n. 26
0
  public static void getLastIntake(Medicine medicine) {
    String recurrenceRule = medicine.getRecurrenceRule();
    String intakesRule = medicine.getSchedule();

    if (!TextUtils.isEmpty(recurrenceRule) && !TextUtils.isEmpty(intakesRule)) {
      Time dtStart = TimeUtils.getTimeDateFromString(medicine.getStartDate());
      List<IntakeHelper> intakes = IntakeUtils.parseDailyIntakes(intakesRule);

      long[] dates;
      int length;
      LocalDate date;
      LocalTime time;

      int durationType = getDurationType(dtStart, recurrenceRule);

      if (durationType == END_NEVER) {
        medicine.setEndDate(-1);
      } else {
        dates = expand(dtStart, recurrenceRule, dtStart.toMillis(false), -1);
        length = dates.length;
        if (length > 0) {
          if (durationType == END_BY_DATE) {
            date = TimeUtils.getDateFromMillis(dates[length - 1]);
            time = intakes.get(intakes.size() - 1).getTime();
          } else {
            // durationType == END_BY_COUNT
            int dailyIntakes = intakes.size();
            if (length % dailyIntakes == 0) {
              date = TimeUtils.getDateFromMillis(dates[(length / dailyIntakes) - 1]);
              time = intakes.get(intakes.size() - 1).getTime();
            } else {
              date = TimeUtils.getDateFromMillis(dates[length / dailyIntakes]);
              time = intakes.get((length % dailyIntakes) - 1).getTime();
            }
          }
          medicine.setEndDate(TimeUtils.getMillis(date, time));
        } else {
          medicine.setEndDate(0);
        }
      }
    }
  }
  /**
   * Link the Sections with the content with a section adapter. Additionally put the current date at
   * the start position.
   */
  private void attachSectionPagerAdapter() {
    Time t = new Time();
    t.setToNow();
    DayView.mLeftBoundary = Time.getJulianDay(t.toMillis(true), t.gmtoff);
    Date now = new Date();
    Calendar calendar = new GregorianCalendar();
    calendar.setTime(now);
    calendar.add(Calendar.MONTH, CalendarActivity.MONTH_AFTER);
    Date lastDate = calendar.getTime();
    int days = (int) ((lastDate.getTime() - now.getTime()) / DateUtils.DAY_IN_MILLIS);
    DayView.mRightBoundary = DayView.mLeftBoundary + days;

    FragmentTransaction ft = getSupportFragmentManager().beginTransaction();

    LoadEventsRequest request = new LoadEventsRequest();
    ft.replace(
        R.id.fragment_container,
        new DayFragment(mEventTime, mWeekMode ? 7 : 1, new EventLoader(this, request)));
    ft.commitAllowingStateLoss();
  }
    @Override
    public void onPostExecute(NotificationEvent _event) {
      if (_event == null || _event.getTravelTime() == FAILURE) {
        Log.w(TAG, "Some problem determining whether late or not");
        // TODO User notification
        return;
      }

      Time t = new Time();
      t.setToNow();
      long nowSec = TimeUnit.SECONDS.convert(t.toMillis(false), TimeUnit.MILLISECONDS);

      boolean isLate = isLate(nowSec, _event.getTravelTime(), _event.getCalendarEvent().getWhen());
      if (isLate) {
        Log.i(TAG, "Event *is* late: " + mCalendarEvent.getDebugString());
        buildLateNotification(_event, mCalendarEvent);
      } else {
        Log.i(TAG, "Event *is not* late: " + mCalendarEvent.getDebugString());
      }
    }
Esempio n. 29
0
  @Override
  public void set(ContentSet values, Time value) {
    values.startBulkUpdate();
    try {
      if (value != null) {
        // just store all three parts separately
        values.put(mTimestampField, value.toMillis(false));

        if (mTzField != null) {
          values.put(mTzField, value.allDay ? null : value.timezone);
        }
        if (mAllDayField != null) {
          values.put(mAllDayField, value.allDay ? 1 : 0);
        }
      } else {
        // write timestamp only, other fields may still use allday and timezone
        values.put(mTimestampField, (Long) null);
      }
    } finally {
      values.finishBulkUpdate();
    }
  }
  @Override
  public void run() {
    cleanupOldAlerts();
    Cursor c = mCR.query(mUri, PROJECTION, null, null, null);

    try {
      Time tNow = new Time();
      tNow.setToNow();
      final long now = tNow.toMillis(false);

      if (c != null) {
        while (c.moveToNext()) {
          schedule1(c, tNow, now);
        }
      }
    } finally {
      if (c != null) {
        c.close();
      }
      mTaskContext.taskComplete();
    }
  }