FileDocCategorySizeDatePackage
Phone.javaAPI DocAndroid 5.1 API11221Thu Mar 12 22:22:42 GMT 2015android.telecom

Phone

public final class Phone extends Object
A unified virtual device providing a means of voice (and other) communication on a device. {@hide}

Fields Summary
private final Map
mCallByTelecomCallId
private final List
mCalls
private final List
mUnmodifiableCalls
private final InCallAdapter
mInCallAdapter
private AudioState
mAudioState
private final List
mListeners
private boolean
mCanAddCall
Constructors Summary
Phone(InCallAdapter adapter)
{@hide}


      
      
        mInCallAdapter = adapter;
    
Methods Summary
public final voidaddListener(android.telecom.Phone$Listener listener)
Adds a listener to this {@code Phone}.

param
listener A {@code Listener} object.

        mListeners.add(listener);
    
public final booleancanAddCall()
Returns if the {@code Phone} can support additional calls.

return
Whether the phone supports adding more calls.

        return mCanAddCall;
    
private voidcheckCallTree(ParcelableCall parcelableCall)

        if (parcelableCall.getParentCallId() != null &&
                !mCallByTelecomCallId.containsKey(parcelableCall.getParentCallId())) {
            Log.wtf(this, "ParcelableCall %s has nonexistent parent %s",
                    parcelableCall.getId(), parcelableCall.getParentCallId());
        }
        if (parcelableCall.getChildCallIds() != null) {
            for (int i = 0; i < parcelableCall.getChildCallIds().size(); i++) {
                if (!mCallByTelecomCallId.containsKey(parcelableCall.getChildCallIds().get(i))) {
                    Log.wtf(this, "ParcelableCall %s has nonexistent child %s",
                            parcelableCall.getId(), parcelableCall.getChildCallIds().get(i));
                }
            }
        }
    
final voiddestroy()
Called to destroy the phone and cleanup any lingering calls.

hide

        for (Call call : mCalls) {
            if (call.getState() != Call.STATE_DISCONNECTED) {
                call.internalSetDisconnected();
            }
        }
    
private voidfireAudioStateChanged(AudioState audioState)

        for (Listener listener : mListeners) {
            listener.onAudioStateChanged(this, audioState);
        }
    
private voidfireBringToForeground(boolean showDialpad)

        for (Listener listener : mListeners) {
            listener.onBringToForeground(this, showDialpad);
        }
    
private voidfireCallAdded(Call call)

        for (Listener listener : mListeners) {
            listener.onCallAdded(this, call);
        }
    
private voidfireCallRemoved(Call call)

        for (Listener listener : mListeners) {
            listener.onCallRemoved(this, call);
        }
    
private voidfireCanAddCallChanged(boolean canAddCall)

        for (Listener listener : mListeners) {
            listener.onCanAddCallChanged(this, canAddCall);
        }
    
public final AudioStategetAudioState()
Obtains the current phone call audio state of the {@code Phone}.

return
An object encapsulating the audio state.

        return mAudioState;
    
public final java.util.ListgetCalls()
Obtains the current list of {@code Call}s to be displayed by this in-call experience.

return
A list of the relevant {@code Call}s.

        return mUnmodifiableCalls;
    
final voidinternalAddCall(ParcelableCall parcelableCall)
{@hide}

        Call call = new Call(this, parcelableCall.getId(), mInCallAdapter);
        mCallByTelecomCallId.put(parcelableCall.getId(), call);
        mCalls.add(call);
        checkCallTree(parcelableCall);
        call.internalUpdate(parcelableCall, mCallByTelecomCallId);
        fireCallAdded(call);
     
final voidinternalAudioStateChanged(AudioState audioState)
{@hide}

        if (!Objects.equals(mAudioState, audioState)) {
            mAudioState = audioState;
            fireAudioStateChanged(audioState);
        }
    
final voidinternalBringToForeground(boolean showDialpad)
{@hide}

        fireBringToForeground(showDialpad);
    
final CallinternalGetCallByTelecomId(java.lang.String telecomId)
{@hide}

        return mCallByTelecomCallId.get(telecomId);
    
final voidinternalRemoveCall(Call call)
{@hide}

        mCallByTelecomCallId.remove(call.internalGetCallId());
        mCalls.remove(call);
        fireCallRemoved(call);
    
final voidinternalSetCanAddCall(boolean canAddCall)
{@hide}

        if (mCanAddCall != canAddCall) {
            mCanAddCall = canAddCall;
            fireCanAddCallChanged(canAddCall);
        }
    
final voidinternalSetPostDialWait(java.lang.String telecomId, java.lang.String remaining)
{@hide}

        Call call = mCallByTelecomCallId.get(telecomId);
        if (call != null) {
            call.internalSetPostDialWait(remaining);
        }
    
final voidinternalUpdateCall(ParcelableCall parcelableCall)
{@hide}

         Call call = mCallByTelecomCallId.get(parcelableCall.getId());
         if (call != null) {
             checkCallTree(parcelableCall);
             call.internalUpdate(parcelableCall, mCallByTelecomCallId);
         }
     
public final voidremoveListener(android.telecom.Phone$Listener listener)
Removes a listener from this {@code Phone}.

param
listener A {@code Listener} object.

        if (listener != null) {
            mListeners.remove(listener);
        }
    
public final voidsetAudioRoute(int route)
Sets the audio route (speaker, bluetooth, etc...). When this request is honored, there will be change to the {@link #getAudioState()}.

param
route The audio route to use.

        mInCallAdapter.setAudioRoute(route);
    
public final voidsetMuted(boolean state)
Sets the microphone mute state. When this request is honored, there will be change to the {@link #getAudioState()}.

param
state {@code true} if the microphone should be muted; {@code false} otherwise.

        mInCallAdapter.mute(state);
    
public final voidsetProximitySensorOff(boolean screenOnImmediately)
Turns the proximity sensor off. When this request is made, the proximity sensor will become inactive, and no longer affect the touch screen and display. This operation is a no-op on devices that do not have a proximity sensor.

param
screenOnImmediately If true, the screen will be turned on immediately if it was previously off. Otherwise, the screen will only be turned on after the proximity sensor is no longer triggered.

        mInCallAdapter.turnProximitySensorOff(screenOnImmediately);
    
public final voidsetProximitySensorOn()
Turns the proximity sensor on. When this request is made, the proximity sensor will become active, and the touch screen and display will be turned off when the user's face is detected to be in close proximity to the screen. This operation is a no-op on devices that do not have a proximity sensor.

        mInCallAdapter.turnProximitySensorOn();