Package org.robolectric.shadows
Class ShadowActivityManager
- java.lang.Object
-
- org.robolectric.shadows.ShadowActivityManager
-
@Implements(android.app.ActivityManager.class) public class ShadowActivityManager extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description ShadowActivityManager()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.util.List<android.app.ActivityManager.AppTask>getAppTasks()For tests, returns the list ofActivityManager.AppTaskset usingsetAppTasks(List).java.lang.StringgetBackgroundPackage()protected static intgetCurrentUser()protected android.content.pm.ConfigurationInfogetDeviceConfigurationInfo()protected intgetLockTaskModeState()protected intgetMemoryClass()protected voidgetMemoryInfo(android.app.ActivityManager.MemoryInfo outInfo)protected static voidgetMyMemoryState(android.app.ActivityManager.RunningAppProcessInfo inState)Returns information seeded bysetProcesses(java.util.List<android.app.ActivityManager.RunningAppProcessInfo>).protected java.util.List<android.app.ActivityManager.RunningAppProcessInfo>getRunningAppProcesses()protected java.util.List<android.app.ActivityManager.RunningServiceInfo>getRunningServices(int maxNum)protected java.util.List<android.app.ActivityManager.RunningTaskInfo>getRunningTasks(int maxNum)protected static android.app.IActivityManagergetService()protected booleanisBackgroundRestricted()Returns the background restricion state set bysetBackgroundRestricted(boolean).protected booleanisInLockTaskMode()protected booleanisLowRamDevice()protected static booleanisUserAMonkey()protected voidkillBackgroundProcesses(java.lang.String packageName)static voidreset()voidsetAppTasks(java.util.List<android.app.ActivityManager.AppTask> appTasks)Sets the values to be returned bygetAppTasks().voidsetBackgroundRestricted(boolean isBackgroundRestricted)Sets the background restriction state reported byActivityManager.isBackgroundRestricted(), but has no effect otherwise.voidsetIsLowRamDevice(boolean isLowRamDevice)Override the return value of isLowRamDevice().voidsetLockTaskModeState(int lockTaskModeState)Sets lock task mode state to be reported byActivityManager.getLockTaskModeState(), but has no effect otherwise.voidsetMemoryClass(int memoryClass)voidsetMemoryInfo(android.app.ActivityManager.MemoryInfo memoryInfo)voidsetProcesses(java.util.List<android.app.ActivityManager.RunningAppProcessInfo> processes)voidsetServices(java.util.List<android.app.ActivityManager.RunningServiceInfo> services)voidsetTasks(java.util.List<android.app.ActivityManager.RunningTaskInfo> tasks)protected booleanswitchUser(int userid)protected booleanswitchUser(android.os.UserHandle userHandle)
-
-
-
Method Detail
-
getMemoryClass
@Implementation protected int getMemoryClass()
-
isUserAMonkey
@Implementation protected static boolean isUserAMonkey()
-
getCurrentUser
@Implementation(minSdk=17) @HiddenApi protected static int getCurrentUser()
-
getRunningTasks
@Implementation protected java.util.List<android.app.ActivityManager.RunningTaskInfo> getRunningTasks(int maxNum)
-
getAppTasks
@Implementation(minSdk=21) protected java.util.List<android.app.ActivityManager.AppTask> getAppTasks()
For tests, returns the list ofActivityManager.AppTaskset usingsetAppTasks(List). Returns empty list if nothing is set.- Returns:
- List of current AppTask.
- See Also:
setAppTasks(List)
-
getRunningServices
@Implementation protected java.util.List<android.app.ActivityManager.RunningServiceInfo> getRunningServices(int maxNum)
-
getRunningAppProcesses
@Implementation protected java.util.List<android.app.ActivityManager.RunningAppProcessInfo> getRunningAppProcesses()
-
getMyMemoryState
@Implementation protected static void getMyMemoryState(android.app.ActivityManager.RunningAppProcessInfo inState)
Returns information seeded bysetProcesses(java.util.List<android.app.ActivityManager.RunningAppProcessInfo>).
-
switchUser
@HiddenApi @Implementation(minSdk=17) protected boolean switchUser(int userid)
-
switchUser
@Implementation(minSdk=29) protected boolean switchUser(android.os.UserHandle userHandle)
-
killBackgroundProcesses
@Implementation protected void killBackgroundProcesses(java.lang.String packageName)
-
getMemoryInfo
@Implementation protected void getMemoryInfo(android.app.ActivityManager.MemoryInfo outInfo)
-
getDeviceConfigurationInfo
@Implementation protected android.content.pm.ConfigurationInfo getDeviceConfigurationInfo()
-
setTasks
public void setTasks(java.util.List<android.app.ActivityManager.RunningTaskInfo> tasks)
- Parameters:
tasks- List of running tasks.
-
setAppTasks
public void setAppTasks(java.util.List<android.app.ActivityManager.AppTask> appTasks)
Sets the values to be returned bygetAppTasks().- Parameters:
tasks- List of app tasks.- See Also:
getAppTasks()
-
setServices
public void setServices(java.util.List<android.app.ActivityManager.RunningServiceInfo> services)
- Parameters:
services- List of running services.
-
setProcesses
public void setProcesses(java.util.List<android.app.ActivityManager.RunningAppProcessInfo> processes)
- Parameters:
processes- List of running processes.
-
getBackgroundPackage
public java.lang.String getBackgroundPackage()
- Returns:
- Get the package name of the last background processes killed.
-
setMemoryClass
public void setMemoryClass(int memoryClass)
- Parameters:
memoryClass- Set the application's memory class.
-
setMemoryInfo
public void setMemoryInfo(android.app.ActivityManager.MemoryInfo memoryInfo)
- Parameters:
memoryInfo- Set the application's memory info.
-
getService
@Implementation(minSdk=26) protected static android.app.IActivityManager getService()
-
isLowRamDevice
@Implementation(minSdk=19) protected boolean isLowRamDevice()
-
setIsLowRamDevice
public void setIsLowRamDevice(boolean isLowRamDevice)
Override the return value of isLowRamDevice().
-
getLockTaskModeState
@Implementation(minSdk=23) protected int getLockTaskModeState()
-
isInLockTaskMode
@Implementation(minSdk=21) protected boolean isInLockTaskMode()
-
setLockTaskModeState
public void setLockTaskModeState(int lockTaskModeState)
Sets lock task mode state to be reported byActivityManager.getLockTaskModeState(), but has no effect otherwise.
-
reset
@Resetter public static void reset()
-
isBackgroundRestricted
@Implementation(minSdk=28) protected boolean isBackgroundRestricted()
Returns the background restricion state set bysetBackgroundRestricted(boolean).
-
setBackgroundRestricted
public void setBackgroundRestricted(boolean isBackgroundRestricted)
Sets the background restriction state reported byActivityManager.isBackgroundRestricted(), but has no effect otherwise.
-
-