Search in sources :

Example 6 with ImsCall

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

the class ImsPhoneCallTracker method canAddVideoCallDuringImsAudioCall.

private boolean canAddVideoCallDuringImsAudioCall(int videoState) {
    if (mAllowHoldingVideoCall) {
        return true;
    }
    ImsCall call = mForegroundCall.getImsCall();
    if (call == null) {
        call = mBackgroundCall.getImsCall();
    }
    boolean isImsAudioCallActiveOrHolding = (mForegroundCall.getState() == Call.State.ACTIVE || mBackgroundCall.getState() == Call.State.HOLDING) && call != null && !call.isVideoCall();
    /* return TRUE if there doesn't exist ims audio call in either active
           or hold states */
    return !isImsAudioCallActiveOrHolding || !VideoProfile.isVideo(videoState);
}
Also used : ImsCall(com.android.ims.ImsCall)

Example 7 with ImsCall

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

the class ImsPhoneCallTracker method downgradeVideoCall.

/**
 * Handles downgrading a video call.  The behavior depends on carrier capabilities; we will
 * attempt to take one of the following actions (in order of precedence):
 * 1. If supported by the carrier, the call will be downgraded to an audio-only call.
 * 2. If the carrier supports video pause signalling, the video will be paused.
 * 3. The call will be disconnected.
 * @param reasonCode The {@link ImsReasonInfo} reason code for the downgrade.
 * @param conn The {@link ImsPhoneConnection} to downgrade.
 */
private void downgradeVideoCall(int reasonCode, ImsPhoneConnection conn) {
    ImsCall imsCall = conn.getImsCall();
    if (imsCall != null) {
        if (conn.hasCapabilities(Connection.Capability.SUPPORTS_DOWNGRADE_TO_VOICE_LOCAL | Connection.Capability.SUPPORTS_DOWNGRADE_TO_VOICE_REMOTE) && !mSupportPauseVideo) {
            log("downgradeVideoCall :: callId=" + conn.getTelecomCallId() + " Downgrade to audio");
            // If the carrier supports downgrading to voice, then we can simply issue a
            // downgrade to voice instead of terminating the call.
            modifyVideoCall(imsCall, VideoProfile.STATE_AUDIO_ONLY);
        } else if (mSupportPauseVideo && reasonCode != ImsReasonInfo.CODE_WIFI_LOST) {
            // The carrier supports video pause signalling, so pause the video if we didn't just
            // lose wifi; in that case just disconnect.
            log("downgradeVideoCall :: callId=" + conn.getTelecomCallId() + " Pause audio");
            mShouldUpdateImsConfigOnDisconnect = true;
            conn.pauseVideo(VideoPauseTracker.SOURCE_DATA_ENABLED);
        } else {
            log("downgradeVideoCall :: callId=" + conn.getTelecomCallId() + " Disconnect call.");
            // At this point the only choice we have is to terminate the call.
            imsCall.terminate(ImsReasonInfo.CODE_USER_TERMINATED, reasonCode);
        }
    }
}
Also used : ImsCall(com.android.ims.ImsCall)

Example 8 with ImsCall

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

the class ImsPhoneCallTracker method hangup.

