Search in sources :

Example 11 with ImsException

use of com.android.ims.ImsException in project android_frameworks_opt_telephony by LineageOS.

the class ImsPhoneCallTracker method conference.

public void conference() {
    ImsCall fgImsCall = mForegroundCall.getImsCall();
    if (fgImsCall == null) {
        log("conference no foreground ims call");
        return;
    }
    ImsCall bgImsCall = mBackgroundCall.getImsCall();
    if (bgImsCall == null) {
        log("conference no background ims call");
        return;
    }
    if (fgImsCall.isCallSessionMergePending()) {
        log("conference: skip; foreground call already in process of merging.");
        return;
    }
    if (bgImsCall.isCallSessionMergePending()) {
        log("conference: skip; background call already in process of merging.");
        return;
    }
    // Keep track of the connect time of the earliest call so that it can be set on the
    // {@code ImsConference} when it is created.
    long foregroundConnectTime = mForegroundCall.getEarliestConnectTime();
    long backgroundConnectTime = mBackgroundCall.getEarliestConnectTime();
    long conferenceConnectTime;
    if (foregroundConnectTime > 0 && backgroundConnectTime > 0) {
        conferenceConnectTime = Math.min(mForegroundCall.getEarliestConnectTime(), mBackgroundCall.getEarliestConnectTime());
        log("conference - using connect time = " + conferenceConnectTime);
    } else if (foregroundConnectTime > 0) {
        log("conference - bg call connect time is 0; using fg = " + foregroundConnectTime);
        conferenceConnectTime = foregroundConnectTime;
    } else {
        log("conference - fg call connect time is 0; using bg = " + backgroundConnectTime);
        conferenceConnectTime = backgroundConnectTime;
    }
    String foregroundId = "";
    ImsPhoneConnection foregroundConnection = mForegroundCall.getFirstConnection();
    if (foregroundConnection != null) {
        foregroundConnection.setConferenceConnectTime(conferenceConnectTime);
        foregroundConnection.handleMergeStart();
        foregroundId = foregroundConnection.getTelecomCallId();
    }
    String backgroundId = "";
    ImsPhoneConnection backgroundConnection = findConnection(bgImsCall);
    if (backgroundConnection != null) {
        backgroundConnection.handleMergeStart();
        backgroundId = backgroundConnection.getTelecomCallId();
    }
    log("conference: fgCallId=" + foregroundId + ", bgCallId=" + backgroundId);
    try {
        fgImsCall.merge(bgImsCall);
    } catch (ImsException e) {
        log("conference " + e.getMessage());
    }
}
Also used : ImsCall(com.android.ims.ImsCall) ImsException(com.android.ims.ImsException)

Example 12 with ImsException

use of com.android.ims.ImsException in project android_frameworks_opt_telephony by LineageOS.

the class ImsPhoneCallTracker method dialInternal.

private void dialInternal(ImsPhoneConnection conn, int clirMode, int videoState, Bundle intentExtras) {
    if (conn == null) {
        return;
    }
    if (conn.getAddress() == null || conn.getAddress().length() == 0 || conn.getAddress().indexOf(PhoneNumberUtils.WILD) >= 0) {
        // Phone number is invalid
        conn.setDisconnectCause(DisconnectCause.INVALID_NUMBER);
        sendEmptyMessageDelayed(EVENT_HANGUP_PENDINGMO, TIMEOUT_HANGUP_PENDINGMO);
        return;
    }
    // Always unmute when initiating a new call
    setMute(false);
    int serviceType = mPhoneNumberUtilsProxy.isEmergencyNumber(conn.getAddress()) ? ImsCallProfile.SERVICE_TYPE_EMERGENCY : ImsCallProfile.SERVICE_TYPE_NORMAL;
    int callType = ImsCallProfile.getCallTypeFromVideoState(videoState);
    // TODO(vt): Is this sufficient?  At what point do we know the video state of the call?
    conn.setVideoState(videoState);
    try {
        String[] callees = new String[] { conn.getAddress() };
        ImsCallProfile profile = mImsManager.createCallProfile(mServiceId, serviceType, callType);
        profile.setCallExtraInt(ImsCallProfile.EXTRA_OIR, clirMode);
        // ImsCallProfile key.
        if (intentExtras != null) {
            if (intentExtras.containsKey(android.telecom.TelecomManager.EXTRA_CALL_SUBJECT)) {
                intentExtras.putString(ImsCallProfile.EXTRA_DISPLAY_TEXT, cleanseInstantLetteringMessage(intentExtras.getString(android.telecom.TelecomManager.EXTRA_CALL_SUBJECT)));
            }
            if (intentExtras.containsKey(ImsCallProfile.EXTRA_IS_CALL_PULL)) {
                profile.mCallExtras.putBoolean(ImsCallProfile.EXTRA_IS_CALL_PULL, intentExtras.getBoolean(ImsCallProfile.EXTRA_IS_CALL_PULL));
                int dialogId = intentExtras.getInt(ImsExternalCallTracker.EXTRA_IMS_EXTERNAL_CALL_ID);
                conn.setIsPulledCall(true);
                conn.setPulledDialogId(dialogId);
            }
            // Pack the OEM-specific call extras.
            profile.mCallExtras.putBundle(ImsCallProfile.EXTRA_OEM_EXTRAS, intentExtras);
        // NOTE: Extras to be sent over the network are packed into the
        // intentExtras individually, with uniquely defined keys.
        // These key-value pairs are processed by IMS Service before
        // being sent to the lower layers/to the network.
        }
        ImsCall imsCall = mImsManager.makeCall(mServiceId, profile, callees, mImsCallListener);
        conn.setImsCall(imsCall);
        mMetrics.writeOnImsCallStart(mPhone.getPhoneId(), imsCall.getSession());
        setVideoCallProvider(conn, imsCall);
        conn.setAllowAddCallDuringVideoCall(mAllowAddCallDuringVideoCall);
    } catch (ImsException e) {
        loge("dialInternal : " + e);
        conn.setDisconnectCause(DisconnectCause.ERROR_UNSPECIFIED);
        sendEmptyMessageDelayed(EVENT_HANGUP_PENDINGMO, TIMEOUT_HANGUP_PENDINGMO);
        retryGetImsService();
    } catch (RemoteException e) {
    }
}
Also used : ImsCallProfile(com.android.ims.ImsCallProfile) ImsCall(com.android.ims.ImsCall) ImsException(com.android.ims.ImsException) RemoteException(android.os.RemoteException) ImsMultiEndpoint(com.android.ims.ImsMultiEndpoint)

