public class RuntimeEnvironment
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static android.app.Application |
application
Deprecated.
Please migrate to
androidx.test.core.app.ApplicationProvider#getApplicationContext |
static FsFile |
compileTimeSystemResourcesFile |
static android.content.Context |
systemContext |
Constructor and Description |
---|
RuntimeEnvironment() |
Modifier and Type | Method and Description |
---|---|
static java.lang.Number |
castNativePtr(long ptr) |
static java.lang.Object |
getActivityThread() |
static java.lang.String |
getAndroidFrameworkJarPath() |
static int |
getApiLevel() |
static ResourceTable |
getAppResourceTable() |
static ResourceTable |
getCompileTimeResourceTable() |
static java.lang.Thread |
getMainThread()
Retrieves the main thread.
|
static Scheduler |
getMasterScheduler()
Retrieves the current master scheduler.
|
static java.lang.String |
getQualifiers()
Returns a qualifier string describing the current
Configuration of the system resources. |
static java.lang.String |
getQualifiers(android.content.res.Configuration configuration,
android.util.DisplayMetrics displayMetrics)
Returns a qualifier string describing the given configuration and display metrics.
|
static ResourceTable |
getSystemResourceTable() |
static TempDirectory |
getTempDirectory() |
static boolean |
isMainThread()
Tests if the current thread is currently set as the main thread.
|
static boolean |
isMainThread(java.lang.Thread thread)
Tests if the given thread is currently set as the main thread.
|
static void |
setActivityThread(java.lang.Object newActivityThread) |
static void |
setAndroidFrameworkJarPath(java.lang.String localArtifactPath) |
static void |
setAppResourceTable(ResourceTable appResourceTable) |
static void |
setCompileTimeResourceTable(ResourceTable compileTimeResourceTable) |
static void |
setMainThread(java.lang.Thread newMainThread)
Sets the main thread.
|
static void |
setMasterScheduler(Scheduler masterScheduler)
Sets the current master scheduler.
|
static void |
setQualifiers(java.lang.String newQualifiers)
Overrides the current device configuration.
|
static void |
setSystemResourceTable(ResourceTable systemResourceTable) |
static void |
setTempDirectory(TempDirectory tempDirectory) |
static void |
setUseLegacyResources(boolean useLegacyResources)
Deprecated.
Do not use.
|
static boolean |
useLegacyResources()
Deprecated.
Do not use.
|
public static android.content.Context systemContext
@Deprecated public static android.app.Application application
androidx.test.core.app.ApplicationProvider#getApplicationContext
public static FsFile compileTimeSystemResourcesFile
public static boolean isMainThread(java.lang.Thread thread)
Tests if the given thread is currently set as the main thread.
thread
- the thread to test.isMainThread()
public static boolean isMainThread()
Tests if the current thread is currently set as the main thread.
public static java.lang.Thread getMainThread()
Retrieves the main thread. The main thread is the thread to which the main looper is attached. Defaults to the thread that initialises the RuntimeEnvironment class.
setMainThread(Thread)
,
isMainThread()
public static void setMainThread(java.lang.Thread newMainThread)
Sets the main thread. The main thread is the thread to which the main looper is attached. Defaults to the thread that initialises the RuntimeEnvironment class.
newMainThread
- the new main thread.setMainThread(Thread)
,
isMainThread()
public static java.lang.Object getActivityThread()
public static void setActivityThread(java.lang.Object newActivityThread)
public static java.lang.String getQualifiers()
Returns a qualifier string describing the current Configuration
of the system resources.
public static java.lang.String getQualifiers(android.content.res.Configuration configuration, android.util.DisplayMetrics displayMetrics)
Returns a qualifier string describing the given configuration and display metrics.
configuration
- the configuration.displayMetrics
- the display metrics.public static void setQualifiers(java.lang.String newQualifiers)
Overrides the current device configuration.
If newQualifiers
starts with a plus (+
), the prior configuration is used as the base configuration, with the given changes applied additively. Otherwise, default values are used for unspecified properties, as described here.
newQualifiers
- the qualifiers to applypublic static int getApiLevel()
public static java.lang.Number castNativePtr(long ptr)
public static Scheduler getMasterScheduler()
Retrieves the current master scheduler. This scheduler is always used by the main Looper
, and if the global scheduler option is set it is also used for the background scheduler and for all other Looper
s
see org.robolectric.Robolectric#getForegroundThreadScheduler()
see org.robolectric.Robolectric#getBackgroundThreadScheduler()
public static void setMasterScheduler(Scheduler masterScheduler)
Sets the current master scheduler. See getMasterScheduler()
for details. Note that this method is primarily intended to be called by the Robolectric core setup code. Changing the master scheduler during a test will have unpredictable results.
masterScheduler
- the new master scheduler.see org.robolectric.Robolectric#getForegroundThreadScheduler()
see org.robolectric.Robolectric#getBackgroundThreadScheduler()
public static void setSystemResourceTable(ResourceTable systemResourceTable)
public static void setAppResourceTable(ResourceTable appResourceTable)
public static ResourceTable getSystemResourceTable()
public static ResourceTable getAppResourceTable()
public static void setCompileTimeResourceTable(ResourceTable compileTimeResourceTable)
public static ResourceTable getCompileTimeResourceTable()
public static void setTempDirectory(TempDirectory tempDirectory)
public static TempDirectory getTempDirectory()
public static void setAndroidFrameworkJarPath(java.lang.String localArtifactPath)
public static java.lang.String getAndroidFrameworkJarPath()
@Deprecated public static boolean useLegacyResources()
Internal only.
@Deprecated public static void setUseLegacyResources(boolean useLegacyResources)
Internal only.