Search in sources :

Example 26 with ImsException

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

the class ImsPhoneCallTracker method hangup.

// ***** Called from ImsPhoneCall
public void hangup(ImsPhoneCall call) throws CallStateException {
    if (DBG)
        log("hangup call");
    if (call.getConnections().size() == 0) {
        throw new CallStateException("no connections");
    }
    ImsCall imsCall = call.getImsCall();
    boolean rejectCall = false;
    if (call == mRingingCall) {
        if (Phone.DEBUG_PHONE)
            log("(ringing) hangup incoming");
        rejectCall = true;
    } else if (call == mForegroundCall) {
        if (call.isDialingOrAlerting()) {
            if (Phone.DEBUG_PHONE) {
                log("(foregnd) hangup dialing or alerting...");
            }
        } else {
            if (Phone.DEBUG_PHONE) {
                log("(foregnd) hangup foreground");
            }
        // held call will be resumed by onCallTerminated
        }
    } else if (call == mBackgroundCall) {
        if (Phone.DEBUG_PHONE) {
            log("(backgnd) hangup waiting or background");
        }
    } else {
        throw new CallStateException("ImsPhoneCall " + call + "does not belong to ImsPhoneCallTracker " + this);
    }
    call.onHangupLocal();
    try {
        if (imsCall != null) {
            if (rejectCall) {
                imsCall.reject(ImsReasonInfo.CODE_USER_DECLINE);
                mMetrics.writeOnImsCommand(mPhone.getPhoneId(), imsCall.getSession(), ImsCommand.IMS_CMD_REJECT);
            } else {
                imsCall.terminate(ImsReasonInfo.CODE_USER_TERMINATED);
                mMetrics.writeOnImsCommand(mPhone.getPhoneId(), imsCall.getSession(), ImsCommand.IMS_CMD_TERMINATE);
            }
        } else if (mPendingMO != null && call == mForegroundCall) {
            // is holding a foreground call
            mPendingMO.update(null, ImsPhoneCall.State.DISCONNECTED);
            mPendingMO.onDisconnect();
            removeConnection(mPendingMO);
            mPendingMO = null;
            updatePhoneState();
            removeMessages(EVENT_DIAL_PENDINGMO);
        }
    } catch (ImsException e) {
        throw new CallStateException(e.getMessage());
    }
    mPhone.notifyPreciseCallStateChanged();
}
Also used : CallStateException(com.android.internal.telephony.CallStateException) ImsCall(com.android.ims.ImsCall) ImsException(com.android.ims.ImsException)

Example 27 with ImsException

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

the class ImsPhoneConnection method updateMediaCapabilities.

/**
 * Check for a change in the video capabilities and audio quality for the {@link ImsCall}, and
 * update the {@link ImsPhoneConnection} with this information.
 *
 * @param imsCall The call to check for changes in media capabilities.
 * @return Whether the media capabilities have been changed.
 */
public boolean updateMediaCapabilities(ImsCall imsCall) {
    if (imsCall == null) {
        return false;
    }
    boolean changed = false;
    try {
        // The actual call profile (negotiated between local and peer).
        ImsCallProfile negotiatedCallProfile = imsCall.getCallProfile();
        if (negotiatedCallProfile != null) {
            int oldVideoState = getVideoState();
            int newVideoState = ImsCallProfile.getVideoStateFromImsCallProfile(negotiatedCallProfile);
            if (oldVideoState != newVideoState) {
                // unpaused state, we will resume passing the video states from the modem as is.
                if (VideoProfile.isPaused(oldVideoState) && !VideoProfile.isPaused(newVideoState)) {
                    // Video entered un-paused state; recognize updates from now on; we want to
                    // ensure that the new un-paused state is propagated to Telecom, so change
                    // this now.
                    mShouldIgnoreVideoStateChanges = false;
                }
                if (!mShouldIgnoreVideoStateChanges) {
                    updateVideoState(newVideoState);
                    changed = true;
                } else {
                    Rlog.d(LOG_TAG, "updateMediaCapabilities - ignoring video state change " + "due to paused state.");
                }
                if (!VideoProfile.isPaused(oldVideoState) && VideoProfile.isPaused(newVideoState)) {
                    // Video entered pause state; ignore updates until un-paused.  We do this
                    // after setVideoState is called above to ensure Telecom is notified that
                    // the device has entered paused state.
                    mShouldIgnoreVideoStateChanges = true;
                }
            }
        }
        // Check for a change in the capabilities for the call and update
        // {@link ImsPhoneConnection} with this information.
        int capabilities = getConnectionCapabilities();
        // Use carrier config to determine if downgrading directly to audio-only is supported.
        if (mOwner.isCarrierDowngradeOfVtCallSupported()) {
            capabilities = addCapability(capabilities, Connection.Capability.SUPPORTS_DOWNGRADE_TO_VOICE_REMOTE | Capability.SUPPORTS_DOWNGRADE_TO_VOICE_LOCAL);
        } else {
            capabilities = removeCapability(capabilities, Connection.Capability.SUPPORTS_DOWNGRADE_TO_VOICE_REMOTE | Capability.SUPPORTS_DOWNGRADE_TO_VOICE_LOCAL);
        }
        // Get the current local call capabilities which might be voice or video or both.
        ImsCallProfile localCallProfile = imsCall.getLocalCallProfile();
        Rlog.v(LOG_TAG, "update localCallProfile=" + localCallProfile);
        if (localCallProfile != null) {
            capabilities = applyLocalCallCapabilities(localCallProfile, capabilities);
        }
        // Get the current remote call capabilities which might be voice or video or both.
        ImsCallProfile remoteCallProfile = imsCall.getRemoteCallProfile();
        Rlog.v(LOG_TAG, "update remoteCallProfile=" + remoteCallProfile);
        if (remoteCallProfile != null) {
            capabilities = applyRemoteCallCapabilities(remoteCallProfile, capabilities);
        }
        if (getConnectionCapabilities() != capabilities) {
            setConnectionCapabilities(capabilities);
            changed = true;
        }
        int newAudioQuality = getAudioQualityFromCallProfile(localCallProfile, remoteCallProfile);
        if (getAudioQuality() != newAudioQuality) {
            setAudioQuality(newAudioQuality);
            changed = true;
        }
    } catch (ImsException e) {
    // No session in place -- no change
    }
    return changed;
}
Also used : ImsCallProfile(com.android.ims.ImsCallProfile) ImsException(com.android.ims.ImsException)

