code: public static void ensureCurrentState(Service.STATE state,
                                          Service.STATE expectedState) {
      if (state != expectedState) {
        throw new IllegalStateException("For this operation, the " +
                                            "current service state must be "
                                            + expectedState
                                            + " instead of " + state);
      }
    }
docs: Verify that a service is in a given state.
  @param state the actual state a service is in
  @param expectedState the desired state
  @throws IllegalStateException if the service state is different from
  the desired state