@Override
 public String toString() {
   return String.format(
       "ConnectionRequest %s %s",
       mAddress == null ? Uri.EMPTY : Connection.toLogSafePhoneNumber(mAddress.toString()),
       mExtras == null ? "" : mExtras);
 }
  /**
   * This can be used by telecom to either create a new outgoing call or attach to an existing
   * incoming call. In either case, telecom will cycle through a set of services and call
   * createConnection util a connection service cancels the process or completes it successfully.
   */
  private void createConnection(
      final PhoneAccountHandle callManagerAccount,
      final String callId,
      final ConnectionRequest request,
      boolean isIncoming,
      boolean isUnknown) {
    Log.d(
        this,
        "createConnection, callManagerAccount: %s, callId: %s, request: %s, "
            + "isIncoming: %b, isUnknown: %b",
        callManagerAccount,
        callId,
        request,
        isIncoming,
        isUnknown);

    Connection connection =
        isUnknown
            ? onCreateUnknownConnection(callManagerAccount, request)
            : isIncoming
                ? onCreateIncomingConnection(callManagerAccount, request)
                : onCreateOutgoingConnection(callManagerAccount, request);
    Log.d(this, "createConnection, connection: %s", connection);
    if (connection == null) {
      connection = Connection.createFailedConnection(new DisconnectCause(DisconnectCause.ERROR));
    }

    if (connection.getState() != Connection.STATE_DISCONNECTED) {
      addConnection(callId, connection);
    }

    Uri address = connection.getAddress();
    String number = address == null ? "null" : address.getSchemeSpecificPart();
    Log.v(
        this,
        "createConnection, number: %s, state: %s, capabilities: %s",
        Connection.toLogSafePhoneNumber(number),
        Connection.stateToString(connection.getState()),
        Connection.capabilitiesToString(connection.getConnectionCapabilities()));

    Log.d(this, "createConnection, calling handleCreateConnectionSuccessful %s", callId);
    mAdapter.handleCreateConnectionComplete(
        callId,
        request,
        new ParcelableConnection(
            request.getAccountHandle(),
            connection.getState(),
            connection.getConnectionCapabilities(),
            connection.getAddress(),
            connection.getAddressPresentation(),
            connection.getCallerDisplayName(),
            connection.getCallerDisplayNamePresentation(),
            connection.getVideoProvider() == null
                ? null
                : connection.getVideoProvider().getInterface(),
            connection.getVideoState(),
            connection.isRingbackRequested(),
            connection.getAudioModeIsVoip(),
            connection.getStatusHints(),
            connection.getDisconnectCause(),
            createIdList(connection.getConferenceables())));
  }