FileDocCategorySizeDatePackage
RemoteConnection.javaAPI DocAndroid 5.1 API33550Thu Mar 12 22:22:42 GMT 2015android.telecom

RemoteConnection

public final class RemoteConnection extends Object
A connection provided to a {@link ConnectionService} by another {@code ConnectionService} running in a different process.
see
ConnectionService#createRemoteOutgoingConnection(PhoneAccountHandle, ConnectionRequest)
see
ConnectionService#createRemoteIncomingConnection(PhoneAccountHandle, ConnectionRequest)
hide

Fields Summary
private com.android.internal.telecom.IConnectionService
mConnectionService
private final String
mConnectionId
private final Set
mCallbacks
ConcurrentHashMap constructor params: 8 is initial table size, 0.9f is load factor before resizing, 1 means we only expect a single thread to access the map so make only a single shard
private final List
mConferenceableConnections
private final List
mUnmodifiableconferenceableConnections
private int
mState
private DisconnectCause
mDisconnectCause
private boolean
mRingbackRequested
private boolean
mConnected
private int
mConnectionCapabilities
private int
mVideoState
private VideoProvider
mVideoProvider
private boolean
mIsVoipAudioMode
private StatusHints
mStatusHints
private android.net.Uri
mAddress
private int
mAddressPresentation
private String
mCallerDisplayName
private int
mCallerDisplayNamePresentation
private RemoteConference
mConference
Constructors Summary
RemoteConnection(String id, com.android.internal.telecom.IConnectionService connectionService, ConnectionRequest request)

hide


          
    
             
             
              
        mConnectionId = id;
        mConnectionService = connectionService;
        mConnected = true;
        mState = Connection.STATE_INITIALIZING;
    
RemoteConnection(String callId, com.android.internal.telecom.IConnectionService connectionService, ParcelableConnection connection)

hide

        mConnectionId = callId;
        mConnectionService = connectionService;
        mConnected = true;
        mState = connection.getState();
        mDisconnectCause = connection.getDisconnectCause();
        mRingbackRequested = connection.isRingbackRequested();
        mConnectionCapabilities = connection.getConnectionCapabilities();
        mVideoState = connection.getVideoState();
        mVideoProvider = new RemoteConnection.VideoProvider(connection.getVideoProvider());
        mIsVoipAudioMode = connection.getIsVoipAudioMode();
        mStatusHints = connection.getStatusHints();
        mAddress = connection.getHandle();
        mAddressPresentation = connection.getHandlePresentation();
        mCallerDisplayName = connection.getCallerDisplayName();
        mCallerDisplayNamePresentation = connection.getCallerDisplayNamePresentation();
        mConference = null;
    
RemoteConnection(DisconnectCause disconnectCause)
Create a RemoteConnection which is used for failed connections. Note that using it for any "real" purpose will almost certainly fail. Callers should note the failure and act accordingly (moving on to another RemoteConnection, for example)

param
disconnectCause The reason for the failed connection.
hide

        mConnectionId = "NULL";
        mConnected = false;
        mState = Connection.STATE_DISCONNECTED;
        mDisconnectCause = disconnectCause;
    
Methods Summary
public voidabort()
Instructs this {@code RemoteConnection} to abort.

        try {
            if (mConnected) {
                mConnectionService.abort(mConnectionId);
            }
        } catch (RemoteException ignored) {
        }
    