public void hangup(ImsPhoneCall call, @android.telecom.Call.RejectReason int rejectReason) throws CallStateException {
    if (DBG)
        log("hangup call - reason=" + rejectReason);
    if (call.getConnectionsCount() == 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 if (call == mHandoverCall) {
        if (Phone.DEBUG_PHONE) {
            log("(handover) hangup handover (SRVCC) call");
        }
    } else {
        throw new CallStateException("ImsPhoneCall " + call + "does not belong to ImsPhoneCallTracker " + this);
    }
    call.onHangupLocal();
    try {
        if (imsCall != null) {
            if (rejectCall) {
                if (rejectReason == android.telecom.Call.REJECT_REASON_UNWANTED) {
                    imsCall.reject(ImsReasonInfo.CODE_SIP_USER_MARKED_UNWANTED);
                } else {
                    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 9 with ImsCall

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

the class ImsPhoneCallTracker method handleDataEnabledChange.

/**
 * Handles changes to the enabled state of mobile data.
 * When data is disabled, handles auto-downgrade of video calls over LTE.
 * When data is enabled, handled resuming of video calls paused when data was disabled.
 * @param enabled {@code true} if mobile data is enabled, {@code false} if mobile data is
 *                            disabled.
 * @param reasonCode The {@link ImsReasonInfo} code for the data enabled state change.
 */
private void handleDataEnabledChange(boolean enabled, int reasonCode) {
    if (!enabled) {
        // data charges.
        for (ImsPhoneConnection conn : mConnections) {
            ImsCall imsCall = conn.getImsCall();
            if (imsCall != null && imsCall.isVideoCall() && !imsCall.isWifiCall()) {
                log("handleDataEnabledChange - downgrading " + conn);
                downgradeVideoCall(reasonCode, conn);
            }
        }
    } else if (mSupportPauseVideo) {
        // Data was re-enabled, so un-pause previously paused video calls.
        for (ImsPhoneConnection conn : mConnections) {
            // If video is paused, check to see if there are any pending pauses due to enabled
            // state of data changing.
            log("handleDataEnabledChange - resuming " + conn);
            if (VideoProfile.isPaused(conn.getVideoState()) && conn.wasVideoPausedFromSource(VideoPauseTracker.SOURCE_DATA_ENABLED)) {
                // The data enabled state was a cause of a pending pause, so potentially
                // resume the video now.
                conn.resumeVideo(VideoPauseTracker.SOURCE_DATA_ENABLED);
            }
        }
        mShouldUpdateImsConfigOnDisconnect = false;
    }
}
Also used : ImsCall(com.android.ims.ImsCall)

Example 10 with ImsCall

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

the class ImsPhoneCallTracker method sendCallStartFailedDisconnect.

public void sendCallStartFailedDisconnect(ImsCall imsCall, ImsReasonInfo reasonInfo) {
    mPendingMO = null;
    ImsPhoneConnection conn = findConnection(imsCall);
    Call.State callState;
    if (conn != null) {
        callState = conn.getState();
    } else {
        // Need to fall back in case connection is null; it shouldn't be, but a sane
        // fallback is to assume we're dialing.  This state is only used to
        // determine which disconnect string to show in the case of a low battery
        // disconnect.
        callState = Call.State.DIALING;
    }
    int cause = getDisconnectCauseFromReasonInfo(reasonInfo, callState);
    processCallStateChange(imsCall, ImsPhoneCall.State.DISCONNECTED, cause);
    if (conn != null) {
        conn.setPreciseDisconnectCause(getPreciseDisconnectCauseFromReasonInfo(reasonInfo));
    }
    mPhone.notifyImsReason(reasonInfo);
}
Also used : ImsCall(com.android.ims.ImsCall) Call(com.android.internal.telephony.Call) ImsMultiEndpoint(com.android.ims.ImsMultiEndpoint)

Aggregations

ImsCall (com.android.ims.ImsCall)48 ImsException (com.android.ims.ImsException)19 SmallTest (android.test.suitebuilder.annotation.SmallTest)16 CallStateException (com.android.internal.telephony.CallStateException)16 TelephonyTest (com.android.internal.telephony.TelephonyTest)16 Test (org.junit.Test)16 ImsCallProfile (android.telephony.ims.ImsCallProfile)8 FlakyTest (androidx.test.filters.FlakyTest)8 RemoteException (android.os.RemoteException)6 Connection (com.android.internal.telephony.Connection)5 ImsPhoneCall (com.android.internal.telephony.imsphone.ImsPhoneCall)5 ImsPhone (com.android.internal.telephony.imsphone.ImsPhone)4 ImsReasonInfo (android.telephony.ims.ImsReasonInfo)3 ImsMultiEndpoint (com.android.ims.ImsMultiEndpoint)3 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)3 Bundle (android.os.Bundle)2 PersistableBundle (android.os.PersistableBundle)2 TestConferenceEventPackageParser (com.android.internal.telephony.test.TestConferenceEventPackageParser)2 File (java.io.File)2 FileInputStream (java.io.FileInputStream)2