Jeff Sharkey | b7342ac | 2011-04-25 23:44:11 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2011 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package android.util; |
| 18 | |
| 19 | /** |
| 20 | * Interface that provides trusted time information, possibly coming from an NTP |
| 21 | * server. Implementations may cache answers until {@link #forceRefresh()}. |
| 22 | * |
| 23 | * @hide |
| 24 | */ |
| 25 | public interface TrustedTime { |
| 26 | /** |
| 27 | * Force update with an external trusted time source, returning {@code true} |
| 28 | * when successful. |
| 29 | */ |
| 30 | public boolean forceRefresh(); |
| 31 | |
| 32 | /** |
| 33 | * Check if this instance has cached a response from a trusted time source. |
| 34 | */ |
| 35 | public boolean hasCache(); |
| 36 | |
| 37 | /** |
| 38 | * Return time since last trusted time source contact, or |
| 39 | * {@link Long#MAX_VALUE} if never contacted. |
| 40 | */ |
| 41 | public long getCacheAge(); |
| 42 | |
| 43 | /** |
| 44 | * Return certainty of cached trusted time in milliseconds, or |
| 45 | * {@link Long#MAX_VALUE} if never contacted. Smaller values are more |
| 46 | * precise. |
| 47 | */ |
| 48 | public long getCacheCertainty(); |
| 49 | |
| 50 | /** |
| 51 | * Return current time similar to {@link System#currentTimeMillis()}, |
| 52 | * possibly using a cached authoritative time source. |
| 53 | */ |
| 54 | public long currentTimeMillis(); |
| 55 | } |