Class ShadowOverlayManager

java.lang.Object
org.robolectric.shadows.ShadowOverlayManager

@Implements(value=android.content.om.OverlayManager.class, minSdk=34, isInAndroidSdk=false) public final class ShadowOverlayManager extends Object
Basic shadow implementation for the OverlayManager.

This shadow exists because the overlays managed by the OverlayManager require set up at the Android base image level. This is not something that can exist for host level unit tests.

To simulate the image configuration, unit tests must call the addOverlayInfo(android.content.om.OverlayInfo) function to define the available overlays.

This basic shadow only implements the getOverlayInfo(java.lang.String,android.os.UserHandle) and setEnabled(java.lang.String,boolean,android.os.UserHandle) functions, enabling a basic workflow for enabling or disabling Runtime Resource Overlays (RROs). It enforces the android.permissions.CHANGE_OVERLAY_PACKAGES permission.

It does not validate the android.permission.INTERACT_ACROSS_USERS or android.INTERACT_ACROSS_USERS_FULL permissions, which are necessary when changing packages owned by a different user.

  • Constructor Details

    • ShadowOverlayManager

      public ShadowOverlayManager()
  • Method Details

    • addOverlayInfo

      public void addOverlayInfo(OverlayInfo overlayInfo)
      Adds or replaces the overlay based on the packageName. Expected to be used by unit tests to setup the expected overlays.
    • removeOverlayInfo

      public void removeOverlayInfo(String packageName)
      Removes an overlay with the specified packageName if it is present. If not present, nothing happens.
    • getOverlayInfo

      @Implementation protected OverlayInfo getOverlayInfo(String packageName, UserHandle userHandle)
    • setEnabled

      @Implementation protected void setEnabled(String packageName, boolean enable, UserHandle user)