diff options
Diffstat (limited to 'telecomm/java/android/telecom/Connection.java')
-rw-r--r-- | telecomm/java/android/telecom/Connection.java | 132 |
1 files changed, 94 insertions, 38 deletions
diff --git a/telecomm/java/android/telecom/Connection.java b/telecomm/java/android/telecom/Connection.java index cd10050..fba4e6a 100644 --- a/telecomm/java/android/telecom/Connection.java +++ b/telecomm/java/android/telecom/Connection.java @@ -16,9 +16,11 @@ package android.telecom; +import com.android.internal.os.SomeArgs; import com.android.internal.telecom.IVideoCallback; import com.android.internal.telecom.IVideoProvider; +import android.annotation.SystemApi; import android.net.Uri; import android.os.Handler; import android.os.IBinder; @@ -45,7 +47,7 @@ import java.util.concurrent.ConcurrentHashMap; * must call {@link #destroy()} to signal to the framework that the {@code Connection} is no * longer used and associated resources may be recovered. */ -public abstract class Connection implements Conferenceable { +public abstract class Connection extends Conferenceable { public static final int STATE_INITIALIZING = 0; @@ -105,38 +107,32 @@ public abstract class Connection implements Conferenceable { /** * Local device supports receiving video. - * @hide */ public static final int CAPABILITY_SUPPORTS_VT_LOCAL_RX = 0x00000100; /** * Local device supports transmitting video. - * @hide */ public static final int CAPABILITY_SUPPORTS_VT_LOCAL_TX = 0x00000200; /** * Local device supports bidirectional video calling. - * @hide */ public static final int CAPABILITY_SUPPORTS_VT_LOCAL_BIDIRECTIONAL = CAPABILITY_SUPPORTS_VT_LOCAL_RX | CAPABILITY_SUPPORTS_VT_LOCAL_TX; /** * Remote device supports receiving video. - * @hide */ public static final int CAPABILITY_SUPPORTS_VT_REMOTE_RX = 0x00000400; /** * Remote device supports transmitting video. - * @hide */ public static final int CAPABILITY_SUPPORTS_VT_REMOTE_TX = 0x00000800; /** * Remote device supports bidirectional video calling. - * @hide */ public static final int CAPABILITY_SUPPORTS_VT_REMOTE_BIDIRECTIONAL = CAPABILITY_SUPPORTS_VT_REMOTE_RX | CAPABILITY_SUPPORTS_VT_REMOTE_TX; @@ -186,14 +182,12 @@ public abstract class Connection implements Conferenceable { /** * Call can be upgraded to a video call. - * @hide */ public static final int CAPABILITY_CAN_UPGRADE_TO_VIDEO = 0x00080000; /** * For video calls, indicates whether the outgoing video for the call can be paused using - * the {@link android.telecom.VideoProfile.VideoState#PAUSED} VideoState. - * @hide + * the {@link android.telecom.VideoProfile#STATE_PAUSED} VideoState. */ public static final int CAPABILITY_CAN_PAUSE_VIDEO = 0x00100000; @@ -339,6 +333,7 @@ public abstract class Connection implements Conferenceable { public void onConferenceParticipantsChanged(Connection c, List<ConferenceParticipant> participants) {} public void onConferenceStarted() {} + public void onConferenceMergeFailed(Connection c) {} } public static abstract class VideoProvider { @@ -470,9 +465,16 @@ public abstract class Connection implements Conferenceable { case MSG_SET_ZOOM: onSetZoom((Float) msg.obj); break; - case MSG_SEND_SESSION_MODIFY_REQUEST: - onSendSessionModifyRequest((VideoProfile) msg.obj); + case MSG_SEND_SESSION_MODIFY_REQUEST: { + SomeArgs args = (SomeArgs) msg.obj; + try { + onSendSessionModifyRequest((VideoProfile) args.arg1, + (VideoProfile) args.arg2); + } finally { + args.recycle(); + } break; + } case MSG_SEND_SESSION_MODIFY_RESPONSE: onSendSessionModifyResponse((VideoProfile) msg.obj); break; @@ -483,7 +485,7 @@ public abstract class Connection implements Conferenceable { onRequestConnectionDataUsage(); break; case MSG_SET_PAUSE_IMAGE: - onSetPauseImage((String) msg.obj); + onSetPauseImage((Uri) msg.obj); break; default: break; @@ -526,9 +528,11 @@ public abstract class Connection implements Conferenceable { mMessageHandler.obtainMessage(MSG_SET_ZOOM, value).sendToTarget(); } - public void sendSessionModifyRequest(VideoProfile requestProfile) { - mMessageHandler.obtainMessage( - MSG_SEND_SESSION_MODIFY_REQUEST, requestProfile).sendToTarget(); + public void sendSessionModifyRequest(VideoProfile fromProfile, VideoProfile toProfile) { + SomeArgs args = SomeArgs.obtain(); + args.arg1 = fromProfile; + args.arg2 = toProfile; + mMessageHandler.obtainMessage(MSG_SEND_SESSION_MODIFY_REQUEST, args).sendToTarget(); } public void sendSessionModifyResponse(VideoProfile responseProfile) { @@ -544,7 +548,7 @@ public abstract class Connection implements Conferenceable { mMessageHandler.obtainMessage(MSG_REQUEST_CONNECTION_DATA_USAGE).sendToTarget(); } - public void setPauseImage(String uri) { + public void setPauseImage(Uri uri) { mMessageHandler.obtainMessage(MSG_SET_PAUSE_IMAGE, uri).sendToTarget(); } } @@ -605,9 +609,11 @@ public abstract class Connection implements Conferenceable { * Some examples of session modification requests: upgrade connection from audio to video, * downgrade connection from video to audio, pause video. * - * @param requestProfile The requested connection video properties. + * @param fromProfile The video properties prior to the request. + * @param toProfile The video properties with the requested changes made. */ - public abstract void onSendSessionModifyRequest(VideoProfile requestProfile); + public abstract void onSendSessionModifyRequest(VideoProfile fromProfile, + VideoProfile toProfile); /**te * Provides a response to a request to change the current connection session video @@ -637,7 +643,7 @@ public abstract class Connection implements Conferenceable { * * @param uri URI of image to display. */ - public abstract void onSetPauseImage(String uri); + public abstract void onSetPauseImage(Uri uri); /** * Invokes callback method defined in listening {@link InCallService} implementations. @@ -721,7 +727,7 @@ public abstract class Connection implements Conferenceable { * * @param dataUsage The updated data usage. */ - public void changeCallDataUsage(long dataUsage) { + public void setCallDataUsage(long dataUsage) { if (mVideoCallbacks != null) { try { for (IVideoCallback callback : mVideoCallbacks.values()) { @@ -735,9 +741,20 @@ public abstract class Connection implements Conferenceable { /** * Invokes callback method defined in listening {@link InCallService} implementations. * + * @param dataUsage The updated data usage. + * @deprecated - Use {@link #setCallDataUsage(long)} instead. + * @hide + */ + public void changeCallDataUsage(long dataUsage) { + setCallDataUsage(dataUsage); + } + + /** + * Invokes callback method defined in listening {@link InCallService} implementations. + * * @param cameraCapabilities The changed camera capabilities. */ - public void changeCameraCapabilities(CameraCapabilities cameraCapabilities) { + public void changeCameraCapabilities(VideoProfile.CameraCapabilities cameraCapabilities) { if (mVideoCallbacks != null) { try { for (IVideoCallback callback : mVideoCallbacks.values()) { @@ -751,6 +768,12 @@ public abstract class Connection implements Conferenceable { /** * Invokes callback method defined in listening {@link InCallService} implementations. * + * Allowed values: + * {@link VideoProfile#QUALITY_HIGH}, + * {@link VideoProfile#QUALITY_MEDIUM}, + * {@link VideoProfile#QUALITY_LOW}, + * {@link VideoProfile#QUALITY_DEFAULT}. + * * @param videoQuality The updated video quality. */ public void changeVideoQuality(int videoQuality) { @@ -795,7 +818,7 @@ public abstract class Connection implements Conferenceable { Collections.unmodifiableList(mConferenceables); private int mState = STATE_NEW; - private AudioState mAudioState; + private CallAudioState mCallAudioState; private Uri mAddress; private int mAddressPresentation; private String mCallerDisplayName; @@ -854,10 +877,10 @@ public abstract class Connection implements Conferenceable { /** * Returns the video state of the connection. - * Valid values: {@link VideoProfile.VideoState#AUDIO_ONLY}, - * {@link VideoProfile.VideoState#BIDIRECTIONAL}, - * {@link VideoProfile.VideoState#TX_ENABLED}, - * {@link VideoProfile.VideoState#RX_ENABLED}. + * Valid values: {@link VideoProfile#STATE_AUDIO_ONLY}, + * {@link VideoProfile#STATE_BIDIRECTIONAL}, + * {@link VideoProfile#STATE_TX_ENABLED}, + * {@link VideoProfile#STATE_RX_ENABLED}. * * @return The video state of the connection. * @hide @@ -870,9 +893,22 @@ public abstract class Connection implements Conferenceable { * @return The audio state of the connection, describing how its audio is currently * being routed by the system. This is {@code null} if this Connection * does not directly know about its audio state. + * @deprecated Use {@link #getCallAudioState()} instead. + * @hide */ + @SystemApi + @Deprecated public final AudioState getAudioState() { - return mAudioState; + return new AudioState(mCallAudioState); + } + + /** + * @return The audio state of the connection, describing how its audio is currently + * being routed by the system. This is {@code null} if this Connection + * does not directly know about its audio state. + */ + public final CallAudioState getCallAudioState() { + return mCallAudioState; } /** @@ -946,11 +982,12 @@ public abstract class Connection implements Conferenceable { * @param state The new audio state. * @hide */ - final void setAudioState(AudioState state) { + final void setCallAudioState(CallAudioState state) { checkImmutable(); Log.d(this, "setAudioState %s", state); - mAudioState = state; - onAudioStateChanged(state); + mCallAudioState = state; + onAudioStateChanged(getAudioState()); + onCallAudioStateChanged(state); } /** @@ -1022,13 +1059,12 @@ public abstract class Connection implements Conferenceable { /** * Set the video state for the connection. - * Valid values: {@link VideoProfile.VideoState#AUDIO_ONLY}, - * {@link VideoProfile.VideoState#BIDIRECTIONAL}, - * {@link VideoProfile.VideoState#TX_ENABLED}, - * {@link VideoProfile.VideoState#RX_ENABLED}. + * Valid values: {@link VideoProfile#STATE_AUDIO_ONLY}, + * {@link VideoProfile#STATE_BIDIRECTIONAL}, + * {@link VideoProfile#STATE_TX_ENABLED}, + * {@link VideoProfile#STATE_RX_ENABLED}. * * @param videoState The new video state. - * @hide */ public final void setVideoState(int videoState) { checkImmutable(); @@ -1092,7 +1128,6 @@ public abstract class Connection implements Conferenceable { /** * Sets the video connection provider. * @param videoProvider The video provider. - * @hide */ public final void setVideoProvider(VideoProvider videoProvider) { checkImmutable(); @@ -1339,10 +1374,21 @@ public abstract class Connection implements Conferenceable { * Notifies this Connection that the {@link #getAudioState()} property has a new value. * * @param state The new connection audio state. + * @deprecated Use {@link #onCallAudioStateChanged(CallAudioState)} instead. + * @hide */ + @SystemApi + @Deprecated public void onAudioStateChanged(AudioState state) {} /** + * Notifies this Connection that the {@link #getCallAudioState()} property has a new value. + * + * @param state The new connection audio state. + */ + public void onCallAudioStateChanged(CallAudioState state) {} + + /** * Notifies this Connection of an internal state change. This method is called after the * state is changed. * @@ -1401,7 +1447,6 @@ public abstract class Connection implements Conferenceable { * a request to accept. * * @param videoState The video state in which to answer the connection. - * @hide */ public void onAnswer(int videoState) {} @@ -1544,6 +1589,17 @@ public abstract class Connection implements Conferenceable { } /** + * Notifies listeners that the merge request failed. + * + * @hide + */ + protected final void notifyConferenceMergeFailed() { + for (Listener l : mListeners) { + l.onConferenceMergeFailed(this); + } + } + + /** * Notifies listeners of a change to conference participant(s). * * @param conferenceParticipants The participants. |