Package org.robolectric.shadows
Class ShadowActivityManager
java.lang.Object
org.robolectric.shadows.ShadowActivityManager
Shadow for
ActivityManager
-
Nested Class Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
__constructor__
(Context context, Handler handler) void
addApplicationExitInfo
(Object info) Adds givenApplicationExitInfo
, seeShadowActivityManager.ApplicationExitInfoBuilder
void
addApplicationExitInfo
(String processName, int pid, int reason, int status) Deprecated.protected void
addOnUidImportanceListener
(Object listener, int importanceCutpoint) protected boolean
clearApplicationUserData
(String packageName, IPackageDataObserver observer) protected List<ActivityManager.AppTask>
For tests, returns the list ofActivityManager.AppTask
set usingsetAppTasks(List)
.protected static int
protected ConfigurationInfo
protected List<?>
getHistoricalProcessExitReasons
(String packageName, int pid, int maxNum) Returns the matchedApplicationExitInfo
added byaddApplicationExitInfo(java.lang.String, int, int, int)
.protected int
protected int
protected void
getMemoryInfo
(ActivityManager.MemoryInfo outInfo) protected static void
Returns information seeded bysetProcesses(java.util.List<android.app.ActivityManager.RunningAppProcessInfo>)
.protected int
getPackageImportance
(String packageName) protected List<ActivityManager.RecentTaskInfo>
getRecentTasks
(int maxNum, int flags) For tests, returns the list ofActivityManager.RecentTaskInfo
set usingsetAppTasks(List)
with at mostmaxNum
tasks.protected List<ActivityManager.RunningAppProcessInfo>
protected List<ActivityManager.RunningServiceInfo>
getRunningServices
(int maxNum) protected List<ActivityManager.RunningTaskInfo>
getRunningTasks
(int maxNum) protected static IActivityManager
protected int
getUidImportance
(int uid) boolean
Returns true after clearing application user data was requested by callingActivityManager.clearApplicationUserData()
.protected boolean
Returns the background restriction state set bysetBackgroundRestricted(boolean)
.protected boolean
protected boolean
protected static boolean
protected void
killBackgroundProcesses
(String packageName) protected void
removeOnUidImportanceListener
(Object listener) static void
reset()
void
setAppTasks
(List<ActivityManager.AppTask> appTasks) Sets the values to be returned bygetAppTasks()
.void
setBackgroundRestricted
(boolean isBackgroundRestricted) Sets the background restriction state reported byActivityManager.isBackgroundRestricted()
, but has no effect otherwise.void
setDeviceConfigurationInfo
(ConfigurationInfo configurationInfo) Sets theConfigurationInfo
returned byActivityManager.getDeviceConfigurationInfo()
, but has no effect otherwise.void
setIsLowRamDevice
(boolean isLowRamDevice) Override the return value of isLowRamDevice().void
setLockTaskModeState
(int lockTaskModeState) Sets lock task mode state to be reported byActivityManager.getLockTaskModeState()
, but has no effect otherwise.void
setMemoryClass
(int memoryClass) void
setMemoryInfo
(ActivityManager.MemoryInfo memoryInfo) void
setProcesses
(List<ActivityManager.RunningAppProcessInfo> processes) void
setRecentTasks
(List<ActivityManager.RecentTaskInfo> recentTasks) Sets the values to be returned by#getRecentTasks()
.void
setServices
(List<ActivityManager.RunningServiceInfo> services) void
void
setUidImportance
(int uid, int importance) protected boolean
switchUser
(int userid) protected boolean
switchUser
(UserHandle userHandle)
-
Constructor Details
-
ShadowActivityManager
public ShadowActivityManager()
-
-
Method Details
-
__constructor__
-
getMemoryClass
-
isUserAMonkey
-
getCurrentUser
-
getRunningTasks
-
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:
-
getRecentTasks
@Implementation protected List<ActivityManager.RecentTaskInfo> getRecentTasks(int maxNum, int flags) For tests, returns the list ofActivityManager.RecentTaskInfo
set usingsetAppTasks(List)
with at mostmaxNum
tasks. Returns empty list if nothing is setflags
is ignored.- Returns:
- List of current AppTask.
- See Also:
-
getRunningServices
-
getRunningAppProcesses
-
getMyMemoryState
@Implementation protected static void getMyMemoryState(ActivityManager.RunningAppProcessInfo inState) Returns information seeded bysetProcesses(java.util.List<android.app.ActivityManager.RunningAppProcessInfo>)
. -
switchUser
-
switchUser
-
killBackgroundProcesses
-
getMemoryInfo
-
getDeviceConfigurationInfo
-
setDeviceConfigurationInfo
Sets theConfigurationInfo
returned byActivityManager.getDeviceConfigurationInfo()
, but has no effect otherwise. -
setTasks
- Parameters:
tasks
- List of running tasks.
-
setAppTasks
Sets the values to be returned bygetAppTasks()
.- Parameters:
appTasks
- List of app tasks.- See Also:
-
setRecentTasks
Sets the values to be returned by#getRecentTasks()
.- Parameters:
recentTasks
- List of recent tasks.- See Also:
-
#getRecentTasks()
-
setServices
- Parameters:
services
- List of running services.
-
setProcesses
- Parameters:
processes
- List of running processes.
-
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
- Parameters:
memoryInfo
- Set the application's memory info.
-
getService
-
isLowRamDevice
-
setIsLowRamDevice
public void setIsLowRamDevice(boolean isLowRamDevice) Override the return value of isLowRamDevice(). -
addOnUidImportanceListener
@Implementation(minSdk=26) protected void addOnUidImportanceListener(Object listener, int importanceCutpoint) -
removeOnUidImportanceListener
-
getPackageImportance
-
getUidImportance
-
setUidImportance
public void setUidImportance(int uid, int importance) -
getLockTaskModeState
-
isInLockTaskMode
-
setLockTaskModeState
public void setLockTaskModeState(int lockTaskModeState) Sets lock task mode state to be reported byActivityManager.getLockTaskModeState()
, but has no effect otherwise. -
reset
-
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 List<?> getHistoricalProcessExitReasons(String packageName, int pid, int maxNum) Returns the matchedApplicationExitInfo
added byaddApplicationExitInfo(java.lang.String, int, int, int)
.packageName
is ignored. -
addApplicationExitInfo
@Deprecated @RequiresApi(api=30) public void addApplicationExitInfo(String processName, int pid, int reason, int status) Deprecated.Prefer using overload withShadowActivityManager.ApplicationExitInfoBuilder
Adds anApplicationExitInfo
with the given information -
addApplicationExitInfo
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()
.
-
ShadowActivityManager.ApplicationExitInfoBuilder