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 import android.annotation.UnsupportedAppUsage; 20 21 /** 22 * Interface that provides trusted time information, possibly coming from an NTP 23 * server. Implementations may cache answers until {@link #forceRefresh()}. 24 * 25 * @hide 26 */ 27 public interface TrustedTime { 28 /** 29 * Force update with an external trusted time source, returning {@code true} 30 * when successful. 31 */ 32 @UnsupportedAppUsage forceRefresh()33 public boolean forceRefresh(); 34 35 /** 36 * Check if this instance has cached a response from a trusted time source. 37 */ 38 @UnsupportedAppUsage hasCache()39 public boolean hasCache(); 40 41 /** 42 * Return time since last trusted time source contact, or 43 * {@link Long#MAX_VALUE} if never contacted. 44 */ 45 @UnsupportedAppUsage getCacheAge()46 public long getCacheAge(); 47 48 /** 49 * Return certainty of cached trusted time in milliseconds, or 50 * {@link Long#MAX_VALUE} if never contacted. Smaller values are more 51 * precise. 52 */ getCacheCertainty()53 public long getCacheCertainty(); 54 55 /** 56 * Return current time similar to {@link System#currentTimeMillis()}, 57 * possibly using a cached authoritative time source. 58 */ 59 @UnsupportedAppUsage currentTimeMillis()60 public long currentTimeMillis(); 61 } 62