Package org.robolectric.shadows
Class ShadowPausedSystemClock
java.lang.Object
org.robolectric.shadows.ShadowSystemClock
org.robolectric.shadows.ShadowPausedSystemClock
@Implements(value=android.os.SystemClock.class,
isInAndroidSdk=false,
shadowPicker=Picker.class)
public class ShadowPausedSystemClock
extends ShadowSystemClock
A shadow SystemClock used when
is active.
invalid reference
LooperMode.Mode#PAUSED
In this variant, System times (both elapsed realtime and uptime) are controlled by this class.
The current times are fixed in place. You can manually advance both by calling SystemClock.setCurrentTimeMillis(long) or just advance elapsed realtime only by calling deepSleep(long).
SystemClock.uptimeMillis() and SystemClock.currentThreadTimeMillis() are
identical.
This class should not be referenced directly. Use ShadowSystemClock instead.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.robolectric.shadows.ShadowSystemClock
ShadowSystemClock.Picker -
Field Summary
Fields inherited from class org.robolectric.shadows.ShadowSystemClock
networkTimeAvailable -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static longprotected static longprotected static longprotected static longprotected static voiddeepSleep(long millis) Advances the current time (elapsed realtime only) by given millis, without sleeping the current thread.protected static longprotected static longstatic voidreset()protected static booleansetCurrentTimeMillis(long millis) Sets the current wall time (both elapsed realtime and uptime).protected static voidsleep(long millis) Advances the current time (both elapsed realtime and uptime) by given millis, without sleeping the current thread.protected static longMethods inherited from class org.robolectric.shadows.ShadowSystemClock
advanceBy, advanceBy, currentGnssTimeClock, currentTimeMillis, nanoTime, setGnssTimeAvailable, setNanoTime, setNetworkTimeAvailable, simulateDeepSleep
-
Constructor Details
-
ShadowPausedSystemClock
public ShadowPausedSystemClock()
-
-
Method Details
-
sleep
@Implementation protected static void sleep(long millis) Advances the current time (both elapsed realtime and uptime) by given millis, without sleeping the current thread. -
deepSleep
protected static void deepSleep(long millis) Advances the current time (elapsed realtime only) by given millis, without sleeping the current thread.This is to simulate scenarios like suspend-to-RAM, where only elapsed realtime is incremented when the device is in deep sleep.
-
setCurrentTimeMillis
@Implementation protected static boolean setCurrentTimeMillis(long millis) Sets the current wall time (both elapsed realtime and uptime).This API sets both of the elapsed realtime and uptime to the specified value.
Currently does not perform any permission checks.
- Returns:
- false if specified time is less than current uptime.
-
uptimeMillis
@Implementation protected static long uptimeMillis() -
elapsedRealtime
@Implementation protected static long elapsedRealtime() -
elapsedRealtimeNanos
@Implementation protected static long elapsedRealtimeNanos() -
currentThreadTimeMillis
@Implementation protected static long currentThreadTimeMillis() -
currentThreadTimeMicro
@HiddenApi @Implementation protected static long currentThreadTimeMicro() -
currentTimeMicro
@HiddenApi @Implementation protected static long currentTimeMicro() -
currentNetworkTimeMillis
@Implementation(minSdk=28) @HiddenApi protected static long currentNetworkTimeMillis() -
reset
@Resetter public static void reset()
-