172 lines
6.4 KiB
Java
Raw Normal View History

/*
* 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
R* limitations under the License.
*/
package android.telecom;
import com.android.internal.os.SomeArgs;
import com.android.internal.telecom.IVideoCallback;
import android.os.Handler;
import android.os.Message;
import android.os.RemoteException;
/**
* A component that provides an RPC servant implementation of {@link IVideoCallback},
* posting incoming messages on the main thread on a client-supplied delegate object.
*
* TODO: Generate this and similar classes using a compiler starting from AIDL interfaces.
*
* @hide
*/
final class VideoCallbackServant {
private static final int MSG_RECEIVE_SESSION_MODIFY_REQUEST = 0;
private static final int MSG_RECEIVE_SESSION_MODIFY_RESPONSE = 1;
private static final int MSG_HANDLE_CALL_SESSION_EVENT = 2;
private static final int MSG_CHANGE_PEER_DIMENSIONS = 3;
private static final int MSG_CHANGE_CALL_DATA_USAGE = 4;
private static final int MSG_CHANGE_CAMERA_CAPABILITIES = 5;
IMS-VT: Upgrade/Downgrade change -Add isVideo API to VideoProfile.VideoState IMS-VT: Fix propagation of device orientation. Orientation received at VT Service is incorrect. Fixed propagation of device orientation to VT service. IMS-VT: Upgrade fix -Add session modify call timed out constant Notify listeners of video quality changed event - Propagate the video quality changed message to the UI. IMS: Add support for video quality - Add Config interface to get/set video quality IMS-VT: Multitasking feature -Support for video multitasking IMS-VT: Modification of data usage aidl Change data usage aidl interface to take parameter type long instead of int Change-Id: I7cda2a689edb86d025dfe8efc8f573918c4bd6bc Propagate the call substate changed message to the UI IMS-VT: Add call modifiable capability PhoneCapababilities call type modifiable constant added IMS-VT: Add a bit mask CALL_SUBSTATE_ALL with all call substate bits set IMS-VT: Enable Video conferencing. Enable Video conferencing. Change-Id: I4240aa6f32c75d6eea8a41da3c87bca651f0901b IMS-VT: Add hide for setVideoProvider API Observed compilation error for SDK generation due to setVideoProvider API. Marking setVideoProvider as hide inorder to resolve the compilation error. IMS-VT: Add persist.radio.ims.audio.output for VT calls -- Add persist.radio.ims.audio.output to set the default speaker for VT calls. -- Add required constants IMS-VT: Add additional error codes for upgrade downgrade -Add support to send additional error codes to UI during upgrade downgrade. Change-Id: Id452d225098fe3bccdcd37d242985c5c761144c1
2015-03-24 16:42:31 -07:00
private static final int MSG_CHANGE_VIDEO_QUALITY = 6;
private final IVideoCallback mDelegate;
private final Handler mHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
try {
internalHandleMessage(msg);
} catch (RemoteException e) {
}
}
// Internal method defined to centralize handling of RemoteException
private void internalHandleMessage(Message msg) throws RemoteException {
switch (msg.what) {
case MSG_RECEIVE_SESSION_MODIFY_REQUEST: {
mDelegate.receiveSessionModifyRequest((VideoProfile) msg.obj);
break;
}
case MSG_RECEIVE_SESSION_MODIFY_RESPONSE: {
SomeArgs args = (SomeArgs) msg.obj;
try {
mDelegate.receiveSessionModifyResponse(
args.argi1,
(VideoProfile) args.arg1,
(VideoProfile) args.arg2);
} finally {
args.recycle();
}
break;
}
case MSG_HANDLE_CALL_SESSION_EVENT: {
SomeArgs args = (SomeArgs) msg.obj;
try {
mDelegate.handleCallSessionEvent(args.argi1);
} finally {
args.recycle();
}
break;
}
case MSG_CHANGE_PEER_DIMENSIONS: {
SomeArgs args = (SomeArgs) msg.obj;
try {
mDelegate.changePeerDimensions(args.argi1, args.argi2);
} finally {
args.recycle();
}
break;
}
case MSG_CHANGE_CALL_DATA_USAGE: {
SomeArgs args = (SomeArgs) msg.obj;
try {
IMS-VT: Upgrade/Downgrade change -Add isVideo API to VideoProfile.VideoState IMS-VT: Fix propagation of device orientation. Orientation received at VT Service is incorrect. Fixed propagation of device orientation to VT service. IMS-VT: Upgrade fix -Add session modify call timed out constant Notify listeners of video quality changed event - Propagate the video quality changed message to the UI. IMS: Add support for video quality - Add Config interface to get/set video quality IMS-VT: Multitasking feature -Support for video multitasking IMS-VT: Modification of data usage aidl Change data usage aidl interface to take parameter type long instead of int Change-Id: I7cda2a689edb86d025dfe8efc8f573918c4bd6bc Propagate the call substate changed message to the UI IMS-VT: Add call modifiable capability PhoneCapababilities call type modifiable constant added IMS-VT: Add a bit mask CALL_SUBSTATE_ALL with all call substate bits set IMS-VT: Enable Video conferencing. Enable Video conferencing. Change-Id: I4240aa6f32c75d6eea8a41da3c87bca651f0901b IMS-VT: Add hide for setVideoProvider API Observed compilation error for SDK generation due to setVideoProvider API. Marking setVideoProvider as hide inorder to resolve the compilation error. IMS-VT: Add persist.radio.ims.audio.output for VT calls -- Add persist.radio.ims.audio.output to set the default speaker for VT calls. -- Add required constants IMS-VT: Add additional error codes for upgrade downgrade -Add support to send additional error codes to UI during upgrade downgrade. Change-Id: Id452d225098fe3bccdcd37d242985c5c761144c1
2015-03-24 16:42:31 -07:00
mDelegate.changeCallDataUsage((long) args.arg1);
} finally {
args.recycle();
}
break;
}
case MSG_CHANGE_CAMERA_CAPABILITIES: {
mDelegate.changeCameraCapabilities((VideoProfile.CameraCapabilities) msg.obj);
break;
}
IMS-VT: Upgrade/Downgrade change -Add isVideo API to VideoProfile.VideoState IMS-VT: Fix propagation of device orientation. Orientation received at VT Service is incorrect. Fixed propagation of device orientation to VT service. IMS-VT: Upgrade fix -Add session modify call timed out constant Notify listeners of video quality changed event - Propagate the video quality changed message to the UI. IMS: Add support for video quality - Add Config interface to get/set video quality IMS-VT: Multitasking feature -Support for video multitasking IMS-VT: Modification of data usage aidl Change data usage aidl interface to take parameter type long instead of int Change-Id: I7cda2a689edb86d025dfe8efc8f573918c4bd6bc Propagate the call substate changed message to the UI IMS-VT: Add call modifiable capability PhoneCapababilities call type modifiable constant added IMS-VT: Add a bit mask CALL_SUBSTATE_ALL with all call substate bits set IMS-VT: Enable Video conferencing. Enable Video conferencing. Change-Id: I4240aa6f32c75d6eea8a41da3c87bca651f0901b IMS-VT: Add hide for setVideoProvider API Observed compilation error for SDK generation due to setVideoProvider API. Marking setVideoProvider as hide inorder to resolve the compilation error. IMS-VT: Add persist.radio.ims.audio.output for VT calls -- Add persist.radio.ims.audio.output to set the default speaker for VT calls. -- Add required constants IMS-VT: Add additional error codes for upgrade downgrade -Add support to send additional error codes to UI during upgrade downgrade. Change-Id: Id452d225098fe3bccdcd37d242985c5c761144c1
2015-03-24 16:42:31 -07:00
case MSG_CHANGE_VIDEO_QUALITY: {
mDelegate.changeVideoQuality(msg.arg1);
break;
}
}
}
};
private final IVideoCallback mStub = new IVideoCallback.Stub() {
@Override
public void receiveSessionModifyRequest(VideoProfile videoProfile) throws RemoteException {
mHandler.obtainMessage(MSG_RECEIVE_SESSION_MODIFY_REQUEST, videoProfile).sendToTarget();
}
@Override
public void receiveSessionModifyResponse(int status, VideoProfile requestedProfile,
VideoProfile responseProfile) throws RemoteException {
SomeArgs args = SomeArgs.obtain();
args.argi1 = status;
args.arg1 = requestedProfile;
args.arg2 = responseProfile;
mHandler.obtainMessage(MSG_RECEIVE_SESSION_MODIFY_RESPONSE, args).sendToTarget();
}
@Override
public void handleCallSessionEvent(int event) throws RemoteException {
SomeArgs args = SomeArgs.obtain();
args.argi1 = event;
mHandler.obtainMessage(MSG_HANDLE_CALL_SESSION_EVENT, args).sendToTarget();
}
@Override
public void changePeerDimensions(int width, int height) throws RemoteException {
SomeArgs args = SomeArgs.obtain();
args.argi1 = width;
args.argi2 = height;
mHandler.obtainMessage(MSG_CHANGE_PEER_DIMENSIONS, args).sendToTarget();
}
@Override
IMS-VT: Upgrade/Downgrade change -Add isVideo API to VideoProfile.VideoState IMS-VT: Fix propagation of device orientation. Orientation received at VT Service is incorrect. Fixed propagation of device orientation to VT service. IMS-VT: Upgrade fix -Add session modify call timed out constant Notify listeners of video quality changed event - Propagate the video quality changed message to the UI. IMS: Add support for video quality - Add Config interface to get/set video quality IMS-VT: Multitasking feature -Support for video multitasking IMS-VT: Modification of data usage aidl Change data usage aidl interface to take parameter type long instead of int Change-Id: I7cda2a689edb86d025dfe8efc8f573918c4bd6bc Propagate the call substate changed message to the UI IMS-VT: Add call modifiable capability PhoneCapababilities call type modifiable constant added IMS-VT: Add a bit mask CALL_SUBSTATE_ALL with all call substate bits set IMS-VT: Enable Video conferencing. Enable Video conferencing. Change-Id: I4240aa6f32c75d6eea8a41da3c87bca651f0901b IMS-VT: Add hide for setVideoProvider API Observed compilation error for SDK generation due to setVideoProvider API. Marking setVideoProvider as hide inorder to resolve the compilation error. IMS-VT: Add persist.radio.ims.audio.output for VT calls -- Add persist.radio.ims.audio.output to set the default speaker for VT calls. -- Add required constants IMS-VT: Add additional error codes for upgrade downgrade -Add support to send additional error codes to UI during upgrade downgrade. Change-Id: Id452d225098fe3bccdcd37d242985c5c761144c1
2015-03-24 16:42:31 -07:00
public void changeCallDataUsage(long dataUsage) throws RemoteException {
SomeArgs args = SomeArgs.obtain();
IMS-VT: Upgrade/Downgrade change -Add isVideo API to VideoProfile.VideoState IMS-VT: Fix propagation of device orientation. Orientation received at VT Service is incorrect. Fixed propagation of device orientation to VT service. IMS-VT: Upgrade fix -Add session modify call timed out constant Notify listeners of video quality changed event - Propagate the video quality changed message to the UI. IMS: Add support for video quality - Add Config interface to get/set video quality IMS-VT: Multitasking feature -Support for video multitasking IMS-VT: Modification of data usage aidl Change data usage aidl interface to take parameter type long instead of int Change-Id: I7cda2a689edb86d025dfe8efc8f573918c4bd6bc Propagate the call substate changed message to the UI IMS-VT: Add call modifiable capability PhoneCapababilities call type modifiable constant added IMS-VT: Add a bit mask CALL_SUBSTATE_ALL with all call substate bits set IMS-VT: Enable Video conferencing. Enable Video conferencing. Change-Id: I4240aa6f32c75d6eea8a41da3c87bca651f0901b IMS-VT: Add hide for setVideoProvider API Observed compilation error for SDK generation due to setVideoProvider API. Marking setVideoProvider as hide inorder to resolve the compilation error. IMS-VT: Add persist.radio.ims.audio.output for VT calls -- Add persist.radio.ims.audio.output to set the default speaker for VT calls. -- Add required constants IMS-VT: Add additional error codes for upgrade downgrade -Add support to send additional error codes to UI during upgrade downgrade. Change-Id: Id452d225098fe3bccdcd37d242985c5c761144c1
2015-03-24 16:42:31 -07:00
args.arg1 = dataUsage;
mHandler.obtainMessage(MSG_CHANGE_CALL_DATA_USAGE, args).sendToTarget();
}
@Override
public void changeCameraCapabilities(
VideoProfile.CameraCapabilities cameraCapabilities)
throws RemoteException {
mHandler.obtainMessage(MSG_CHANGE_CAMERA_CAPABILITIES, cameraCapabilities)
.sendToTarget();
}
IMS-VT: Upgrade/Downgrade change -Add isVideo API to VideoProfile.VideoState IMS-VT: Fix propagation of device orientation. Orientation received at VT Service is incorrect. Fixed propagation of device orientation to VT service. IMS-VT: Upgrade fix -Add session modify call timed out constant Notify listeners of video quality changed event - Propagate the video quality changed message to the UI. IMS: Add support for video quality - Add Config interface to get/set video quality IMS-VT: Multitasking feature -Support for video multitasking IMS-VT: Modification of data usage aidl Change data usage aidl interface to take parameter type long instead of int Change-Id: I7cda2a689edb86d025dfe8efc8f573918c4bd6bc Propagate the call substate changed message to the UI IMS-VT: Add call modifiable capability PhoneCapababilities call type modifiable constant added IMS-VT: Add a bit mask CALL_SUBSTATE_ALL with all call substate bits set IMS-VT: Enable Video conferencing. Enable Video conferencing. Change-Id: I4240aa6f32c75d6eea8a41da3c87bca651f0901b IMS-VT: Add hide for setVideoProvider API Observed compilation error for SDK generation due to setVideoProvider API. Marking setVideoProvider as hide inorder to resolve the compilation error. IMS-VT: Add persist.radio.ims.audio.output for VT calls -- Add persist.radio.ims.audio.output to set the default speaker for VT calls. -- Add required constants IMS-VT: Add additional error codes for upgrade downgrade -Add support to send additional error codes to UI during upgrade downgrade. Change-Id: Id452d225098fe3bccdcd37d242985c5c761144c1
2015-03-24 16:42:31 -07:00
@Override
public void changeVideoQuality(int videoQuality) throws RemoteException {
mHandler.obtainMessage(MSG_CHANGE_VIDEO_QUALITY, videoQuality, 0).sendToTarget();
}
};
public VideoCallbackServant(IVideoCallback delegate) {
mDelegate = delegate;
}
public IVideoCallback getStub() {
return mStub;
}
}