Package org.robolectric.shadows
Class ShadowActivityManager
- java.lang.Object
-
- org.robolectric.shadows.ShadowActivityManager
-
@Implements(value=android.app.ActivityManager.class, looseSignatures=true) public class ShadowActivityManager extends Object
Shadow forActivityManager
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ShadowActivityManager.ApplicationExitInfoBuilder
Builder class forApplicationExitInfo
-
Constructor Summary
Constructors Constructor Description ShadowActivityManager()
-
Method Summary
-
-
-
Method Detail
-
__constructor__
@Implementation protected void __constructor__(Context context, Handler handler)
-
getMemoryClass
@Implementation protected int getMemoryClass()
-
isUserAMonkey
@Implementation protected static boolean isUserAMonkey()
-
getCurrentUser
@Implementation(minSdk=17) @HiddenApi protected static int getCurrentUser()
-
getRunningTasks
@Implementation protected List<ActivityManager.RunningTaskInfo> getRunningTasks(int maxNum)
-
getAppTasks
@Implementation(minSdk=21) protected List<ActivityManager.AppTask> getAppTasks()
For tests, returns the list ofActivityManager.AppTask
set usingsetAppTasks(List)
. Returns empty list if nothing is set.- Returns:
- List of current AppTask.
- See Also:
setAppTasks(List)
-
getRunningServices
@Implementation protected List<ActivityManager.RunningServiceInfo> getRunningServices(int maxNum)
-
getRunningAppProcesses
@Implementation protected List<ActivityManager.RunningAppProcessInfo> getRunningAppProcesses()
-
getMyMemoryState
@Implementation protected static void getMyMemoryState(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(UserHandle userHandle)
-
killBackgroundProcesses
@Implementation protected void killBackgroundProcesses(String packageName)
-
getMemoryInfo
@Implementation protected void getMemoryInfo(ActivityManager.MemoryInfo outInfo)
-
getDeviceConfigurationInfo
@Implementation protected ConfigurationInfo getDeviceConfigurationInfo()
-
setDeviceConfigurationInfo
public void setDeviceConfigurationInfo(ConfigurationInfo configurationInfo)
Sets theConfigurationInfo
returned byActivityManager.getDeviceConfigurationInfo()
, but has no effect otherwise.
-
setTasks
public void setTasks(List<ActivityManager.RunningTaskInfo> tasks)
- Parameters:
tasks
- List of running tasks.
-
setAppTasks
public void setAppTasks(List<ActivityManager.AppTask> appTasks)
Sets the values to be returned bygetAppTasks()
.- Parameters:
tasks
- List of app tasks.- See Also:
getAppTasks()
-
setServices
public void setServices(List<ActivityManager.RunningServiceInfo> services)
- Parameters:
services
- List of running services.
-
setProcesses
public void setProcesses(List<ActivityManager.RunningAppProcessInfo> processes)
- Parameters:
processes
- List of running processes.
-
getBackgroundPackage
public 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(ActivityManager.MemoryInfo memoryInfo)
- Parameters:
memoryInfo
- Set the application's memory info.
-
getService
@Implementation(minSdk=26) protected static IActivityManager getService()
-
isLowRamDevice
@Implementation(minSdk=19) protected boolean isLowRamDevice()
-
setIsLowRamDevice
public void setIsLowRamDevice(boolean isLowRamDevice)
Override the return value of isLowRamDevice().
-
addOnUidImportanceListener
@Implementation(minSdk=26) protected void addOnUidImportanceListener(Object listener, Object importanceCutpoint)
-
removeOnUidImportanceListener
@Implementation(minSdk=26) protected void removeOnUidImportanceListener(Object listener)
-
getPackageImportance
@Implementation(minSdk=23) protected int getPackageImportance(String packageName)
-
getUidImportance
@Implementation(minSdk=26) protected int getUidImportance(int uid)
-
setUidImportance
public void setUidImportance(int uid, int importance)
-
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 restriction state set bysetBackgroundRestricted(boolean)
.
-
setBackgroundRestricted
public void setBackgroundRestricted(boolean isBackgroundRestricted)
Sets the background restriction state reported byActivityManager.isBackgroundRestricted()
, but has no effect otherwise.
-
getHistoricalProcessExitReasons
@Implementation(minSdk=30) protected Object getHistoricalProcessExitReasons(Object packageName, Object pid, Object maxNum)
Returns the matchedApplicationExitInfo
added byaddApplicationExitInfo(java.lang.String, int, int, int)
.packageName
is ignored.
-
addApplicationExitInfo
@Deprecated public void addApplicationExitInfo(String processName, int pid, int reason, int status)
Deprecated.Prefer using overload withShadowActivityManager.ApplicationExitInfoBuilder
Adds anApplicationExitInfo
with the given information
-
addApplicationExitInfo
public void addApplicationExitInfo(Object info)
Adds givenApplicationExitInfo
, seeShadowActivityManager.ApplicationExitInfoBuilder
-
clearApplicationUserData
@Implementation protected boolean clearApplicationUserData(String packageName, IPackageDataObserver observer)
-
isApplicationUserDataCleared
public boolean isApplicationUserDataCleared()
Returns true after clearing application user data was requested by callingActivityManager.clearApplicationUserData()
.
-
-