@VisibleForTesting
  List<String> validateService(String service) {
    if (service == null || service.isEmpty()) {
      return getMutableSingletonList("Service can't be empty");
    }

    if (context == null) {
      return getMutableSingletonList("Context is null, can't query PackageManager");
    }

    PackageManager pm = context.getPackageManager();
    if (pm == null) {
      return getMutableSingletonList("PackageManager is null, can't validate service");
    }

    Intent executeIntent = new Intent(JobService.ACTION_EXECUTE);
    executeIntent.setClassName(context, service);
    List<ResolveInfo> intentServices = pm.queryIntentServices(executeIntent, 0);
    if (intentServices == null || intentServices.isEmpty()) {
      // queryIntentServices might incorrectly return an empty list.
      String msg =
          "Couldn't find a registered service with the name "
              + service
              + ". Is it declared in the manifest with the right intent-filter?"
              + " If not, the job won't be started.";
      Log.e(TAG, msg);
      return null;
    }

    for (ResolveInfo info : intentServices) {
      if (info.serviceInfo != null && info.serviceInfo.enabled) {
        // found a match!
        return null;
      }
    }

    return getMutableSingletonList(service + " is disabled.");
  }
Attempts to validate the provided RetryStrategy. If valid, null is returned. Otherwise a list
of errors will be returned.
jobdispatcher/src/main/java/com/firebase/jobdispatcher/DefaultJobValidator.java