Package org.robolectric.shadows
Class ShadowActivityManager
java.lang.Object
org.robolectric.shadows.ShadowActivityManager
Shadow for
ActivityManager-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void__constructor__(Context context, Handler handler) voidaddApplicationExitInfo(Object info) Adds givenApplicationExitInfo, seeShadowActivityManager.ApplicationExitInfoBuildervoidaddApplicationExitInfo(String processName, int pid, int reason, int status) Deprecated.protected voidaddOnUidImportanceListener(Object listener, int importanceCutpoint) protected booleanclearApplicationUserData(String packageName, IPackageDataObserver observer) protected List<ActivityManager.AppTask> For tests, returns the list ofActivityManager.AppTaskset usingsetAppTasks(List).protected static intprotected ConfigurationInfoGets the values set bysetDeviceLocales(LocaleList).protected List<?> getHistoricalProcessExitReasons(String packageName, int pid, int maxNum) Returns the matchedApplicationExitInfoadded byaddApplicationExitInfo(java.lang.String, int, int, int).protected intprotected intprotected voidgetMemoryInfo(ActivityManager.MemoryInfo outInfo) protected static voidReturns information seeded bysetProcesses(java.util.List<android.app.ActivityManager.RunningAppProcessInfo>).protected intgetPackageImportance(String packageName) protected List<ActivityManager.RecentTaskInfo> getRecentTasks(int maxNum, int flags) For tests, returns the list ofActivityManager.RecentTaskInfoset usingsetAppTasks(List)with at mostmaxNumtasks.protected List<ActivityManager.RunningAppProcessInfo> protected List<ActivityManager.RunningServiceInfo> getRunningServices(int maxNum) protected List<ActivityManager.RunningTaskInfo> getRunningTasks(int maxNum) protected static IActivityManagerprotected intgetUidImportance(int uid) booleanReturns true after clearing application user data was requested by callingActivityManager.clearApplicationUserData().protected booleanReturns the background restriction state set bysetBackgroundRestricted(boolean).protected booleanprotected booleanprotected static booleanprotected voidkillBackgroundProcesses(String packageName) protected voidremoveOnUidImportanceListener(Object listener) static voidreset()voidsetAppTasks(List<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.voidsetDeviceConfigurationInfo(ConfigurationInfo configurationInfo) Sets theConfigurationInforeturned byActivityManager.getDeviceConfigurationInfo(), but has no effect otherwise.protected voidsetDeviceLocales(LocaleList locales) Sets the current locales of the device.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(ActivityManager.MemoryInfo memoryInfo) voidsetProcesses(List<ActivityManager.RunningAppProcessInfo> processes) voidsetRecentTasks(List<ActivityManager.RecentTaskInfo> recentTasks) Sets the values to be returned bygetRecentTasks(int, int).voidsetServices(List<ActivityManager.RunningServiceInfo> services) voidvoidsetUidImportance(int uid, int importance) protected booleanswitchUser(int userid) protected booleanswitchUser(UserHandle userHandle)
-
Constructor Details
-
ShadowActivityManager
public ShadowActivityManager()
-
-
Method Details
-
__constructor__
-
getMemoryClass
-
isUserAMonkey
-
getCurrentUser
-
getRunningTasks
-
getAppTasks
For tests, returns the list ofActivityManager.AppTaskset 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.RecentTaskInfoset usingsetAppTasks(List)with at mostmaxNumtasks. Returns empty list if nothing is setflagsis ignored.- Returns:
- List of current AppTask.
- See Also:
-
setDeviceLocales
Sets the current locales of the device. If the input isnull, sets theLocale.ENGLISHas default locale. -
getDeviceLocales
Gets the values set bysetDeviceLocales(LocaleList).- Returns:
- an
LocaleListobject contains the current locales.
-
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 theConfigurationInforeturned 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 bygetRecentTasks(int, int).- Parameters:
recentTasks- List of recent tasks.- See Also:
-
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 matchedApplicationExitInfoadded byaddApplicationExitInfo(java.lang.String, int, int, int).packageNameis ignored. -
addApplicationExitInfo
@Deprecated @RequiresApi(api=30) public void addApplicationExitInfo(String processName, int pid, int reason, int status) Deprecated.Prefer using overload withShadowActivityManager.ApplicationExitInfoBuilderAdds anApplicationExitInfowith 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