FileDocCategorySizeDatePackage
ImsPhoneCall.javaAPI DocAndroid 5.1 API9544Thu Mar 12 22:22:54 GMT 2015com.android.internal.telephony.imsphone

ImsPhoneCall

public class ImsPhoneCall extends com.android.internal.telephony.Call
{@hide}

Fields Summary
private static final String
LOG_TAG
Instance Variables
ImsPhoneCallTracker
mOwner
private boolean
mRingbackTonePlayed
Constructors Summary
ImsPhoneCall()
Constructors


      
    /*package*/
     
    
ImsPhoneCall(ImsPhoneCallTracker owner)

        mOwner = owner;
    
Methods Summary
voidattach(com.android.internal.telephony.Connection conn, State state)

        this.attach(conn);
        mState = state;
    
voidattach(com.android.internal.telephony.Connection conn)

        clearDisconnected();
        mConnections.add(conn);
    
voidattachFake(com.android.internal.telephony.Connection conn, State state)

        attach(conn, state);
    
voidclearDisconnected()
Called when it's time to clean up disconnected Connection objects

        for (int i = mConnections.size() - 1 ; i >= 0 ; i--) {
            ImsPhoneConnection cn = (ImsPhoneConnection)mConnections.get(i);

            if (cn.getState() == State.DISCONNECTED) {
                mConnections.remove(i);
            }
        }

        if (mConnections.size() == 0) {
            mState = State.IDLE;
        }
    
booleanconnectionDisconnected(ImsPhoneConnection conn)
Called by ImsPhoneConnection when it has disconnected

        if (mState != State.DISCONNECTED) {
            /* If only disconnected connections remain, we are disconnected*/

            boolean hasOnlyDisconnectedConnections = true;

            for (int i = 0, s = mConnections.size()  ; i < s; i ++) {
                if (mConnections.get(i).getState() != State.DISCONNECTED) {
                    hasOnlyDisconnectedConnections = false;
                    break;
                }
            }

            if (hasOnlyDisconnectedConnections) {
                mState = State.DISCONNECTED;
                return true;
            }
        }

        return false;
    
voiddetach(ImsPhoneConnection conn)

        mConnections.remove(conn);
        clearDisconnected();
    
public voiddispose()

        try {
            mOwner.hangup(this);
        } catch (CallStateException ex) {
            //Rlog.e(LOG_TAG, "dispose: unexpected error on hangup", ex);
            //while disposing, ignore the exception and clean the connections
        } finally {
            for(int i = 0, s = mConnections.size(); i < s; i++) {
                ImsPhoneConnection c = (ImsPhoneConnection) mConnections.get(i);
                c.onDisconnect(DisconnectCause.LOST_SIGNAL);
            }
        }
    
public java.util.ListgetConnections()
Overridden from Call

        return mConnections;
    
ImsPhoneConnectiongetFirstConnection()

        if (mConnections.size() == 0) return null;

        return (ImsPhoneConnection) mConnections.get(0);
    
ImsPhoneConnectiongetHandoverConnection()

        return (ImsPhoneConnection) getEarliestConnection();
    
public com.android.ims.ImsCallgetImsCall()
Retrieves the {@link ImsCall} for the current {@link ImsPhoneCall}.

Marked as {@code VisibleForTesting} so that the {@link com.android.internal.telephony.TelephonyTester} class can inject a test conference event package into a regular ongoing IMS call.

return
The {@link ImsCall}.

        return (getFirstConnection() == null) ? null : getFirstConnection().getImsCall();
    
public com.android.internal.telephony.PhonegetPhone()

        return mOwner.mPhone;
    
public voidhangup()
Please note: if this is the foreground call and a background call exists, the background call will be resumed.

        mOwner.hangup(this);
    
booleanisFull()

return
true if there's no space in this call for additional connections to be added via "conference"

        return mConnections.size() == ImsPhoneCallTracker.MAX_CONNECTIONS_PER_CALL;
    
static booleanisLocalTone(com.android.ims.ImsCall imsCall)

        if ((imsCall == null) || (imsCall.getCallProfile() == null)
                || (imsCall.getCallProfile().mMediaProfile == null)) {
            return false;
        }

        ImsStreamMediaProfile mediaProfile = imsCall.getCallProfile().mMediaProfile;

        return (mediaProfile.mAudioDirection == ImsStreamMediaProfile.DIRECTION_INACTIVE)
                ? true : false;
    
public booleanisMultiparty()

        ImsCall imsCall = getImsCall();
        if (imsCall == null) {
            return false;
        }

        return imsCall.isMultiparty();
    
voidmerge(com.android.internal.telephony.imsphone.ImsPhoneCall that, State state)

        // This call is the conference host and the "that" call is the one being merged in.
        // Set the connect time for the conference; this will have been determined when the
        // conference was initially created.
        ImsPhoneConnection imsPhoneConnection = getFirstConnection();
        if (imsPhoneConnection != null) {
            long conferenceConnectTime = imsPhoneConnection.getConferenceConnectTime();
            if (conferenceConnectTime > 0) {
                imsPhoneConnection.setConnectTime(conferenceConnectTime);
            }
        }

        ImsPhoneConnection[] cc = that.mConnections.toArray(
                new ImsPhoneConnection[that.mConnections.size()]);
        for (ImsPhoneConnection c : cc) {
            c.update(null, state);
        }
    
voidonHangupLocal()
Called when this Call is being hung up locally (eg, user pressed "end")

        for (int i = 0, s = mConnections.size(); i < s; i++) {
            ImsPhoneConnection cn = (ImsPhoneConnection)mConnections.get(i);
            cn.onHangupLocal();
        }
        mState = State.DISCONNECTING;
    
voidsetMute(boolean mute)

        ImsCall imsCall = getFirstConnection() == null ?
                null : getFirstConnection().getImsCall();
        if (imsCall != null) {
            try {
                imsCall.setMute(mute);
            } catch (ImsException e) {
                Rlog.e(LOG_TAG, "setMute failed : " + e.getMessage());
            }
        }
    
voidswitchWith(com.android.internal.telephony.imsphone.ImsPhoneCall that)

        synchronized (ImsPhoneCall.class) {
            ImsPhoneCall tmp = new ImsPhoneCall();
            tmp.takeOver(this);
            this.takeOver(that);
            that.takeOver(tmp);
        }
    
private voidtakeOver(com.android.internal.telephony.imsphone.ImsPhoneCall that)

        mConnections = that.mConnections;
        mState = that.mState;
        for (Connection c : mConnections) {
            ((ImsPhoneConnection) c).changeParent(this);
        }
    
public java.lang.StringtoString()

        return mState.toString();
    
booleanupdate(ImsPhoneConnection conn, com.android.ims.ImsCall imsCall, State state)

        State newState = state;
        boolean changed = false;

        //ImsCall.Listener.onCallProgressing can be invoked several times
        //and ringback tone mode can be changed during the call setup procedure
        if (state == State.ALERTING) {
            if (mRingbackTonePlayed && !isLocalTone(imsCall)) {
                mOwner.mPhone.stopRingbackTone();
                mRingbackTonePlayed = false;
            } else if (!mRingbackTonePlayed && isLocalTone(imsCall)) {
                mOwner.mPhone.startRingbackTone();
                mRingbackTonePlayed = true;
            }
        } else {
            if (mRingbackTonePlayed) {
                mOwner.mPhone.stopRingbackTone();
                mRingbackTonePlayed = false;
            }
        }

        if ((newState != mState) && (state != State.DISCONNECTED)) {
            mState = newState;
            changed = true;
        } else if (state == State.DISCONNECTED) {
            changed = true;
        }

        return changed;