diff options
Diffstat (limited to 'telecomm/java/android/telecom/Call.java')
-rw-r--r-- | telecomm/java/android/telecom/Call.java | 154 |
1 files changed, 78 insertions, 76 deletions
diff --git a/telecomm/java/android/telecom/Call.java b/telecomm/java/android/telecom/Call.java index 33a7fe1..2a30384 100644 --- a/telecomm/java/android/telecom/Call.java +++ b/telecomm/java/android/telecom/Call.java @@ -16,6 +16,7 @@ package android.telecom; +import android.annotation.SystemApi; import android.net.Uri; import android.os.Bundle; @@ -65,9 +66,18 @@ public final class Call { public static final int STATE_DISCONNECTED = 7; /** - * The state of an outgoing {@code Call}, but waiting for user input before proceeding. + * The state of an outgoing {@code Call} when waiting on user to select a + * {@link PhoneAccount} through which to place the call. */ - public static final int STATE_PRE_DIAL_WAIT = 8; + public static final int STATE_SELECT_PHONE_ACCOUNT = 8; + + /** + * @hide + * @deprecated use STATE_SELECT_PHONE_ACCOUNT. + */ + @Deprecated + @SystemApi + public static final int STATE_PRE_DIAL_WAIT = STATE_SELECT_PHONE_ACCOUNT; /** * The initial state of an outgoing {@code Call}. @@ -212,7 +222,6 @@ public final class Call { /** * For video calls, indicates whether the outgoing video for the call can be paused using * the {@link android.telecom.VideoProfile.VideoState#PAUSED} VideoState. - * @hide */ public static final int CAPABILITY_CAN_PAUSE_VIDEO = 0x00100000; @@ -233,7 +242,6 @@ public final class Call { private final int mVideoState; private final StatusHints mStatusHints; private final Bundle mExtras; - private final int mCallSubstate; /** * Whether the supplied capabilities supports the specified capability. @@ -430,14 +438,6 @@ public final class Call { return mExtras; } - /** - * @return The substate of the {@code Call}. - * @hide - */ - public int getCallSubstate() { - return mCallSubstate; - } - @Override public boolean equals(Object o) { if (o instanceof Details) { @@ -456,8 +456,7 @@ public final class Call { Objects.equals(mGatewayInfo, d.mGatewayInfo) && Objects.equals(mVideoState, d.mVideoState) && Objects.equals(mStatusHints, d.mStatusHints) && - Objects.equals(mExtras, d.mExtras) && - Objects.equals(mCallSubstate, d.mCallSubstate); + Objects.equals(mExtras, d.mExtras); } return false; } @@ -477,8 +476,7 @@ public final class Call { Objects.hashCode(mGatewayInfo) + Objects.hashCode(mVideoState) + Objects.hashCode(mStatusHints) + - Objects.hashCode(mExtras) + - Objects.hashCode(mCallSubstate); + Objects.hashCode(mExtras); } /** {@hide} */ @@ -495,8 +493,7 @@ public final class Call { GatewayInfo gatewayInfo, int videoState, StatusHints statusHints, - Bundle extras, - int callSubstate) { + Bundle extras) { mHandle = handle; mHandlePresentation = handlePresentation; mCallerDisplayName = callerDisplayName; @@ -510,11 +507,10 @@ public final class Call { mVideoState = videoState; mStatusHints = statusHints; mExtras = extras; - mCallSubstate = callSubstate; } } - public static abstract class Listener { + public static abstract class Callback { /** * Invoked when the state of this {@code Call} has changed. See {@link #getState()}. * @@ -598,13 +594,21 @@ public final class Call { public void onConferenceableCallsChanged(Call call, List<Call> conferenceableCalls) {} } + /** + * @deprecated Use {@code Call.Callback} instead. + * @hide + */ + @Deprecated + @SystemApi + public static abstract class Listener extends Callback { } + private final Phone mPhone; private final String mTelecomCallId; private final InCallAdapter mInCallAdapter; private final List<String> mChildrenIds = new ArrayList<>(); private final List<Call> mChildren = new ArrayList<>(); private final List<Call> mUnmodifiableChildren = Collections.unmodifiableList(mChildren); - private final List<Listener> mListeners = new CopyOnWriteArrayList<>(); + private final List<Callback> mCallbacks = new CopyOnWriteArrayList<>(); private final List<Call> mConferenceableCalls = new ArrayList<>(); private final List<Call> mUnmodifiableConferenceableCalls = Collections.unmodifiableList(mConferenceableCalls); @@ -699,8 +703,8 @@ public final class Call { * {@code Call} 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 Call} will pause playing the tones and notify listeners via - * {@link Listener#onPostDialWait(Call, String)}. At this point, the in-call app + * {@code Call} will pause playing the tones and notify callbacks via + * {@link Callback#onPostDialWait(Call, 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. @@ -841,25 +845,52 @@ public final class Call { } /** + * Registers a callback to this {@code Call}. + * + * @param callback A {@code Callback}. + */ + public void registerCallback(Callback callback) { + mCallbacks.add(callback); + } + + /** + * Unregisters a callback from this {@code Call}. + * + * @param callback A {@code Callback}. + */ + public void unregisterCallback(Callback callback) { + if (callback != null) { + mCallbacks.remove(callback); + } + } + + /** * Adds a listener to this {@code Call}. * * @param listener A {@code Listener}. + * @deprecated Use {@link #registerCallback} instead. + * @hide */ + @Deprecated + @SystemApi public void addListener(Listener listener) { - mListeners.add(listener); + registerCallback(listener); } /** * Removes a listener from this {@code Call}. * * @param listener A {@code Listener}. + * @deprecated Use {@link #unregisterCallback} instead. + * @hide */ + @Deprecated + @SystemApi public void removeListener(Listener listener) { - if (listener != null) { - mListeners.remove(listener); - } + unregisterCallback(listener); } + /** {@hide} */ Call(Phone phone, String telecomCallId, InCallAdapter inCallAdapter) { mPhone = phone; @@ -889,8 +920,7 @@ public final class Call { parcelableCall.getGatewayInfo(), parcelableCall.getVideoState(), parcelableCall.getStatusHints(), - parcelableCall.getExtras(), - parcelableCall.getCallSubstate()); + parcelableCall.getExtras()); boolean detailsChanged = !Objects.equals(mDetails, details); if (detailsChanged) { mDetails = details; @@ -908,7 +938,7 @@ public final class Call { mVideoCall = parcelableCall.getVideoCall(); } - int state = stateFromParcelableCallState(parcelableCall.getState()); + int state = parcelableCall.getState(); boolean stateChanged = mState != state; if (stateChanged) { mState = state; @@ -991,84 +1021,56 @@ public final class Call { } private void fireStateChanged(int newState) { - for (Listener listener : mListeners) { - listener.onStateChanged(this, newState); + for (Callback callback : mCallbacks) { + callback.onStateChanged(this, newState); } } private void fireParentChanged(Call newParent) { - for (Listener listener : mListeners) { - listener.onParentChanged(this, newParent); + for (Callback callback : mCallbacks) { + callback.onParentChanged(this, newParent); } } private void fireChildrenChanged(List<Call> children) { - for (Listener listener : mListeners) { - listener.onChildrenChanged(this, children); + for (Callback callback : mCallbacks) { + callback.onChildrenChanged(this, children); } } private void fireDetailsChanged(Details details) { - for (Listener listener : mListeners) { - listener.onDetailsChanged(this, details); + for (Callback callback : mCallbacks) { + callback.onDetailsChanged(this, details); } } private void fireCannedTextResponsesLoaded(List<String> cannedTextResponses) { - for (Listener listener : mListeners) { - listener.onCannedTextResponsesLoaded(this, cannedTextResponses); + for (Callback callback : mCallbacks) { + callback.onCannedTextResponsesLoaded(this, cannedTextResponses); } } private void fireVideoCallChanged(InCallService.VideoCall videoCall) { - for (Listener listener : mListeners) { - listener.onVideoCallChanged(this, videoCall); + for (Callback callback : mCallbacks) { + callback.onVideoCallChanged(this, videoCall); } } private void firePostDialWait(String remainingPostDialSequence) { - for (Listener listener : mListeners) { - listener.onPostDialWait(this, remainingPostDialSequence); + for (Callback callback : mCallbacks) { + callback.onPostDialWait(this, remainingPostDialSequence); } } private void fireCallDestroyed() { - for (Listener listener : mListeners) { - listener.onCallDestroyed(this); + for (Callback callback : mCallbacks) { + callback.onCallDestroyed(this); } } private void fireConferenceableCallsChanged() { - for (Listener listener : mListeners) { - listener.onConferenceableCallsChanged(this, mUnmodifiableConferenceableCalls); - } - } - - private int stateFromParcelableCallState(int parcelableCallState) { - switch (parcelableCallState) { - case CallState.NEW: - return STATE_NEW; - case CallState.CONNECTING: - return STATE_CONNECTING; - case CallState.PRE_DIAL_WAIT: - return STATE_PRE_DIAL_WAIT; - case CallState.DIALING: - return STATE_DIALING; - case CallState.RINGING: - return STATE_RINGING; - case CallState.ACTIVE: - return STATE_ACTIVE; - case CallState.ON_HOLD: - return STATE_HOLDING; - case CallState.DISCONNECTED: - return STATE_DISCONNECTED; - case CallState.ABORTED: - return STATE_DISCONNECTED; - case CallState.DISCONNECTING: - return STATE_DISCONNECTING; - default: - Log.wtf(this, "Unrecognized CallState %s", parcelableCallState); - return STATE_NEW; + for (Callback callback : mCallbacks) { + callback.onConferenceableCallsChanged(this, mUnmodifiableConferenceableCalls); } } } |