Package org.robolectric.shadows
Class ShadowSystemClock
- java.lang.Object
-
- org.robolectric.shadows.ShadowSystemClock
-
- Direct Known Subclasses:
ShadowLegacySystemClock,ShadowPausedSystemClock
@Implements(value=android.os.SystemClock.class, shadowPicker=Picker.class, looseSignatures=true) public abstract class ShadowSystemClock extends java.lang.ObjectThe shadow API forSystemClock. The behavior of SystemClock in Robolectric will differ based on the currentLooperMode. SeeShadowLegacySystemClockandShadowPausedSystemClockfor more details.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classShadowSystemClock.Picker
-
Field Summary
Fields Modifier and Type Field Description protected static booleannetworkTimeAvailable
-
Constructor Summary
Constructors Constructor Description ShadowSystemClock()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static voidadvanceBy(java.time.Duration duration)A convenience method for advancing the clock viaSystemClock.setCurrentTimeMillis(long)protected static java.lang.ObjectcurrentGnssTimeClock()static longcurrentTimeMillis()ImplementsSystem.currentTimeMillis()through ShadowWrangler.static longnanoTime()Deprecated.Don't call this method directly; instead, useSystem.nanoTime().static voidreset()static voidsetGnssTimeAvailable(boolean available)Sets whether gnss location based time is available.static voidsetNanoTime(long nanoTime)Sets the value forSystem.nanoTime().static voidsetNetworkTimeAvailable(boolean available)Sets whether network time is available.
-
-
-
Method Detail
-
currentTimeMillis
public static long currentTimeMillis()
ImplementsSystem.currentTimeMillis()through ShadowWrangler.- Returns:
- Current time in millis.
-
nanoTime
@Deprecated public static long nanoTime()
Deprecated.Don't call this method directly; instead, useSystem.nanoTime().ImplementsSystem.nanoTime().- Returns:
- Current time with nanos.
-
setNanoTime
public static void setNanoTime(long nanoTime)
Sets the value forSystem.nanoTime().May only be used for
LooperMode.Mode.LEGACY. ForLooperMode.Mode.PAUSED, {@param nanoTime} is calculated based onSystemClock.uptimeMillis()and can't be set explicitly.
-
setNetworkTimeAvailable
public static void setNetworkTimeAvailable(boolean available)
Sets whether network time is available.
-
advanceBy
public static void advanceBy(java.time.Duration duration)
A convenience method for advancing the clock viaSystemClock.setCurrentTimeMillis(long)- Parameters:
duration- The interval by which to advance.
-
currentGnssTimeClock
@Implementation(minSdk=29) protected static java.lang.Object currentGnssTimeClock()
-
setGnssTimeAvailable
public static void setGnssTimeAvailable(boolean available)
Sets whether gnss location based time is available.
-
reset
public static void reset()
-
-