public voidanswer()
Instructs this {@link Connection#STATE_RINGING} {@code RemoteConnection} to answer.

        try {
            if (mConnected) {
                mConnectionService.answer(mConnectionId);
            }
        } catch (RemoteException ignored) {
        }
    
public voidanswer(int videoState)
Instructs this {@link Connection#STATE_RINGING} {@code RemoteConnection} to answer.

param
videoState The video state in which to answer the call.
hide

        try {
            if (mConnected) {
                mConnectionService.answerVideo(mConnectionId, videoState);
            }
        } catch (RemoteException ignored) {
        }
    
public voiddisconnect()
Instructs this {@code RemoteConnection} to disconnect.

        try {
            if (mConnected) {
                mConnectionService.disconnect(mConnectionId);
            }
        } catch (RemoteException ignored) {
        }
    
public static android.telecom.RemoteConnectionfailure(DisconnectCause disconnectCause)
Create a RemoteConnection represents a failure, and which will be in {@link Connection#STATE_DISCONNECTED}. Attempting to use it for anything will almost certainly result in bad things happening. Do not do this.

return
a failed {@link RemoteConnection}
hide

        return new RemoteConnection(disconnectCause);
    
public android.net.UrigetAddress()
Obtains the address of this {@code RemoteConnection}.

return
The address (e.g., phone number) to which the {@code RemoteConnection} is currently connected.

        return mAddress;
    
public intgetAddressPresentation()
Obtains the presentation requirements for the address of this {@code RemoteConnection}.

return
The presentation requirements for the address. See {@link TelecomManager} for valid values.

        return mAddressPresentation;
    
public java.lang.CharSequencegetCallerDisplayName()
Obtains the display name for this {@code RemoteConnection}'s caller.

return
The display name for the caller.

        return mCallerDisplayName;
    
public intgetCallerDisplayNamePresentation()
Obtains the presentation requirements for this {@code RemoteConnection}'s caller's display name.

return
The presentation requirements for the caller display name. See {@link TelecomManager} for valid values.

        return mCallerDisplayNamePresentation;
    
public RemoteConferencegetConference()
Obtain the {@code RemoteConference} that this {@code RemoteConnection} may be a part of, or {@code null} if there is no such {@code RemoteConference}.

return
A {@code RemoteConference} or {@code null};

        return mConference;
    
public java.util.ListgetConferenceableConnections()
Obtain the {@code RemoteConnection}s with which this {@code RemoteConnection} may be successfully asked to create a conference with.

return
The {@code RemoteConnection}s with which this {@code RemoteConnection} may be merged into a {@link RemoteConference}.

        return mUnmodifiableconferenceableConnections;
    
public intgetConnectionCapabilities()
Obtains the capabilities of this {@code RemoteConnection}.

return
A bitmask of the capabilities of the {@code RemoteConnection}, as defined in the {@code CAPABILITY_*} constants in class {@link Connection}.

        return mConnectionCapabilities;
    
com.android.internal.telecom.IConnectionServicegetConnectionService()
{@hide}

        return mConnectionService;
    
public DisconnectCausegetDisconnectCause()
Obtains the reason why this {@code RemoteConnection} may have been disconnected.

return
For a {@link Connection#STATE_DISCONNECTED} {@code RemoteConnection}, the disconnect cause expressed as a code chosen from among those declared in {@link DisconnectCause}.

        return mDisconnectCause;
    
java.lang.StringgetId()
{@hide}

        return mConnectionId;
    
public intgetState()
Obtains the state of this {@code RemoteConnection}.

return
A state value, chosen from the {@code STATE_*} constants.

        return mState;
    
public StatusHintsgetStatusHints()
Obtains status hints pertaining to this {@code RemoteConnection}.

return
The current {@link StatusHints} of this {@code RemoteConnection}, or {@code null} if none have been set.

        return mStatusHints;
    
public final android.telecom.RemoteConnection$VideoProvidergetVideoProvider()
Obtains the video provider of this {@code RemoteConnection}.

return
The video provider associated with this {@code RemoteConnection}.
hide

        return mVideoProvider;
    
public intgetVideoState()
Obtains the video state of this {@code RemoteConnection}.

return
The video state of the {@code RemoteConnection}. See {@link VideoProfile.VideoState}.
hide

        return mVideoState;
    
public voidhold()
Instructs this {@code RemoteConnection} to go on hold.

        try {
            if (mConnected) {
                mConnectionService.hold(mConnectionId);
            }
        } catch (RemoteException ignored) {
        }
    
public booleanisRingbackRequested()
Determines whether this {@code RemoteConnection} is requesting ringback.

return
Whether the {@code RemoteConnection} is requesting that the framework play a ringback tone on its behalf.

        return false;
    
public booleanisVoipAudioMode()
Determines if the audio mode of this {@code RemoteConnection} is VOIP.

return
{@code true} if the {@code RemoteConnection}'s current audio mode is VOIP.

        return mIsVoipAudioMode;
    
voidonPostDialChar(char nextChar)

hide

        for (Callback c : mCallbacks) {
            c.onPostDialChar(this, nextChar);
        }
    
public voidplayDtmfTone(char digit)
Instructs this {@code RemoteConnection} to play a dual-tone multi-frequency signaling (DTMF) tone. Any other currently playing DTMF tone in the specified call is immediately stopped.

param
digit A character representing the DTMF digit for which to play the tone. This value must be one of {@code '0'} through {@code '9'}, {@code '*'} or {@code '#'}.

        try {
            if (mConnected) {
                mConnectionService.playDtmfTone(mConnectionId, digit);
            }
        } catch (RemoteException ignored) {
        }
    
public voidpostDialContinue(boolean proceed)
Instructs this {@code RemoteConnection} to continue playing a post-dial DTMF string. A post-dial DTMF string is a string of digits following the first instance of either {@link TelecomManager#DTMF_CHARACTER_WAIT} or {@link TelecomManager#DTMF_CHARACTER_PAUSE}. These digits are immediately sent as DTMF tones to the recipient as soon as the connection is made. If the DTMF string contains a {@link TelecomManager#DTMF_CHARACTER_PAUSE} symbol, this {@code RemoteConnection} will temporarily pause playing the tones for a pre-defined period of time. If the DTMF string contains a {@link TelecomManager#DTMF_CHARACTER_WAIT} symbol, this {@code RemoteConnection} will pause playing the tones and notify callbacks via {@link Callback#onPostDialWait(RemoteConnection, String)}. At this point, the in-call app should display to the user an indication of this state and an affordance to continue the postdial sequence. When the user decides to continue the postdial sequence, the in-call app should invoke the {@link #postDialContinue(boolean)} method.

param
proceed Whether or not to continue with the post-dial sequence.

        try {
            if (mConnected) {
                mConnectionService.onPostDialContinue(mConnectionId, proceed);
            }
        } catch (RemoteException ignored) {
        }
    
public voidregisterCallback(android.telecom.RemoteConnection$Callback callback)
Adds a callback to this {@code RemoteConnection}.

param
callback A {@code Callback}.

        mCallbacks.add(callback);
    
public voidreject()
Instructs this {@link Connection#STATE_RINGING} {@code RemoteConnection} to reject.

        try {
            if (mConnected) {
                mConnectionService.reject(mConnectionId);
            }
        } catch (RemoteException ignored) {
        }
    
voidsetAddress(android.net.Uri address, int presentation)

hide

        mAddress = address;
        mAddressPresentation = presentation;
        for (Callback c : mCallbacks) {
            c.onAddressChanged(this, address, presentation);
        }
    
public voidsetAudioState(AudioState state)
Set the audio state of this {@code RemoteConnection}.

param
state The audio state of this {@code RemoteConnection}.

        try {
            if (mConnected) {
                mConnectionService.onAudioStateChanged(mConnectionId, state);
            }
        } catch (RemoteException ignored) {
        }
    
voidsetCallerDisplayName(java.lang.String callerDisplayName, int presentation)

hide

        mCallerDisplayName = callerDisplayName;
        mCallerDisplayNamePresentation = presentation;
        for (Callback c : mCallbacks) {
            c.onCallerDisplayNameChanged(this, callerDisplayName, presentation);
        }
    
voidsetConference(RemoteConference conference)

hide

        if (mConference != conference) {
            mConference = conference;
            for (Callback c : mCallbacks) {
                c.onConferenceChanged(this, conference);
            }
        }
    
voidsetConferenceableConnections(java.util.List conferenceableConnections)

hide

        mConferenceableConnections.clear();
        mConferenceableConnections.addAll(conferenceableConnections);
        for (Callback c : mCallbacks) {
            c.onConferenceableConnectionsChanged(this, mUnmodifiableconferenceableConnections);
        }
    
voidsetConnectionCapabilities(int connectionCapabilities)

hide

        mConnectionCapabilities = connectionCapabilities;
        for (Callback c : mCallbacks) {
            c.onConnectionCapabilitiesChanged(this, connectionCapabilities);
            c.onCallCapabilitiesChanged(this, connectionCapabilities);
        }
    
voidsetDestroyed()

hide

        if (!mCallbacks.isEmpty()) {
            // Make sure that the callbacks are notified that the call is destroyed first.
            if (mState != Connection.STATE_DISCONNECTED) {
                setDisconnected(
                        new DisconnectCause(DisconnectCause.ERROR, "Connection destroyed."));
            }

            for (Callback c : mCallbacks) {
                c.onDestroyed(this);
            }
            mCallbacks.clear();

            mConnected = false;
        }
    
voidsetDisconnected(DisconnectCause disconnectCause)

hide

        if (mState != Connection.STATE_DISCONNECTED) {
            mState = Connection.STATE_DISCONNECTED;
            mDisconnectCause = disconnectCause;

            for (Callback c : mCallbacks) {
                c.onDisconnected(this, mDisconnectCause);
            }
        }
    
voidsetIsVoipAudioMode(boolean isVoip)

hide

        mIsVoipAudioMode = isVoip;
        for (Callback c : mCallbacks) {
            c.onVoipAudioChanged(this, isVoip);
        }
    
voidsetPostDialWait(java.lang.String remainingDigits)

hide

        for (Callback c : mCallbacks) {
            c.onPostDialWait(this, remainingDigits);
        }
    
voidsetRingbackRequested(boolean ringback)

hide

        if (mRingbackRequested != ringback) {
            mRingbackRequested = ringback;
            for (Callback c : mCallbacks) {
                c.onRingbackRequested(this, ringback);
            }
        }
    
voidsetState(int state)

hide

        if (mState != state) {
            mState = state;
            for (Callback c: mCallbacks) {
                c.onStateChanged(this, state);
            }
        }
    
voidsetStatusHints(StatusHints statusHints)

hide

        mStatusHints = statusHints;
        for (Callback c : mCallbacks) {
            c.onStatusHintsChanged(this, statusHints);
        }
    
voidsetVideoProvider(android.telecom.RemoteConnection$VideoProvider videoProvider)

hide

        mVideoProvider = videoProvider;
        for (Callback c : mCallbacks) {
            c.onVideoProviderChanged(this, videoProvider);
        }
    
voidsetVideoState(int videoState)

hide

        mVideoState = videoState;
        for (Callback c : mCallbacks) {
            c.onVideoStateChanged(this, videoState);
        }
    
public voidstopDtmfTone()
Instructs this {@code RemoteConnection} to stop any dual-tone multi-frequency signaling (DTMF) tone currently playing. DTMF tones are played by calling {@link #playDtmfTone(char)}. If no DTMF tone is currently playing, this method will do nothing.

        try {
            if (mConnected) {
                mConnectionService.stopDtmfTone(mConnectionId);
            }
        } catch (RemoteException ignored) {
        }
    
public voidunhold()
Instructs this {@link Connection#STATE_HOLDING} call to release from hold.

        try {
            if (mConnected) {
                mConnectionService.unhold(mConnectionId);
            }
        } catch (RemoteException ignored) {
        }
    
public voidunregisterCallback(android.telecom.RemoteConnection$Callback callback)
Removes a callback from this {@code RemoteConnection}.

param
callback A {@code Callback}.

        if (callback != null) {
            mCallbacks.remove(callback);
        }