Class SntpClient
- java.lang.Object
-
- com.google.android.exoplayer2.util.SntpClient
-
@Deprecated public final class SntpClient extends Object
Deprecated.com.google.android.exoplayer2 is deprecated. Please migrate to androidx.media3 (which contains the same ExoPlayer code). See the migration guide for more details, including a script to help with the migration.Static utility to retrieve the device time offset using SNTP.Based on the Android framework SntpClient.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
SntpClient.InitializationCallback
Deprecated.Callback for calls toinitialize(Loader, InitializationCallback)
.
-
Field Summary
Fields Modifier and Type Field Description static String
DEFAULT_NTP_HOST
Deprecated.The default NTP host address used to retrievegetElapsedRealtimeOffsetMs()
.
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static long
getElapsedRealtimeOffsetMs()
Deprecated.Returns the offset betweenSystemClock.elapsedRealtime()
and the NTP server time in milliseconds, orC.TIME_UNSET
ifisInitialized()
returns false.static String
getNtpHost()
Deprecated.Returns the NTP host address used to retrievegetElapsedRealtimeOffsetMs()
.static void
initialize(Loader loader, SntpClient.InitializationCallback callback)
Deprecated.Starts loading the device time offset.static boolean
isInitialized()
Deprecated.Returns whether the device time offset has already been loaded.static void
setNtpHost(String ntpHost)
Deprecated.Sets the NTP host address used to retrievegetElapsedRealtimeOffsetMs()
.
-
-
-
Field Detail
-
DEFAULT_NTP_HOST
public static final String DEFAULT_NTP_HOST
Deprecated.The default NTP host address used to retrievegetElapsedRealtimeOffsetMs()
.- See Also:
- Constant Field Values
-
-
Method Detail
-
getNtpHost
public static String getNtpHost()
Deprecated.Returns the NTP host address used to retrievegetElapsedRealtimeOffsetMs()
.
-
setNtpHost
public static void setNtpHost(String ntpHost)
Deprecated.Sets the NTP host address used to retrievegetElapsedRealtimeOffsetMs()
.The default is
DEFAULT_NTP_HOST
.If the new host address is different from the previous one, the NTP client will be
isInitialized()
uninitialized} again.- Parameters:
ntpHost
- The NTP host address.
-
isInitialized
public static boolean isInitialized()
Deprecated.Returns whether the device time offset has already been loaded.If
false
, useinitialize(Loader, InitializationCallback)
to start the initialization.
-
getElapsedRealtimeOffsetMs
public static long getElapsedRealtimeOffsetMs()
Deprecated.Returns the offset betweenSystemClock.elapsedRealtime()
and the NTP server time in milliseconds, orC.TIME_UNSET
ifisInitialized()
returns false.The offset is calculated as
ntpServerTime - deviceElapsedRealTime
.
-
initialize
public static void initialize(@Nullable Loader loader, @Nullable SntpClient.InitializationCallback callback)
Deprecated.Starts loading the device time offset.- Parameters:
loader
- ALoader
to use for loading the time offset, or null to create a new one.callback
- An optionalSntpClient.InitializationCallback
to be notified when the time offset has been initialized or initialization failed.
-
-