Package org.robolectric.shadows
Class ShadowRoleManager
java.lang.Object
org.robolectric.shadows.ShadowRoleManager
@Implements(value=android.app.role.RoleManager.class,
minSdk=29)
public class ShadowRoleManager
extends Object
A shadow implementation of
RoleManager.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void__constructor__(Context context) protected void__constructor__(Context context, IRoleManager service) voidaddAvailableRole(String roleName) Add a role that will be recognized as available when invokingRoleManager.isRoleAvailable(String).voidaddHeldRole(String roleName) Add a role that would be held by the calling app when invokingRoleManager.isRoleHeld(String).protected StringgetDefaultApplication(String roleName) protected booleanisRoleAvailable(String roleName) Check whether a particular role is available on the device.protected booleanisRoleHeld(String roleName) Check whether the calling application is holding a particular role.voidremoveAvailableRole(String roleName) voidremoveHeldRole(String roleName) static voidreset()protected voidsetDefaultApplication(String roleName, String packageName, int flags, Executor executor, Consumer<Boolean> callback)
-
Field Details
-
roleManager
-
-
Constructor Details
-
ShadowRoleManager
public ShadowRoleManager()
-
-
Method Details
-
__constructor__
-
__constructor__
-
isRoleHeld
Check whether the calling application is holding a particular role.Callers can add held roles via
addHeldRole(String)- Parameters:
roleName- the name of the role to check for- Returns:
- whether the calling application is holding the role
-
addHeldRole
Add a role that would be held by the calling app when invokingRoleManager.isRoleHeld(String).This method makes the role available as well.
-
removeHeldRole
-
isRoleAvailable
Check whether a particular role is available on the device.Ideally available roles would be autodetected based on the state of other services or features present, but for now callers can add available roles via
addAvailableRole(String).- Parameters:
roleName- the name of the role to check for- Returns:
- whether the role is available
-
addAvailableRole
Add a role that will be recognized as available when invokingRoleManager.isRoleAvailable(String). -
removeAvailableRole
-
getDefaultApplication
-
setDefaultApplication
-
reset
-