shadows/framework/src/main/java/org/robolectric/shadows/ShadowPackageManager.java
public void addOrUpdateService(ServiceInfo serviceInfo) {
    addComponent(
        serviceFilters,
        p -> p.services,
        (p, a) -> p.services = a,
        new ServiceInfo(serviceInfo),
        true);
  }
public void addOrUpdateService(ServiceInfo serviceInfo) {
    addComponent(
        serviceFilters,
        p -> p.services,
        (p, a) -> p.services = a,
        new ServiceInfo(serviceInfo),
        true);
  }
Adds or updates given service in the system.

If service with the same {@link ComponentInfo#name} and {@code ComponentInfo#packageName}
exists it will be updated. Its {@link ComponentInfo#applicationInfo} is always set to {@link
ApplicationInfo} already existing in the system, but if no application exists a new one will be
created using {@link ComponentInfo#applicationInfo} in this component.