/** * Sets the new call state onto the call and performs some additional logic associated with * setting the state. */ private void setNewState(Call call, int newState, Connection connection) { Preconditions.checkState(call.getState() != newState); // When starting an outgoing call, we need to grab gateway information // for the call, if available, and set it. final RawGatewayInfo info = mCallGatewayManager.getGatewayInfo(connection); if (Call.State.isDialing(newState)) { if (!info.isEmpty()) { call.setGatewayNumber(info.getFormattedGatewayNumber()); call.setGatewayPackage(info.packageName); } } else if (!Call.State.isConnected(newState)) { mCallGatewayManager.clearGatewayData(connection); } call.setState(newState); }