Example 28 with ImsException

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

the class ImsPhoneMmiCode method onIcbQueryComplete.

private void onIcbQueryComplete(AsyncResult ar) {
    Rlog.d(LOG_TAG, "onIcbQueryComplete mmi=" + this);
    StringBuilder sb = new StringBuilder(getScString());
    sb.append("\n");
    if (ar.exception != null) {
        mState = State.FAILED;
        if (ar.exception instanceof ImsException) {
            ImsException error = (ImsException) ar.exception;
            if (error.getMessage() != null) {
                sb.append(error.getMessage());
            } else {
                sb.append(getErrorMessage(ar));
            }
        } else {
            sb.append(getErrorMessage(ar));
        }
    } else {
        ImsSsInfo[] infos = (ImsSsInfo[]) ar.result;
        if (infos.length == 0) {
            sb.append(mContext.getText(com.android.internal.R.string.serviceDisabled));
        } else {
            for (int i = 0, s = infos.length; i < s; i++) {
                if (infos[i].mIcbNum != null) {
                    sb.append("Num: " + infos[i].mIcbNum + " status: " + infos[i].mStatus + "\n");
                } else if (infos[i].mStatus == 1) {
                    sb.append(mContext.getText(com.android.internal.R.string.serviceEnabled));
                } else {
                    sb.append(mContext.getText(com.android.internal.R.string.serviceDisabled));
                }
            }
        }
        mState = State.COMPLETE;
    }
    mMessage = sb;
    mPhone.onMMIDone(this);
}
Also used : SpannableStringBuilder(android.text.SpannableStringBuilder) ImsSsInfo(com.android.ims.ImsSsInfo) ImsException(com.android.ims.ImsException)

Example 29 with ImsException

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

the class ImsPhoneMmiCode method onQueryClirComplete.

