/**
   * Returns the [position]th call found in the call map with the specified state. TODO: Improve
   * this logic to sort by call time.
   */
public DialerCall getCallWithState(int state, int positionToFind) {
    DialerCall retval = null;
    int position = 0;
    for (DialerCall call : callById.values()) {
      if (call.getState() == state) {
        if (position >= positionToFind) {
          retval = call;
          break;
        } else {
          position++;
        }
      }
    }
    return retval;
  }
public DialerCall getCallWithState(int state, int positionToFind) {
DialerCall retval = null;
int position = 0;
for (DialerCall call : callById.values()) {
if (call.getState() == state) {
if (position >= positionToFind) {
retval = call;
break;
} else {
position++;
}
}
}
return retval;
}
public DialerCall getCallWithState(int state, int positionToFind) {
DialerCall retval = null;
int position = 0;
for (DialerCall call : callById.values()) {
if (call.getState() == state) {
if (position >= positionToFind) {
retval = call;
break;
} else {
position++;
}
}
}
return retval;
}
public DialerCall getCallWithState(int state, int positionToFind) {
DialerCall retval = null;
int position = 0;
for (DialerCall call : callById.values()) {
if (call.getState() == state) {
if (position >= positionToFind) {
retval = call;
break;
} else {
position++;
}
}
}
return retval;
}