Move VideoCallProvider into ConnectionService.
Bug: 16494880
Change-Id: I0778197d06fcd219db4a1e1fa065e69026254a99
diff --git a/api/current.txt b/api/current.txt
index 713b8d5..b1b1708 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -28613,7 +28613,7 @@
method public final android.telecomm.Connection getParentConnection();
method public final int getState();
method public final android.telecomm.StatusHints getStatusHints();
- method public final android.telecomm.VideoCallProvider getVideoCallProvider();
+ method public final android.telecomm.ConnectionService.VideoCallProvider getVideoCallProvider();
method public final int getVideoState();
method public final boolean isConferenceConnection();
method public final boolean isRequestingRingback();
@@ -28650,7 +28650,7 @@
method public final void setRinging();
method public final void setSignal(android.os.Bundle);
method public final void setStatusHints(android.telecomm.StatusHints);
- method public final void setVideoCallProvider(android.telecomm.VideoCallProvider);
+ method public final void setVideoCallProvider(android.telecomm.ConnectionService.VideoCallProvider);
method public final void setVideoState(int);
method public final void startActivityFromInCall(android.app.PendingIntent);
method public static java.lang.String stateToString(int);
@@ -28702,6 +28702,26 @@
method public abstract void onSuccess(android.telecomm.ConnectionRequest, CONNECTION);
}
+ public static abstract class ConnectionService.VideoCallProvider {
+ ctor public ConnectionService.VideoCallProvider();
+ method public void changeCallDataUsage(int);
+ method public void changeCameraCapabilities(android.telecomm.CallCameraCapabilities);
+ method public void changePeerDimensions(int, int);
+ method public void handleCallSessionEvent(int);
+ method public abstract void onRequestCallDataUsage();
+ method public abstract void onRequestCameraCapabilities();
+ method public abstract void onSendSessionModifyRequest(android.telecomm.VideoCallProfile);
+ method public abstract void onSendSessionModifyResponse(android.telecomm.VideoCallProfile);
+ method public abstract void onSetCamera(java.lang.String);
+ method public abstract void onSetDeviceOrientation(int);
+ method public abstract void onSetDisplaySurface(android.view.Surface);
+ method public abstract void onSetPauseImage(java.lang.String);
+ method public abstract void onSetPreviewSurface(android.view.Surface);
+ method public abstract void onSetZoom(float);
+ method public void receiveSessionModifyRequest(android.telecomm.VideoCallProfile);
+ method public void receiveSessionModifyResponse(int, android.telecomm.VideoCallProfile, android.telecomm.VideoCallProfile);
+ }
+
public class GatewayInfo implements android.os.Parcelable {
method public int describeContents();
method public android.net.Uri getGatewayHandle();
@@ -28934,26 +28954,6 @@
field public static final int VIDEO_STATE_TX_ENABLED = 1; // 0x1
}
- public abstract class VideoCallProvider {
- ctor public VideoCallProvider();
- method public void changeCallDataUsage(int);
- method public void changeCameraCapabilities(android.telecomm.CallCameraCapabilities);
- method public void changePeerDimensions(int, int);
- method public void handleCallSessionEvent(int);
- method public abstract void onRequestCallDataUsage();
- method public abstract void onRequestCameraCapabilities();
- method public abstract void onSendSessionModifyRequest(android.telecomm.VideoCallProfile);
- method public abstract void onSendSessionModifyResponse(android.telecomm.VideoCallProfile);
- method public abstract void onSetCamera(java.lang.String);
- method public abstract void onSetDeviceOrientation(int);
- method public abstract void onSetDisplaySurface(android.view.Surface);
- method public abstract void onSetPauseImage(java.lang.String);
- method public abstract void onSetPreviewSurface(android.view.Surface);
- method public abstract void onSetZoom(float);
- method public void receiveSessionModifyRequest(android.telecomm.VideoCallProfile);
- method public void receiveSessionModifyResponse(int, android.telecomm.VideoCallProfile, android.telecomm.VideoCallProfile);
- }
-
}
package android.telephony {
@@ -39777,8 +39777,8 @@
method public void setLogo(android.graphics.drawable.Drawable);
method public void setLogoDescription(int);
method public void setLogoDescription(java.lang.CharSequence);
- method public void setNavigationContentDescription(java.lang.CharSequence);
method public void setNavigationContentDescription(int);
+ method public void setNavigationContentDescription(java.lang.CharSequence);
method public void setNavigationIcon(int);
method public void setNavigationIcon(android.graphics.drawable.Drawable);
method public void setNavigationOnClickListener(android.view.View.OnClickListener);
diff --git a/telecomm/java/android/telecomm/Connection.java b/telecomm/java/android/telecomm/Connection.java
index 6043232..322dafe 100644
--- a/telecomm/java/android/telecomm/Connection.java
+++ b/telecomm/java/android/telecomm/Connection.java
@@ -44,7 +44,8 @@
public void onDestroyed(Connection c) {}
public void onCallCapabilitiesChanged(Connection c, int callCapabilities) {}
public void onParentConnectionChanged(Connection c, Connection parent) {}
- public void onVideoCallProviderChanged(Connection c, VideoCallProvider videoCallProvider) {}
+ public void onVideoCallProviderChanged(
+ Connection c, ConnectionService.VideoCallProvider videoCallProvider) {}
public void onAudioModeIsVoipChanged(Connection c, boolean isVoip) {}
public void onStatusHintsChanged(Connection c, StatusHints statusHints) {}
public void onStartActivityFromInCall(Connection c, PendingIntent intent) {}
@@ -78,7 +79,7 @@
private boolean mRequestingRingback = false;
private int mCallCapabilities;
private Connection mParentConnection;
- private VideoCallProvider mVideoCallProvider;
+ private ConnectionService.VideoCallProvider mVideoCallProvider;
private boolean mAudioModeIsVoip;
private StatusHints mStatusHints;
private int mVideoState;
@@ -417,14 +418,14 @@
* Sets the video call provider.
* @param videoCallProvider The video call provider.
*/
- public final void setVideoCallProvider(VideoCallProvider videoCallProvider) {
+ public final void setVideoCallProvider(ConnectionService.VideoCallProvider videoCallProvider) {
mVideoCallProvider = videoCallProvider;
for (Listener l : mListeners) {
l.onVideoCallProviderChanged(this, videoCallProvider);
}
}
- public final VideoCallProvider getVideoCallProvider() {
+ public final ConnectionService.VideoCallProvider getVideoCallProvider() {
return mVideoCallProvider;
}
diff --git a/telecomm/java/android/telecomm/ConnectionService.java b/telecomm/java/android/telecomm/ConnectionService.java
index 51876df..cefa929 100644
--- a/telecomm/java/android/telecomm/ConnectionService.java
+++ b/telecomm/java/android/telecomm/ConnectionService.java
@@ -29,9 +29,14 @@
import android.os.Looper;
import android.os.Message;
import android.telephony.DisconnectCause;
+import android.os.RemoteException;
+import android.view.Surface;
+
import com.android.internal.os.SomeArgs;
import com.android.internal.telecomm.IConnectionService;
import com.android.internal.telecomm.IConnectionServiceAdapter;
+import com.android.internal.telecomm.IVideoCallCallback;
+import com.android.internal.telecomm.IVideoCallProvider;
import com.android.internal.telecomm.RemoteServiceCallback;
import java.util.Collection;
@@ -758,4 +763,312 @@
Log.w(this, "%s - Cannot find Connection %s", action, callId);
return NULL_CONNECTION;
}
+
+ public static abstract class VideoCallProvider {
+ private static final int MSG_SET_VIDEO_CALL_LISTENER = 1;
+ private static final int MSG_SET_CAMERA = 2;
+ private static final int MSG_SET_PREVIEW_SURFACE = 3;
+ private static final int MSG_SET_DISPLAY_SURFACE = 4;
+ private static final int MSG_SET_DEVICE_ORIENTATION = 5;
+ private static final int MSG_SET_ZOOM = 6;
+ private static final int MSG_SEND_SESSION_MODIFY_REQUEST = 7;
+ private static final int MSG_SEND_SESSION_MODIFY_RESPONSE = 8;
+ private static final int MSG_REQUEST_CAMERA_CAPABILITIES = 9;
+ private static final int MSG_REQUEST_CALL_DATA_USAGE = 10;
+ private static final int MSG_SET_PAUSE_IMAGE = 11;
+
+ private final VideoCallProviderHandler mMessageHandler = new VideoCallProviderHandler();
+ private final VideoCallProviderBinder mBinder;
+ private IVideoCallCallback mVideoCallListener;
+
+ /**
+ * Default handler used to consolidate binder method calls onto a single thread.
+ */
+ private final class VideoCallProviderHandler extends Handler {
+ @Override
+ public void handleMessage(Message msg) {
+ switch (msg.what) {
+ case MSG_SET_VIDEO_CALL_LISTENER:
+ mVideoCallListener = IVideoCallCallback.Stub.asInterface((IBinder) msg.obj);
+ break;
+ case MSG_SET_CAMERA:
+ onSetCamera((String) msg.obj);
+ break;
+ case MSG_SET_PREVIEW_SURFACE:
+ onSetPreviewSurface((Surface) msg.obj);
+ break;
+ case MSG_SET_DISPLAY_SURFACE:
+ onSetDisplaySurface((Surface) msg.obj);
+ break;
+ case MSG_SET_DEVICE_ORIENTATION:
+ onSetDeviceOrientation(msg.arg1);
+ break;
+ case MSG_SET_ZOOM:
+ onSetZoom((Float) msg.obj);
+ break;
+ case MSG_SEND_SESSION_MODIFY_REQUEST:
+ onSendSessionModifyRequest((VideoCallProfile) msg.obj);
+ break;
+ case MSG_SEND_SESSION_MODIFY_RESPONSE:
+ onSendSessionModifyResponse((VideoCallProfile) msg.obj);
+ break;
+ case MSG_REQUEST_CAMERA_CAPABILITIES:
+ onRequestCameraCapabilities();
+ break;
+ case MSG_REQUEST_CALL_DATA_USAGE:
+ onRequestCallDataUsage();
+ break;
+ case MSG_SET_PAUSE_IMAGE:
+ onSetPauseImage((String) msg.obj);
+ break;
+ default:
+ break;
+ }
+ }
+ }
+
+ /**
+ * IVideoCallProvider stub implementation.
+ */
+ private final class VideoCallProviderBinder extends IVideoCallProvider.Stub {
+ public void setVideoCallListener(IBinder videoCallListenerBinder) {
+ mMessageHandler.obtainMessage(
+ MSG_SET_VIDEO_CALL_LISTENER, videoCallListenerBinder).sendToTarget();
+ }
+
+ public void setCamera(String cameraId) {
+ mMessageHandler.obtainMessage(MSG_SET_CAMERA, cameraId).sendToTarget();
+ }
+
+ public void setPreviewSurface(Surface surface) {
+ mMessageHandler.obtainMessage(MSG_SET_PREVIEW_SURFACE, surface).sendToTarget();
+ }
+
+ public void setDisplaySurface(Surface surface) {
+ mMessageHandler.obtainMessage(MSG_SET_DISPLAY_SURFACE, surface).sendToTarget();
+ }
+
+ public void setDeviceOrientation(int rotation) {
+ mMessageHandler.obtainMessage(MSG_SET_DEVICE_ORIENTATION, rotation).sendToTarget();
+ }
+
+ public void setZoom(float value) {
+ mMessageHandler.obtainMessage(MSG_SET_ZOOM, value).sendToTarget();
+ }
+
+ public void sendSessionModifyRequest(VideoCallProfile requestProfile) {
+ mMessageHandler.obtainMessage(
+ MSG_SEND_SESSION_MODIFY_REQUEST, requestProfile).sendToTarget();
+ }
+
+ public void sendSessionModifyResponse(VideoCallProfile responseProfile) {
+ mMessageHandler.obtainMessage(
+ MSG_SEND_SESSION_MODIFY_RESPONSE, responseProfile).sendToTarget();
+ }
+
+ public void requestCameraCapabilities() {
+ mMessageHandler.obtainMessage(MSG_REQUEST_CAMERA_CAPABILITIES).sendToTarget();
+ }
+
+ public void requestCallDataUsage() {
+ mMessageHandler.obtainMessage(MSG_REQUEST_CALL_DATA_USAGE).sendToTarget();
+ }
+
+ public void setPauseImage(String uri) {
+ mMessageHandler.obtainMessage(MSG_SET_PAUSE_IMAGE, uri).sendToTarget();
+ }
+ }
+
+ public VideoCallProvider() {
+ mBinder = new VideoCallProviderBinder();
+ }
+
+ /**
+ * Returns binder object which can be used across IPC methods.
+ * @hide
+ */
+ public final IVideoCallProvider getInterface() {
+ return mBinder;
+ }
+
+ /**
+ * Sets the camera to be used for video recording in a video call.
+ *
+ * @param cameraId The id of the camera.
+ */
+ public abstract void onSetCamera(String cameraId);
+
+ /**
+ * Sets the surface to be used for displaying a preview of what the user's camera is
+ * currently capturing. When video transmission is enabled, this is the video signal which is
+ * sent to the remote device.
+ *
+ * @param surface The surface.
+ */
+ public abstract void onSetPreviewSurface(Surface surface);
+
+ /**
+ * Sets the surface to be used for displaying the video received from the remote device.
+ *
+ * @param surface The surface.
+ */
+ public abstract void onSetDisplaySurface(Surface surface);
+
+ /**
+ * Sets the device orientation, in degrees. Assumes that a standard portrait orientation of the
+ * device is 0 degrees.
+ *
+ * @param rotation The device orientation, in degrees.
+ */
+ public abstract void onSetDeviceOrientation(int rotation);
+
+ /**
+ * Sets camera zoom ratio.
+ *
+ * @param value The camera zoom ratio.
+ */
+ public abstract void onSetZoom(float value);
+
+ /**
+ * 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 InCallService.VideoCall.Listener#onSessionModifyRequestReceived}.
+ * Some examples of session modification requests: upgrade call from audio to video, downgrade
+ * call from video to audio, pause video.
+ *
+ * @param requestProfile The requested call video properties.
+ */
+ public abstract void onSendSessionModifyRequest(VideoCallProfile requestProfile);
+
+ /**te
+ * 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 InCallService.VideoCall.Listener#onSessionModifyRequestReceived}.
+ * The response is handled on the remove device by
+ * {@link InCallService.VideoCall.Listener#onSessionModifyResponseReceived}.
+ *
+ * @param responseProfile The response call video properties.
+ */
+ public abstract void onSendSessionModifyResponse(VideoCallProfile responseProfile);
+
+ /**
+ * Issues a request to the video provider to retrieve the camera capabilities.
+ * Camera capabilities are reported back to the caller via
+ * {@link InCallService.VideoCall.Listener#onCameraCapabilitiesChanged(CallCameraCapabilities)}.
+ */
+ public abstract void onRequestCameraCapabilities();
+
+ /**
+ * 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 InCallService.VideoCall.Listener#onCallDataUsageChanged}.
+ */
+ public abstract void onRequestCallDataUsage();
+
+ /**
+ * Provides the video telephony framework with the URI of an image to be displayed to remote
+ * devices when the video signal is paused.
+ *
+ * @param uri URI of image to display.
+ */
+ public abstract void onSetPauseImage(String uri);
+
+ /**
+ * Invokes callback method defined in {@link InCallService.VideoCall.Listener}.
+ *
+ * @param videoCallProfile The requested video call profile.
+ */
+ public void receiveSessionModifyRequest(VideoCallProfile videoCallProfile) {
+ if (mVideoCallListener != null) {
+ try {
+ mVideoCallListener.receiveSessionModifyRequest(videoCallProfile);
+ } catch (RemoteException ignored) {
+ }
+ }
+ }
+
+ /**
+ * Invokes callback method defined in {@link InCallService.VideoCall.Listener}.
+ *
+ * @param status Status of the session modify request. Valid values are
+ * {@link InCallService.VideoCall#SESSION_MODIFY_REQUEST_SUCCESS},
+ * {@link InCallService.VideoCall#SESSION_MODIFY_REQUEST_FAIL},
+ * {@link InCallService.VideoCall#SESSION_MODIFY_REQUEST_INVALID}
+ * @param requestedProfile The original request which was sent to the remote device.
+ * @param responseProfile The actual profile changes made by the remote device.
+ */
+ public void receiveSessionModifyResponse(int status,
+ VideoCallProfile requestedProfile, VideoCallProfile responseProfile) {
+ if (mVideoCallListener != null) {
+ try {
+ mVideoCallListener.receiveSessionModifyResponse(
+ status, requestedProfile, responseProfile);
+ } catch (RemoteException ignored) {
+ }
+ }
+ }
+
+ /**
+ * Invokes callback method defined in {@link InCallService.VideoCall.Listener}.
+ *
+ * Valid values are: {@link InCallService.VideoCall#SESSION_EVENT_RX_PAUSE},
+ * {@link InCallService.VideoCall#SESSION_EVENT_RX_RESUME},
+ * {@link InCallService.VideoCall#SESSION_EVENT_TX_START},
+ * {@link InCallService.VideoCall#SESSION_EVENT_TX_STOP}
+ *
+ * @param event The event.
+ */
+ public void handleCallSessionEvent(int event) {
+ if (mVideoCallListener != null) {
+ try {
+ mVideoCallListener.handleCallSessionEvent(event);
+ } catch (RemoteException ignored) {
+ }
+ }
+ }
+
+ /**
+ * Invokes callback method defined in {@link InCallService.VideoCall.Listener}.
+ *
+ * @param width The updated peer video width.
+ * @param height The updated peer video height.
+ */
+ public void changePeerDimensions(int width, int height) {
+ if (mVideoCallListener != null) {
+ try {
+ mVideoCallListener.changePeerDimensions(width, height);
+ } catch (RemoteException ignored) {
+ }
+ }
+ }
+
+ /**
+ * Invokes callback method defined in {@link InCallService.VideoCall.Listener}.
+ *
+ * @param dataUsage The updated data usage.
+ */
+ public void changeCallDataUsage(int dataUsage) {
+ if (mVideoCallListener != null) {
+ try {
+ mVideoCallListener.changeCallDataUsage(dataUsage);
+ } catch (RemoteException ignored) {
+ }
+ }
+ }
+
+ /**
+ * Invokes callback method defined in {@link InCallService.VideoCall.Listener}.
+ *
+ * @param callCameraCapabilities The changed camera capabilities.
+ */
+ public void changeCameraCapabilities(CallCameraCapabilities callCameraCapabilities) {
+ if (mVideoCallListener != null) {
+ try {
+ mVideoCallListener.changeCameraCapabilities(callCameraCapabilities);
+ } catch (RemoteException ignored) {
+ }
+ }
+ }
+ }
}
diff --git a/telecomm/java/android/telecomm/ConnectionServiceAdapter.java b/telecomm/java/android/telecomm/ConnectionServiceAdapter.java
index 8f91e72..ea61362 100644
--- a/telecomm/java/android/telecomm/ConnectionServiceAdapter.java
+++ b/telecomm/java/android/telecomm/ConnectionServiceAdapter.java
@@ -275,7 +275,8 @@
* @param callId The unique ID of the call to set with the given call video provider.
* @param videoCallProvider The call video provider instance to set on the call.
*/
- void setVideoCallProvider(String callId, VideoCallProvider videoCallProvider) {
+ void setVideoCallProvider(
+ String callId, ConnectionService.VideoCallProvider videoCallProvider) {
for (IConnectionServiceAdapter adapter : mAdapters) {
try {
adapter.setVideoCallProvider(
diff --git a/telecomm/java/android/telecomm/InCallService.java b/telecomm/java/android/telecomm/InCallService.java
index 38de08e..14b25dc8 100644
--- a/telecomm/java/android/telecomm/InCallService.java
+++ b/telecomm/java/android/telecomm/InCallService.java
@@ -339,12 +339,13 @@
public static abstract class Listener {
/**
* Called when a session modification request is received from the remote device.
- * The remote request is sent via {@link VideoCallProvider#onSendSessionModifyRequest}.
- * The InCall UI is responsible for potentially prompting the user whether they wish to
- * accept the new call profile (e.g. prompt user if they wish to accept an upgrade from
- * an audio to a video call) and should call
- * {@link VideoCallProvider#onSendSessionModifyResponse} to indicate the video settings
- * the user has agreed to.
+ * The remote request is sent via
+ * {@link ConnectionService.VideoCallProvider#onSendSessionModifyRequest}. The InCall UI
+ * is responsible for potentially prompting the user whether they wish to accept the new
+ * call profile (e.g. prompt user if they wish to accept an upgrade from an audio to a
+ * video call) and should call
+ * {@link ConnectionService.VideoCallProvider#onSendSessionModifyResponse} to indicate
+ * the video settings the user has agreed to.
*
* @param videoCallProfile The requested video call profile.
*/
@@ -353,7 +354,7 @@
/**
* Called when a response to a session modification request is received from the remote
* device. The remote InCall UI sends the response using
- * {@link VideoCallProvider#onSendSessionModifyResponse}.
+ * {@link ConnectionService.VideoCallProvider#onSendSessionModifyResponse}.
*
* @param status Status of the session modify request. Valid values are
* {@link VideoCall#SESSION_MODIFY_REQUEST_SUCCESS},
diff --git a/telecomm/java/android/telecomm/VideoCallImpl.java b/telecomm/java/android/telecomm/VideoCallImpl.java
index 3e538cb..c32bcd2 100644
--- a/telecomm/java/android/telecomm/VideoCallImpl.java
+++ b/telecomm/java/android/telecomm/VideoCallImpl.java
@@ -30,8 +30,8 @@
/**
* Implementation of a Video Call, which allows InCallUi to communicate commands to the underlying
- * {@link VideoCallProvider}, and direct callbacks from the {@link VideoCallProvider} to the
- * appropriate {@link VideoCall.Listener}.
+ * {@link ConnectionService.VideoCallProvider}, and direct callbacks from the
+ * {@link ConnectionService.VideoCallProvider} to the appropriate {@link VideoCall.Listener}.
*/
public class VideoCallImpl extends VideoCall {
private static final int MSG_RECEIVE_SESSION_MODIFY_REQUEST = 1;
diff --git a/telecomm/java/android/telecomm/VideoCallProvider.java b/telecomm/java/android/telecomm/VideoCallProvider.java
deleted file mode 100644
index de0126d..0000000
--- a/telecomm/java/android/telecomm/VideoCallProvider.java
+++ /dev/null
@@ -1,334 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.telecomm;
-
-import android.os.Handler;
-import android.os.IBinder;
-import android.os.Message;
-import android.os.RemoteException;
-import android.view.Surface;
-
-import com.android.internal.telecomm.IVideoCallCallback;
-import com.android.internal.telecomm.IVideoCallProvider;
-
-public abstract class VideoCallProvider {
- private static final int MSG_SET_VIDEO_CALL_LISTENER = 1;
- private static final int MSG_SET_CAMERA = 2;
- private static final int MSG_SET_PREVIEW_SURFACE = 3;
- private static final int MSG_SET_DISPLAY_SURFACE = 4;
- private static final int MSG_SET_DEVICE_ORIENTATION = 5;
- private static final int MSG_SET_ZOOM = 6;
- private static final int MSG_SEND_SESSION_MODIFY_REQUEST = 7;
- private static final int MSG_SEND_SESSION_MODIFY_RESPONSE = 8;
- private static final int MSG_REQUEST_CAMERA_CAPABILITIES = 9;
- private static final int MSG_REQUEST_CALL_DATA_USAGE = 10;
- private static final int MSG_SET_PAUSE_IMAGE = 11;
-
- private final VideoCallProviderHandler mMessageHandler = new VideoCallProviderHandler();
- private final VideoCallProviderBinder mBinder;
- private IVideoCallCallback mVideoCallListener;
-
- /**
- * Default handler used to consolidate binder method calls onto a single thread.
- */
- private final class VideoCallProviderHandler extends Handler {
- @Override
- public void handleMessage(Message msg) {
- switch (msg.what) {
- case MSG_SET_VIDEO_CALL_LISTENER:
- mVideoCallListener = IVideoCallCallback.Stub.asInterface((IBinder) msg.obj);
- break;
- case MSG_SET_CAMERA:
- onSetCamera((String) msg.obj);
- break;
- case MSG_SET_PREVIEW_SURFACE:
- onSetPreviewSurface((Surface) msg.obj);
- break;
- case MSG_SET_DISPLAY_SURFACE:
- onSetDisplaySurface((Surface) msg.obj);
- break;
- case MSG_SET_DEVICE_ORIENTATION:
- onSetDeviceOrientation(msg.arg1);
- break;
- case MSG_SET_ZOOM:
- onSetZoom((Float) msg.obj);
- break;
- case MSG_SEND_SESSION_MODIFY_REQUEST:
- onSendSessionModifyRequest((VideoCallProfile) msg.obj);
- break;
- case MSG_SEND_SESSION_MODIFY_RESPONSE:
- onSendSessionModifyResponse((VideoCallProfile) msg.obj);
- break;
- case MSG_REQUEST_CAMERA_CAPABILITIES:
- onRequestCameraCapabilities();
- break;
- case MSG_REQUEST_CALL_DATA_USAGE:
- onRequestCallDataUsage();
- break;
- case MSG_SET_PAUSE_IMAGE:
- onSetPauseImage((String) msg.obj);
- break;
- default:
- break;
- }
- }
- }
-
- /**
- * IVideoCallProvider stub implementation.
- */
- private final class VideoCallProviderBinder extends IVideoCallProvider.Stub {
- public void setVideoCallListener(IBinder videoCallListenerBinder) {
- mMessageHandler.obtainMessage(
- MSG_SET_VIDEO_CALL_LISTENER, videoCallListenerBinder).sendToTarget();
- }
-
- public void setCamera(String cameraId) {
- mMessageHandler.obtainMessage(MSG_SET_CAMERA, cameraId).sendToTarget();
- }
-
- public void setPreviewSurface(Surface surface) {
- mMessageHandler.obtainMessage(MSG_SET_PREVIEW_SURFACE, surface).sendToTarget();
- }
-
- public void setDisplaySurface(Surface surface) {
- mMessageHandler.obtainMessage(MSG_SET_DISPLAY_SURFACE, surface).sendToTarget();
- }
-
- public void setDeviceOrientation(int rotation) {
- mMessageHandler.obtainMessage(MSG_SET_DEVICE_ORIENTATION, rotation).sendToTarget();
- }
-
- public void setZoom(float value) {
- mMessageHandler.obtainMessage(MSG_SET_ZOOM, value).sendToTarget();
- }
-
- public void sendSessionModifyRequest(VideoCallProfile requestProfile) {
- mMessageHandler.obtainMessage(
- MSG_SEND_SESSION_MODIFY_REQUEST, requestProfile).sendToTarget();
- }
-
- public void sendSessionModifyResponse(VideoCallProfile responseProfile) {
- mMessageHandler.obtainMessage(
- MSG_SEND_SESSION_MODIFY_RESPONSE, responseProfile).sendToTarget();
- }
-
- public void requestCameraCapabilities() {
- mMessageHandler.obtainMessage(MSG_REQUEST_CAMERA_CAPABILITIES).sendToTarget();
- }
-
- public void requestCallDataUsage() {
- mMessageHandler.obtainMessage(MSG_REQUEST_CALL_DATA_USAGE).sendToTarget();
- }
-
- public void setPauseImage(String uri) {
- mMessageHandler.obtainMessage(MSG_SET_PAUSE_IMAGE, uri).sendToTarget();
- }
- }
-
- public VideoCallProvider() {
- mBinder = new VideoCallProviderBinder();
- }
-
- /**
- * Returns binder object which can be used across IPC methods.
- * @hide
- */
- public final IVideoCallProvider getInterface() {
- return mBinder;
- }
-
- /**
- * Sets the camera to be used for video recording in a video call.
- *
- * @param cameraId The id of the camera.
- */
- public abstract void onSetCamera(String cameraId);
-
- /**
- * Sets the surface to be used for displaying a preview of what the user's camera is
- * currently capturing. When video transmission is enabled, this is the video signal which is
- * sent to the remote device.
- *
- * @param surface The surface.
- */
- public abstract void onSetPreviewSurface(Surface surface);
-
- /**
- * Sets the surface to be used for displaying the video received from the remote device.
- *
- * @param surface The surface.
- */
- public abstract void onSetDisplaySurface(Surface surface);
-
- /**
- * Sets the device orientation, in degrees. Assumes that a standard portrait orientation of the
- * device is 0 degrees.
- *
- * @param rotation The device orientation, in degrees.
- */
- public abstract void onSetDeviceOrientation(int rotation);
-
- /**
- * Sets camera zoom ratio.
- *
- * @param value The camera zoom ratio.
- */
- public abstract void onSetZoom(float value);
-
- /**
- * 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 InCallService.VideoCall.Listener#onSessionModifyRequestReceived}.
- * Some examples of session modification requests: upgrade call from audio to video, downgrade
- * call from video to audio, pause video.
- *
- * @param requestProfile The requested call video properties.
- */
- public abstract void onSendSessionModifyRequest(VideoCallProfile requestProfile);
-
- /**te
- * 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 InCallService.VideoCall.Listener#onSessionModifyRequestReceived}.
- * The response is handled on the remove device by
- * {@link InCallService.VideoCall.Listener#onSessionModifyResponseReceived}.
- *
- * @param responseProfile The response call video properties.
- */
- public abstract void onSendSessionModifyResponse(VideoCallProfile responseProfile);
-
- /**
- * Issues a request to the video provider to retrieve the camera capabilities.
- * Camera capabilities are reported back to the caller via
- * {@link InCallService.VideoCall.Listener#onCameraCapabilitiesChanged(CallCameraCapabilities)}.
- */
- public abstract void onRequestCameraCapabilities();
-
- /**
- * 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 InCallService.VideoCall.Listener#onCallDataUsageChanged}.
- */
- public abstract void onRequestCallDataUsage();
-
- /**
- * Provides the video telephony framework with the URI of an image to be displayed to remote
- * devices when the video signal is paused.
- *
- * @param uri URI of image to display.
- */
- public abstract void onSetPauseImage(String uri);
-
- /**
- * Invokes callback method defined in {@link InCallService.VideoCall.Listener}.
- *
- * @param videoCallProfile The requested video call profile.
- */
- public void receiveSessionModifyRequest(VideoCallProfile videoCallProfile) {
- if (mVideoCallListener != null) {
- try {
- mVideoCallListener.receiveSessionModifyRequest(videoCallProfile);
- } catch (RemoteException ignored) {
- }
- }
- }
-
- /**
- * Invokes callback method defined in {@link InCallService.VideoCall.Listener}.
- *
- * @param status Status of the session modify request. Valid values are
- * {@link InCallService.VideoCall#SESSION_MODIFY_REQUEST_SUCCESS},
- * {@link InCallService.VideoCall#SESSION_MODIFY_REQUEST_FAIL},
- * {@link InCallService.VideoCall#SESSION_MODIFY_REQUEST_INVALID}
- * @param requestedProfile The original request which was sent to the remote device.
- * @param responseProfile The actual profile changes made by the remote device.
- */
- public void receiveSessionModifyResponse(int status,
- VideoCallProfile requestedProfile, VideoCallProfile responseProfile) {
- if (mVideoCallListener != null) {
- try {
- mVideoCallListener.receiveSessionModifyResponse(
- status, requestedProfile, responseProfile);
- } catch (RemoteException ignored) {
- }
- }
- }
-
- /**
- * Invokes callback method defined in {@link InCallService.VideoCall.Listener}.
- *
- * Valid values are: {@link InCallService.VideoCall#SESSION_EVENT_RX_PAUSE},
- * {@link InCallService.VideoCall#SESSION_EVENT_RX_RESUME},
- * {@link InCallService.VideoCall#SESSION_EVENT_TX_START},
- * {@link InCallService.VideoCall#SESSION_EVENT_TX_STOP}
- *
- * @param event The event.
- */
- public void handleCallSessionEvent(int event) {
- if (mVideoCallListener != null) {
- try {
- mVideoCallListener.handleCallSessionEvent(event);
- } catch (RemoteException ignored) {
- }
- }
- }
-
- /**
- * Invokes callback method defined in {@link InCallService.VideoCall.Listener}.
- *
- * @param width The updated peer video width.
- * @param height The updated peer video height.
- */
- public void changePeerDimensions(int width, int height) {
- if (mVideoCallListener != null) {
- try {
- mVideoCallListener.changePeerDimensions(width, height);
- } catch (RemoteException ignored) {
- }
- }
- }
-
- /**
- * Invokes callback method defined in {@link InCallService.VideoCall.Listener}.
- *
- * @param dataUsage The updated data usage.
- */
- public void changeCallDataUsage(int dataUsage) {
- if (mVideoCallListener != null) {
- try {
- mVideoCallListener.changeCallDataUsage(dataUsage);
- } catch (RemoteException ignored) {
- }
- }
- }
-
- /**
- * Invokes callback method defined in {@link InCallService.VideoCall.Listener}.
- *
- * @param callCameraCapabilities The changed camera capabilities.
- */
- public void changeCameraCapabilities(CallCameraCapabilities callCameraCapabilities) {
- if (mVideoCallListener != null) {
- try {
- mVideoCallListener.changeCameraCapabilities(callCameraCapabilities);
- } catch (RemoteException ignored) {
- }
- }
- }
-}