private void onQueryClirComplete(AsyncResult ar) {
    StringBuilder sb = new StringBuilder(getScString());
    sb.append("\n");
    mState = State.FAILED;
    if (ar.exception != null) {
        if (ar.exception instanceof ImsException) {
            ImsException error = (ImsException) ar.exception;
            if (error.getMessage() != null) {
                sb.append(error.getMessage());
            } else {
                sb.append(getErrorMessage(ar));
            }
        }
    } else {
        Bundle ssInfo = (Bundle) ar.result;
        int[] clirInfo = ssInfo.getIntArray(UT_BUNDLE_KEY_CLIR);
        // clirInfo[0] = The 'n' parameter from TS 27.007 7.7
        // clirInfo[1] = The 'm' parameter from TS 27.007 7.7
        Rlog.d(LOG_TAG, "onQueryClirComplete: CLIR param n=" + clirInfo[0] + " m=" + clirInfo[1]);
        // 'm' parameter.
        switch(clirInfo[1]) {
            case CLIR_NOT_PROVISIONED:
                sb.append(mContext.getText(com.android.internal.R.string.serviceNotProvisioned));
                mState = State.COMPLETE;
                break;
            case CLIR_PROVISIONED_PERMANENT:
                sb.append(mContext.getText(com.android.internal.R.string.CLIRPermanent));
                mState = State.COMPLETE;
                break;
            case CLIR_PRESENTATION_RESTRICTED_TEMPORARY:
                // 'n' parameter.
                switch(clirInfo[0]) {
                    case CLIR_DEFAULT:
                        sb.append(mContext.getText(com.android.internal.R.string.CLIRDefaultOnNextCallOn));
                        mState = State.COMPLETE;
                        break;
                    case CLIR_INVOCATION:
                        sb.append(mContext.getText(com.android.internal.R.string.CLIRDefaultOnNextCallOn));
                        mState = State.COMPLETE;
                        break;
                    case CLIR_SUPPRESSION:
                        sb.append(mContext.getText(com.android.internal.R.string.CLIRDefaultOnNextCallOff));
                        mState = State.COMPLETE;
                        break;
                    default:
                        sb.append(mContext.getText(com.android.internal.R.string.mmiError));
                        mState = State.FAILED;
                }
                break;
            case CLIR_PRESENTATION_ALLOWED_TEMPORARY:
                // 'n' parameter.
                switch(clirInfo[0]) {
                    case CLIR_DEFAULT:
                        sb.append(mContext.getText(com.android.internal.R.string.CLIRDefaultOffNextCallOff));
                        mState = State.COMPLETE;
                        break;
                    case CLIR_INVOCATION:
                        sb.append(mContext.getText(com.android.internal.R.string.CLIRDefaultOffNextCallOn));
                        mState = State.COMPLETE;
                        break;
                    case CLIR_SUPPRESSION:
                        sb.append(mContext.getText(com.android.internal.R.string.CLIRDefaultOffNextCallOff));
                        mState = State.COMPLETE;
                        break;
                    default:
                        sb.append(mContext.getText(com.android.internal.R.string.mmiError));
                        mState = State.FAILED;
                }
                break;
            default:
                sb.append(mContext.getText(com.android.internal.R.string.mmiError));
                mState = State.FAILED;
        }
    }
    mMessage = sb;
    Rlog.d(LOG_TAG, "onQueryClirComplete mmi=" + this);
    mPhone.onMMIDone(this);
}
Also used : SpannableStringBuilder(android.text.SpannableStringBuilder) Bundle(android.os.Bundle) ImsException(com.android.ims.ImsException)

Example 30 with ImsException

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

the class ImsPhoneMmiCode method onSuppSvcQueryComplete.

private void onSuppSvcQueryComplete(AsyncResult ar) {
    StringBuilder sb = new StringBuilder(getScString());
    sb.append("\n");
    if (ar.exception != null) {
        mState = State.FAILED;
        if (ar.exception instanceof ImsException) {
            ImsException error = (ImsException) ar.exception;
            if (error.getMessage() != null) {
                sb.append(error.getMessage());
            } else {
                sb.append(getErrorMessage(ar));
            }
        } else {
            sb.append(getErrorMessage(ar));
        }
    } else {
        mState = State.FAILED;
        ImsSsInfo ssInfo = null;
        if (ar.result instanceof Bundle) {
            Rlog.d(LOG_TAG, "onSuppSvcQueryComplete: Received CLIP/COLP/COLR Response.");
            // Response for CLIP, COLP and COLR queries.
            Bundle ssInfoResp = (Bundle) ar.result;
            ssInfo = (ImsSsInfo) ssInfoResp.getParcelable(UT_BUNDLE_KEY_SSINFO);
            if (ssInfo != null) {
                Rlog.d(LOG_TAG, "onSuppSvcQueryComplete: ImsSsInfo mStatus = " + ssInfo.mStatus);
                if (ssInfo.mStatus == ImsSsInfo.DISABLED) {
                    sb.append(mContext.getText(com.android.internal.R.string.serviceDisabled));
                    mState = State.COMPLETE;
                } else if (ssInfo.mStatus == ImsSsInfo.ENABLED) {
                    sb.append(mContext.getText(com.android.internal.R.string.serviceEnabled));
                    mState = State.COMPLETE;
                } else {
                    sb.append(mContext.getText(com.android.internal.R.string.mmiError));
                }
            } else {
                sb.append(mContext.getText(com.android.internal.R.string.mmiError));
            }
        } else {
            Rlog.d(LOG_TAG, "onSuppSvcQueryComplete: Received Call Barring Response.");
            // Response for Call Barring queries.
            int[] cbInfos = (int[]) ar.result;
            if (cbInfos[0] == 1) {
                sb.append(mContext.getText(com.android.internal.R.string.serviceEnabled));
                mState = State.COMPLETE;
            } else {
                sb.append(mContext.getText(com.android.internal.R.string.serviceDisabled));
                mState = State.COMPLETE;
            }
        }
    }
    mMessage = sb;
    Rlog.d(LOG_TAG, "onSuppSvcQueryComplete mmi=" + this);
    mPhone.onMMIDone(this);
}
Also used : SpannableStringBuilder(android.text.SpannableStringBuilder) Bundle(android.os.Bundle) ImsSsInfo(com.android.ims.ImsSsInfo) 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