private long getTimeTillNextCounterValue(long time) {
    long currentValue = getCounterValue(time);
    long nextValue = currentValue + 1;
    long nextValueStartTime = Utilities.secondsToMillis(mCounter.getValueStartTime(nextValue));
    return nextValueStartTime - time;
  }
Gets the time remaining till the counter assumes its next value.

@param time time instant (milliseconds since epoch) for which to perform the query.

@return time (milliseconds) till next value.
java/com/google/android/apps/authenticator/otp/TotpCountdownTask.java