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
diff --git a/telecomm/java/android/telecom/Call.java b/telecomm/java/android/telecom/Call.java
index 8a1a553..92d5aa9 100644
--- a/telecomm/java/android/telecom/Call.java
+++ b/telecomm/java/android/telecom/Call.java
@@ -684,7 +684,7 @@
private int mState;
private List<String> mCannedTextResponses = null;
private String mRemainingPostDialSequence;
- private InCallService.VideoCall mVideoCall;
+ private VideoCallImpl mVideoCallImpl;
private Details mDetails;
/**
@@ -897,7 +897,7 @@
* @return An {@code Call.VideoCall}.
*/
public InCallService.VideoCall getVideoCall() {
- return mVideoCall;
+ return mVideoCallImpl;
}
/**
@@ -1028,10 +1028,14 @@
cannedTextResponsesChanged = true;
}
+ VideoCallImpl newVideoCallImpl = parcelableCall.getVideoCallImpl();
boolean videoCallChanged = parcelableCall.isVideoCallProviderChanged() &&
- !Objects.equals(mVideoCall, parcelableCall.getVideoCall(this));
+ !Objects.equals(mVideoCallImpl, newVideoCallImpl);
if (videoCallChanged) {
- mVideoCall = parcelableCall.getVideoCall(this);
+ mVideoCallImpl = newVideoCallImpl;
+ }
+ if (mVideoCallImpl != null) {
+ mVideoCallImpl.setVideoState(getDetails().getVideoState());
}
int state = parcelableCall.getState();
@@ -1081,7 +1085,7 @@
fireCannedTextResponsesLoaded(mCannedTextResponses);
}
if (videoCallChanged) {
- fireVideoCallChanged(mVideoCall);
+ fireVideoCallChanged(mVideoCallImpl);
}
if (parentChanged) {
fireParentChanged(getParent());