Example 13 with ImsException

use of com.android.ims.ImsException in project android_frameworks_opt_telephony by LineageOS.

the class ImsPhone method getCallForwardingOption.

@Override
public void getCallForwardingOption(int commandInterfaceCFReason, Message onComplete) {
    if (DBG)
        Rlog.d(LOG_TAG, "getCallForwardingOption reason=" + commandInterfaceCFReason);
    if (isValidCommandInterfaceCFReason(commandInterfaceCFReason)) {
        if (DBG)
            Rlog.d(LOG_TAG, "requesting call forwarding query.");
        Message resp;
        resp = obtainMessage(EVENT_GET_CALL_FORWARD_DONE, onComplete);
        try {
            ImsUtInterface ut = mCT.getUtInterface();
            ut.queryCallForward(getConditionFromCFReason(commandInterfaceCFReason), null, resp);
        } catch (ImsException e) {
            sendErrorResponse(onComplete, e);
        }
    } else if (onComplete != null) {
        sendErrorResponse(onComplete);
    }
}
Also used : Message(android.os.Message) ImsUtInterface(com.android.ims.ImsUtInterface) ImsException(com.android.ims.ImsException)

Example 14 with ImsException

use of com.android.ims.ImsException in project android_frameworks_opt_telephony by LineageOS.

the class ImsPhone method getCallWaiting.

@Override
public void getCallWaiting(Message onComplete) {
    if (DBG)
        Rlog.d(LOG_TAG, "getCallWaiting");
    Message resp;
    resp = obtainMessage(EVENT_GET_CALL_WAITING_DONE, onComplete);
    try {
        ImsUtInterface ut = mCT.getUtInterface();
        ut.queryCallWaiting(resp);
    } catch (ImsException e) {
        sendErrorResponse(onComplete, e);
    }
}
Also used : Message(android.os.Message) ImsUtInterface(com.android.ims.ImsUtInterface) ImsException(com.android.ims.ImsException)

Example 15 with ImsException

use of com.android.ims.ImsException in project android_frameworks_opt_telephony by LineageOS.

the class ImsPhoneCallTracker method sendUSSD.

public void sendUSSD(String ussdString, Message response) {
    if (DBG)
        log("sendUSSD");
    try {
        if (mUssdSession != null) {
            mUssdSession.sendUssd(ussdString);
            AsyncResult.forMessage(response, null, null);
            response.sendToTarget();
            return;
        }
        if (mImsManager == null) {
            mPhone.sendErrorResponse(response, getImsManagerIsNullException());
            return;
        }
        String[] callees = new String[] { ussdString };
        ImsCallProfile profile = mImsManager.createCallProfile(mServiceId, ImsCallProfile.SERVICE_TYPE_NORMAL, ImsCallProfile.CALL_TYPE_VOICE);
        profile.setCallExtraInt(ImsCallProfile.EXTRA_DIALSTRING, ImsCallProfile.DIALSTRING_USSD);
        mUssdSession = mImsManager.makeCall(mServiceId, profile, callees, mImsUssdListener);
    } catch (ImsException e) {
        loge("sendUSSD : " + e);
        mPhone.sendErrorResponse(response, e);
        retryGetImsService();
    }
}
Also used : ImsCallProfile(com.android.ims.ImsCallProfile) ImsException(com.android.ims.ImsException)

Aggregations

ImsException (com.android.ims.ImsException)37 Message (android.os.Message)9 ImsUtInterface (com.android.ims.ImsUtInterface)8 ImsCall (com.android.ims.ImsCall)7 ImsConfig (com.android.ims.ImsConfig)7 SpannableStringBuilder (android.text.SpannableStringBuilder)6 CallStateException (com.android.internal.telephony.CallStateException)6 ImsCallProfile (com.android.ims.ImsCallProfile)4 Context (android.content.Context)3 PendingIntent (android.app.PendingIntent)2 Bundle (android.os.Bundle)2 FlakyTest (android.support.test.filters.FlakyTest)2 SmallTest (android.test.suitebuilder.annotation.SmallTest)2 ImsConnectionStateListener (com.android.ims.ImsConnectionStateListener)2 ImsSsInfo (com.android.ims.ImsSsInfo)2 CommandException (com.android.internal.telephony.CommandException)2 TelephonyTest (com.android.internal.telephony.TelephonyTest)2 Test (org.junit.Test)2 Intent (android.content.Intent)1 AsyncResult (android.os.AsyncResult)1