@Override
  public synchronized void onServiceConnected(ComponentName name, IBinder service) {
    if (wasUnbound()) {
      Log.w(TAG, "Connection have been used already.");
      return;
    }

    binder = IRemoteJobService.Stub.asInterface(service);
    Set<JobInvocation> startedJobs = new HashSet<>();
    for (Entry<JobInvocation, Boolean> entry : jobStatuses.entrySet()) {
      if (Boolean.FALSE.equals(entry.getValue())) {
        try {
          binder.start(encodeJob(entry.getKey()), callback);
          startedJobs.add(entry.getKey());
        } catch (RemoteException remoteException) {
          Log.e(TAG, "Failed to start job " + entry.getKey(), remoteException);
          unbind();
          // TODO(user) notify a driver about the fail and release a wakelock.
          return;
        }
      }
    }

    // Mark jobs as started.
    for (JobInvocation invocation : startedJobs) {
      jobStatuses.put(invocation, true);
    }
  }
A map of {@link JobInvocation job} to running state.
jobdispatcher/src/main/java/com/firebase/jobdispatcher/JobServiceConnection.java