FileDocCategorySizeDatePackage
ImsCallSession.javaAPI DocAndroid 5.1 API38248Thu Mar 12 22:22:52 GMT 2015com.android.ims.internal

ImsCallSession

public class ImsCallSession extends Object
Provides the call initiation/termination, and media exchange between two IMS endpoints. It directly communicates with IMS service which implements the IMS protocol behavior.
hide

Fields Summary
private static final String
TAG
private final IImsCallSession
miSession
private boolean
mClosed
private Listener
mListener
Constructors Summary
public ImsCallSession(IImsCallSession iSession)


       
        miSession = iSession;

        if (iSession != null) {
            try {
                iSession.setListener(new IImsCallSessionListenerProxy());
            } catch (RemoteException e) {
            }
        } else {
            mClosed = true;
        }
    
public ImsCallSession(IImsCallSession iSession, Listener listener)

        this(iSession);
        setListener(listener);
    
Methods Summary
public voidaccept(int callType, com.android.ims.ImsStreamMediaProfile profile)
Accepts an incoming call or session update.

param
callType call type specified in {@link ImsCallProfile} to be answered
param
profile stream media profile {@link ImsStreamMediaProfile} to be answered
see
Listener#callSessionStarted

        if (mClosed) {
            return;
        }

        try {
            miSession.accept(callType, profile);
        } catch (RemoteException e) {
        }
    
public synchronized voidclose()
Closes this object. This object is not usable after being closed.

        if (mClosed) {
            return;
        }

        try {
            miSession.close();
            mClosed = true;
        } catch (RemoteException e) {
        }
    
public voidextendToConference(java.lang.String[] participants)
Extends this call to the conference call with the specified recipients.

participants
participant list to be invited to the conference call after extending the call
see
Listener#sessionConferenceExtened, Listener#sessionConferenceExtendFailed

        if (mClosed) {
            return;
        }

        try {
            miSession.extendToConference(participants);
        } catch (RemoteException e) {
        }
    
public java.lang.StringgetCallId()
Gets the call ID of the session.

return
the call ID

        if (mClosed) {
            return null;
        }

        try {
            return miSession.getCallId();
        } catch (RemoteException e) {
            return null;
        }
    
public com.android.ims.ImsCallProfilegetCallProfile()
Gets the call profile that this session is associated with

return
the call profile that this session is associated with

        if (mClosed) {
            return null;
        }

        try {
            return miSession.getCallProfile();
        } catch (RemoteException e) {
            return null;
        }
    
public com.android.ims.ImsCallProfilegetLocalCallProfile()
Gets the local call profile that this session is associated with

return
the local call profile that this session is associated with

        if (mClosed) {
            return null;
        }

        try {
            return miSession.getLocalCallProfile();
        } catch (RemoteException e) {
            return null;
        }
    
public java.lang.StringgetProperty(java.lang.String name)
Gets the value associated with the specified property of this session.

return
the string value associated with the specified property

        if (mClosed) {
            return null;
        }

        try {
            return miSession.getProperty(name);
        } catch (RemoteException e) {
            return null;
        }
    
public com.android.ims.ImsCallProfilegetRemoteCallProfile()
Gets the remote call profile that this session is associated with

return
the remote call profile that this session is associated with

        if (mClosed) {
            return null;
        }

        try {
            return miSession.getRemoteCallProfile();
        } catch (RemoteException e) {
            return null;
        }
    
public IImsCallSessiongetSession()
Gets the native IMS call session.

hide

        return miSession;
    
public intgetState()
Gets the session state. The value returned must be one of the states in {@link State}.

return
the session state

        if (mClosed) {
            return State.INVALID;
        }

        try {
            return miSession.getState();
        } catch (RemoteException e) {
            return State.INVALID;
        }
    
public IImsVideoCallProvidergetVideoCallProvider()
Gets the video call provider for the session.

