diff options
Diffstat (limited to 'telecomm/java/android')
| -rw-r--r-- | telecomm/java/android/telecom/Call.java | 88 | ||||
| -rw-r--r-- | telecomm/java/android/telecom/InCallService.java | 35 | ||||
| -rw-r--r-- | telecomm/java/android/telecom/VideoCallImpl.java | 22 |
3 files changed, 97 insertions, 48 deletions
diff --git a/telecomm/java/android/telecom/Call.java b/telecomm/java/android/telecom/Call.java index 33a7fe1..f0bc25d 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; @@ -514,7 +515,7 @@ public final class Call { } } - 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 +599,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 +708,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 +850,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; @@ -991,56 +1027,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); + for (Callback callback : mCallbacks) { + callback.onConferenceableCallsChanged(this, mUnmodifiableConferenceableCalls); } } diff --git a/telecomm/java/android/telecom/InCallService.java b/telecomm/java/android/telecom/InCallService.java index a17474a..4229db8 100644 --- a/telecomm/java/android/telecom/InCallService.java +++ b/telecomm/java/android/telecom/InCallService.java @@ -357,12 +357,19 @@ public abstract class InCallService extends Service { public static abstract class VideoCall { /** - * Sets a listener to invoke callback methods in the InCallUI after performing video - * telephony actions. + * Registers a callback to receive c ommands and state changes for video calls. * - * @param videoCallListener The call video client. + * @param callback The vdieo call callback. */ - public abstract void setVideoCallListener(VideoCall.Listener videoCallListener); + public abstract void registerCallback(VideoCall.Callback callback); + + /** + * @deprecated Use {@code VideoCall#registerCallback} instead. + */ + @Deprecated + public void setVideoCallListener(VideoCall.Listener videoCallListener) { + registerCallback(videoCallListener); + } /** * Sets the camera to be used for video recording in a video call. @@ -405,7 +412,7 @@ public abstract class InCallService extends Service { /** * Issues a request to modify the properties of the current session. The request is sent to * the remote device where it it handled by - * {@link VideoCall.Listener#onSessionModifyRequestReceived}. + * {@link VideoCall.Callback#onSessionModifyRequestReceived}. * Some examples of session modification requests: upgrade call from audio to video, * downgrade call from video to audio, pause video. * @@ -417,9 +424,9 @@ public abstract class InCallService extends Service { * Provides a response to a request to change the current call session video * properties. * This is in response to a request the InCall UI has received via - * {@link VideoCall.Listener#onSessionModifyRequestReceived}. + * {@link VideoCall.Callback#onSessionModifyRequestReceived}. * The response is handled on the remove device by - * {@link VideoCall.Listener#onSessionModifyResponseReceived}. + * {@link VideoCall.Callback#onSessionModifyResponseReceived}. * * @param responseProfile The response call video properties. */ @@ -428,14 +435,14 @@ public abstract class InCallService extends Service { /** * Issues a request to the video provider to retrieve the camera capabilities. * Camera capabilities are reported back to the caller via - * {@link VideoCall.Listener#onCameraCapabilitiesChanged(CameraCapabilities)}. + * {@link VideoCall.Callback#onCameraCapabilitiesChanged(CameraCapabilities)}. */ public abstract void requestCameraCapabilities(); /** * Issues a request to the video telephony framework to retrieve the cumulative data usage for * the current call. Data usage is reported back to the caller via - * {@link VideoCall.Listener#onCallDataUsageChanged}. + * {@link VideoCall.Callback#onCallDataUsageChanged}. */ public abstract void requestCallDataUsage(); @@ -448,9 +455,9 @@ public abstract class InCallService extends Service { public abstract void setPauseImage(String uri); /** - * Listener class which invokes callbacks after video call actions occur. + * Callback class which invokes callbacks after video call actions occur. */ - public static abstract class Listener { + public static abstract class Callback { /** * Called when a session modification request is received from the remote device. * The remote request is sent via @@ -527,5 +534,11 @@ public abstract class InCallService extends Service { */ public abstract void onCameraCapabilitiesChanged(CameraCapabilities cameraCapabilities); } + + /** + * @deprecated Use {@code VideoCall.Callback} instead. + */ + @Deprecated + public static abstract class Listener extends Callback { } } } diff --git a/telecomm/java/android/telecom/VideoCallImpl.java b/telecomm/java/android/telecom/VideoCallImpl.java index 0445448..7bef688 100644 --- a/telecomm/java/android/telecom/VideoCallImpl.java +++ b/telecomm/java/android/telecom/VideoCallImpl.java @@ -46,7 +46,7 @@ public class VideoCallImpl extends VideoCall { private final IVideoProvider mVideoProvider; private final VideoCallListenerBinder mBinder; - private VideoCall.Listener mVideoCallListener; + private VideoCall.Callback mCallback; private IBinder.DeathRecipient mDeathRecipient = new IBinder.DeathRecipient() { @Override @@ -109,14 +109,14 @@ public class VideoCallImpl extends VideoCall { private final Handler mHandler = new Handler(Looper.getMainLooper()) { @Override public void handleMessage(Message msg) { - if (mVideoCallListener == null) { + if (mCallback == null) { return; } SomeArgs args; switch (msg.what) { case MSG_RECEIVE_SESSION_MODIFY_REQUEST: - mVideoCallListener.onSessionModifyRequestReceived((VideoProfile) msg.obj); + mCallback.onSessionModifyRequestReceived((VideoProfile) msg.obj); break; case MSG_RECEIVE_SESSION_MODIFY_RESPONSE: args = (SomeArgs) msg.obj; @@ -125,34 +125,34 @@ public class VideoCallImpl extends VideoCall { VideoProfile requestProfile = (VideoProfile) args.arg2; VideoProfile responseProfile = (VideoProfile) args.arg3; - mVideoCallListener.onSessionModifyResponseReceived( + mCallback.onSessionModifyResponseReceived( status, requestProfile, responseProfile); } finally { args.recycle(); } break; case MSG_HANDLE_CALL_SESSION_EVENT: - mVideoCallListener.onCallSessionEvent((int) msg.obj); + mCallback.onCallSessionEvent((int) msg.obj); break; case MSG_CHANGE_PEER_DIMENSIONS: args = (SomeArgs) msg.obj; try { int width = (int) args.arg1; int height = (int) args.arg2; - mVideoCallListener.onPeerDimensionsChanged(width, height); + mCallback.onPeerDimensionsChanged(width, height); } finally { args.recycle(); } break; case MSG_CHANGE_CALL_DATA_USAGE: - mVideoCallListener.onCallDataUsageChanged((long) msg.obj); + mCallback.onCallDataUsageChanged((long) msg.obj); break; case MSG_CHANGE_CAMERA_CAPABILITIES: - mVideoCallListener.onCameraCapabilitiesChanged( + mCallback.onCameraCapabilitiesChanged( (CameraCapabilities) msg.obj); break; case MSG_CHANGE_VIDEO_QUALITY: - mVideoCallListener.onVideoQualityChanged(msg.arg1); + mCallback.onVideoQualityChanged(msg.arg1); break; default: break; @@ -170,8 +170,8 @@ public class VideoCallImpl extends VideoCall { } /** {@inheritDoc} */ - public void setVideoCallListener(VideoCall.Listener videoCallListener) { - mVideoCallListener = videoCallListener; + public void registerCallback(VideoCall.Callback callback) { + mCallback = callback; } /** {@inheritDoc} */ |
