Search in sources :

Example 1 with ImsExternalConnection

use of com.android.internal.telephony.imsphone.ImsExternalConnection in project packages_services_Telephony by Evolution-X.

the class PstnIncomingCallNotifier method addNewUnknownCall.

private void addNewUnknownCall(Connection connection) {
    Log.i(this, "addNewUnknownCall, connection is: %s", connection);
    if (!maybeSwapAnyWithUnknownConnection(connection)) {
        Log.i(this, "determined new connection is: %s", connection);
        Bundle extras = new Bundle();
        if (connection.getNumberPresentation() == TelecomManager.PRESENTATION_ALLOWED && !TextUtils.isEmpty(connection.getAddress())) {
            Uri uri = Uri.fromParts(PhoneAccount.SCHEME_TEL, connection.getAddress(), null);
            extras.putParcelable(TelecomManager.EXTRA_UNKNOWN_CALL_HANDLE, uri);
        }
        // being added.
        if (connection instanceof ImsExternalConnection) {
            ImsExternalConnection externalConnection = (ImsExternalConnection) connection;
            extras.putInt(ImsExternalCallTracker.EXTRA_IMS_EXTERNAL_CALL_ID, externalConnection.getCallId());
        }
        // Specifies the time the call was added. This is used by the dialer for analytics.
        extras.putLong(EXTRA_CALL_CREATED_TIME_MILLIS, SystemClock.elapsedRealtime());
        PhoneAccountHandle handle = findCorrectPhoneAccountHandle();
        if (handle == null) {
            try {
                connection.hangup();
            } catch (CallStateException e) {
            // connection already disconnected. Do nothing
            }
        } else {
            TelecomManager tm = mPhone.getContext().getSystemService(TelecomManager.class);
            tm.addNewUnknownCall(handle, extras);
        }
    } else {
        Log.i(this, "swapped an old connection, new one is: %s", connection);
    }
}
Also used : PhoneAccountHandle(android.telecom.PhoneAccountHandle) ImsExternalConnection(com.android.internal.telephony.imsphone.ImsExternalConnection) CallStateException(com.android.internal.telephony.CallStateException) Bundle(android.os.Bundle) Uri(android.net.Uri) TelecomManager(android.telecom.TelecomManager)

Example 2 with ImsExternalConnection

use of com.android.internal.telephony.imsphone.ImsExternalConnection in project packages_services_Telephony by Evolution-X.

the class PstnIncomingCallNotifier method maybeSwapWithUnknownConnection.

private boolean maybeSwapWithUnknownConnection(TelephonyConnection telephonyConnection, Connection unknown) {
    Connection original = telephonyConnection.getOriginalConnection();
    if (original != null && !original.isIncoming() && Objects.equals(original.getAddress(), unknown.getAddress())) {
        // to disconnect.
        if (unknown instanceof ImsExternalConnection && !(telephonyConnection.getOriginalConnection() instanceof ImsExternalConnection)) {
            Log.v(this, "maybeSwapWithUnknownConnection - not swapping regular connection " + "with external connection.");
            return false;
        }
        telephonyConnection.setOriginalConnection(unknown);
        // not supported.
        if (original instanceof ImsExternalConnection) {
            return true;
        }
        // call stuck in the call tracker preventing other calls from being placed.
        if (original.getCall() != null && original.getCall().getPhone() != null && original.getCall().getPhone() instanceof GsmCdmaPhone) {
            GsmCdmaPhone phone = (GsmCdmaPhone) original.getCall().getPhone();
            phone.getCallTracker().cleanupCalls();
            Log.i(this, "maybeSwapWithUnknownConnection - Invoking call tracker cleanup " + "for connection: " + original);
        }
        return true;
    }
    return false;
}
Also used : GsmCdmaPhone(com.android.internal.telephony.GsmCdmaPhone) ImsExternalConnection(com.android.internal.telephony.imsphone.ImsExternalConnection) ImsPhoneConnection(com.android.internal.telephony.imsphone.ImsPhoneConnection) ImsExternalConnection(com.android.internal.telephony.imsphone.ImsExternalConnection) Connection(com.android.internal.telephony.Connection)

Aggregations

ImsExternalConnection (com.android.internal.telephony.imsphone.ImsExternalConnection)2 Uri (android.net.Uri)1 Bundle (android.os.Bundle)1 PhoneAccountHandle (android.telecom.PhoneAccountHandle)1 TelecomManager (android.telecom.TelecomManager)1 CallStateException (com.android.internal.telephony.CallStateException)1 Connection (com.android.internal.telephony.Connection)1 GsmCdmaPhone (com.android.internal.telephony.GsmCdmaPhone)1 ImsPhoneConnection (com.android.internal.telephony.imsphone.ImsPhoneConnection)1