return
The video call provider.

        if (mClosed) {
            return null;
        }

        try {
            return miSession.getVideoCallProvider();
        } catch (RemoteException e) {
            return null;
        }
    
public voidhold(com.android.ims.ImsStreamMediaProfile profile)
Puts a call on hold. When it succeeds, {@link Listener#callSessionHeld} is called.

param
profile stream media profile {@link ImsStreamMediaProfile} to hold the call
see
Listener#callSessionHeld, Listener#callSessionHoldFailed

        if (mClosed) {
            return;
        }

        try {
            miSession.hold(profile);
        } catch (RemoteException e) {
        }
    
public voidinviteParticipants(java.lang.String[] participants)
Requests the conference server to invite an additional participants to the conference.

participants
participant list to be invited to the conference call
see
Listener#sessionInviteParticipantsRequestDelivered, Listener#sessionInviteParticipantsRequestFailed

        if (mClosed) {
            return;
        }

        try {
            miSession.inviteParticipants(participants);
        } catch (RemoteException e) {
        }
    
public booleanisAlive()
Determines if the {@link ImsCallSession} is currently alive (e.g. not in a terminated or closed state).

return
{@code True} if the session is alive.

        if (mClosed) {
            return false;
        }

        int state = getState();
        switch (state) {
            case State.IDLE:
            case State.INITIATED:
            case State.NEGOTIATING:
            case State.ESTABLISHING:
            case State.ESTABLISHED:
            case State.RENEGOTIATING:
            case State.REESTABLISHING:
                return true;
            default:
                return false;
        }
    
public booleanisInCall()
Checks if the session is in call.

return
true if the session is in call

        if (mClosed) {
            return false;
        }

        try {
            return miSession.isInCall();
        } catch (RemoteException e) {
            return false;
        }
    
public booleanisMultiparty()
Determines if the session is multiparty.

return
{@code True} if the session is multiparty.

        if (mClosed) {
            return false;
        }

        try {
            return miSession.isMultiparty();
        } catch (RemoteException e) {
            return false;
        }
    
public voidmerge()
Merges the active & hold call. When it succeeds, {@link Listener#callSessionMergeStarted} is called.

see
Listener#callSessionMergeStarted , Listener#callSessionMergeFailed

        if (mClosed) {
            return;
        }

        try {
            miSession.merge();
        } catch (RemoteException e) {
        }
    
public voidreject(int reason)
Rejects an incoming call or session update.

param
reason reason code to reject an incoming call
see
Listener#callSessionStartFailed

        if (mClosed) {
            return;
        }

        try {
            miSession.reject(reason);
        } catch (RemoteException e) {
        }
    
public voidremoveParticipants(java.lang.String[] participants)
Requests the conference server to remove the specified participants from the conference.

param
participants participant list to be removed from the conference call
see
Listener#sessionRemoveParticipantsRequestDelivered, Listener#sessionRemoveParticipantsRequestFailed

        if (mClosed) {
            return;
        }

        try {
            miSession.removeParticipants(participants);
        } catch (RemoteException e) {
        }
    
public voidresume(com.android.ims.ImsStreamMediaProfile profile)
Continues a call that's on hold. When it succeeds, {@link Listener#callSessionResumed} is called.

param
profile stream media profile {@link ImsStreamMediaProfile} to resume the call
see
Listener#callSessionResumed, Listener#callSessionResumeFailed

        if (mClosed) {
            return;
        }

        try {
            miSession.resume(profile);
        } catch (RemoteException e) {
        }
    
public voidsendDtmf(char c, android.os.Message result)
Sends a DTMF code. According to RFC 2833, event 0 ~ 9 maps to decimal value 0 ~ 9, '*' to 10, '#' to 11, event 'A' ~ 'D' to 12 ~ 15, and event flash to 16. Currently, event flash is not supported.

param
c the DTMF to send. '0' ~ '9', 'A' ~ 'D', '*', '#' are valid inputs.

        if (mClosed) {
            return;
        }

        try {
            miSession.sendDtmf(c, result);
        } catch (RemoteException e) {
        }
    
public voidsendUssd(java.lang.String ussdMessage)
Sends an USSD message.

param
ussdMessage USSD message to send

        if (mClosed) {
            return;
        }

        try {
            miSession.sendUssd(ussdMessage);
        } catch (RemoteException e) {
        }
    
public voidsetListener(com.android.ims.internal.ImsCallSession$Listener listener)
Sets the listener to listen to the session events. A {@link ImsCallSession} can only hold one listener at a time. Subsequent calls to this method override the previous listener.

param
listener to listen to the session events of this object

        mListener = listener;
    
public voidsetMute(boolean muted)
Mutes or unmutes the mic for the active call.

param
muted true if the call is muted, false otherwise

        if (mClosed) {
            return;
        }

        try {
            miSession.setMute(muted);
        } catch (RemoteException e) {
        }
    
public voidstart(java.lang.String callee, com.android.ims.ImsCallProfile profile)
Initiates an IMS call with the specified target and call profile. The session listener is called back upon defined session events. The method is only valid to call when the session state is in {@link ImsCallSession#State#IDLE}.

param
callee dialed string to make the call to
param
profile call profile to make the call with the specified service type, call type and media information
see
Listener#callSessionStarted, Listener#callSessionStartFailed

        if (mClosed) {
            return;
        }

        try {
            miSession.start(callee, profile);
        } catch (RemoteException e) {
        }
    
public voidstart(java.lang.String[] participants, com.android.ims.ImsCallProfile profile)
Initiates an IMS conference call with the specified target and call profile. The session listener is called back upon defined session events. The method is only valid to call when the session state is in {@link ImsCallSession#State#IDLE}.

param
participants participant list to initiate an IMS conference call
param
profile call profile to make the call with the specified service type, call type and media information
see
Listener#callSessionStarted, Listener#callSessionStartFailed

        if (mClosed) {
            return;
        }

        try {
            miSession.startConference(participants, profile);
        } catch (RemoteException e) {
        }
    
public voidstartDtmf(char c)
Starts a DTMF code. According to RFC 2833, event 0 ~ 9 maps to decimal value 0 ~ 9, '*' to 10, '#' to 11, event 'A' ~ 'D' to 12 ~ 15, and event flash to 16. Currently, event flash is not supported.

param
c the DTMF to send. '0' ~ '9', 'A' ~ 'D', '*', '#' are valid inputs.

        if (mClosed) {
            return;
        }

        try {
            miSession.startDtmf(c);
        } catch (RemoteException e) {
        }
    
public voidstopDtmf()
Stops a DTMF code.

        if (mClosed) {
            return;
        }

        try {
            miSession.stopDtmf();
        } catch (RemoteException e) {
        }
    
public voidterminate(int reason)
Terminates a call.

see
Listener#callSessionTerminated

        if (mClosed) {
            return;
        }

        try {
            miSession.terminate(reason);
        } catch (RemoteException e) {
        }
    
public java.lang.StringtoString()
Provides a string representation of the {@link ImsCallSession}. Primarily intended for use in log statements.

return
String representation of session.

        StringBuilder sb = new StringBuilder();
        sb.append("[ImsCallSession objId:");
        sb.append(System.identityHashCode(this));
        sb.append(" state:");
        sb.append(State.toString(getState()));
        sb.append(" callId:");
        sb.append(getCallId());
        sb.append("]");
        return sb.toString();
    
public voidupdate(int callType, com.android.ims.ImsStreamMediaProfile profile)
Updates the current call's properties (ex. call mode change: video upgrade / downgrade).

param
callType call type specified in {@link ImsCallProfile} to be updated
param
profile stream media profile {@link ImsStreamMediaProfile} to be updated
see
Listener#callSessionUpdated, Listener#callSessionUpdateFailed

        if (mClosed) {
            return;
        }

        try {
            miSession.update(callType, profile);
        } catch (RemoteException e) {
        }