Remove dependency on android.telecom.Call in VideoCallImpl for testing.
VideoCallImpl had a depedency on android.telecom.Call, which was used to get the current video state of a call when the user issues a session modify request (we need to know what the video state was before the request was sent). This proved problematic for unit tests, as android.telecom.Call is a final class and cannot be mocked. These changes assume the VideoCallImpl will instead have a video state property, which is updated by the Call whenever it changes. This removes the dependency on the Call, and makes it possible to unit test the API. Change-Id: Ie67255d68b23e32aa177b30ac6439632fad5cc27
This commit is contained in:
@@ -42,7 +42,7 @@ public class VideoCallImpl extends VideoCall {
|
||||
private final VideoCallListenerBinder mBinder;
|
||||
private VideoCall.Callback mCallback;
|
||||
private int mVideoQuality = VideoProfile.QUALITY_UNKNOWN;
|
||||
private Call mCall;
|
||||
private int mVideoState = VideoProfile.STATE_AUDIO_ONLY;
|
||||
|
||||
private IBinder.DeathRecipient mDeathRecipient = new IBinder.DeathRecipient() {
|
||||
@Override
|
||||
@@ -197,13 +197,12 @@ public class VideoCallImpl extends VideoCall {
|
||||
|
||||
private Handler mHandler;
|
||||
|
||||
VideoCallImpl(IVideoProvider videoProvider, Call call) throws RemoteException {
|
||||
VideoCallImpl(IVideoProvider videoProvider) throws RemoteException {
|
||||
mVideoProvider = videoProvider;
|
||||
mVideoProvider.asBinder().linkToDeath(mDeathRecipient, 0);
|
||||
|
||||
mBinder = new VideoCallListenerBinder();
|
||||
mVideoProvider.addVideoCallback(mBinder);
|
||||
mCall = call;
|
||||
}
|
||||
|
||||
public void destroy() {
|
||||
@@ -292,8 +291,7 @@ public class VideoCallImpl extends VideoCall {
|
||||
*/
|
||||
public void sendSessionModifyRequest(VideoProfile requestProfile) {
|
||||
try {
|
||||
VideoProfile originalProfile = new VideoProfile(mCall.getDetails().getVideoState(),
|
||||
mVideoQuality);
|
||||
VideoProfile originalProfile = new VideoProfile(mVideoState, mVideoQuality);
|
||||
|
||||
mVideoProvider.sendSessionModifyRequest(originalProfile, requestProfile);
|
||||
} catch (RemoteException e) {
|
||||
@@ -331,4 +329,12 @@ public class VideoCallImpl extends VideoCall {
|
||||
} catch (RemoteException e) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the video state for the current video call.
|
||||
* @param videoState the new video state.
|
||||
*/
|
||||
public void setVideoState(int videoState) {
|
||||
mVideoState = videoState;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user