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 Details

  • Constructor Details

    • ShadowRoleManager

      public ShadowRoleManager()
  • Method Details

    • __constructor__

      @Implementation(maxSdk=30) protected void __constructor__(Context context)
    • __constructor__

      @Implementation(minSdk=31) protected void __constructor__(Context context, IRoleManager service)
    • isRoleHeld

      @Implementation protected boolean isRoleHeld(String roleName)
      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

      public void addHeldRole(String roleName)
      Add a role that would be held by the calling app when invoking RoleManager.isRoleHeld(String).

      This method makes the role available as well.

    • removeHeldRole

      public void removeHeldRole(String roleName)
    • isRoleAvailable

      @Implementation protected boolean isRoleAvailable(String roleName)
      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

      public void addAvailableRole(String roleName)
      Add a role that will be recognized as available when invoking RoleManager.isRoleAvailable(String).
    • removeAvailableRole

      public void removeAvailableRole(String roleName)
    • getDefaultApplication

      @Implementation(minSdk=34) protected String getDefaultApplication(String roleName)
    • setDefaultApplication

      @Implementation(minSdk=34) protected void setDefaultApplication(String roleName, String packageName, int flags, Executor executor, Consumer<Boolean> callback)
    • reset

      @Resetter public static void reset()