diff options
author | 2015-12-08 10:53:41 -0800 | |
---|---|---|
committer | 2015-12-08 10:53:41 -0800 | |
commit | 584ba6c1d156af1a1295fb101cd085577ac82ece (patch) | |
tree | a7abf885914cfb4eb3c2a46517543595c5bdd7bb | |
parent | 79aeb92f4de64dc658b3cbae6dcf40f19b1597f8 (diff) |
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
-rw-r--r-- | telecomm/java/android/telecom/Call.java | 14 | ||||
-rw-r--r-- | telecomm/java/android/telecom/ParcelableCall.java | 7 | ||||
-rw-r--r-- | telecomm/java/android/telecom/VideoCallImpl.java | 16 |
3 files changed, 24 insertions, 13 deletions
diff --git a/telecomm/java/android/telecom/Call.java b/telecomm/java/android/telecom/Call.java index 8a1a55378321..92d5aa903397 100644 --- a/telecomm/java/android/telecom/Call.java +++ b/telecomm/java/android/telecom/Call.java @@ -684,7 +684,7 @@ public final class Call { 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 @@ public final class Call { * @return An {@code Call.VideoCall}. */ public InCallService.VideoCall getVideoCall() { - return mVideoCall; + return mVideoCallImpl; } /** @@ -1028,10 +1028,14 @@ public final class Call { 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 @@ public final class Call { fireCannedTextResponsesLoaded(mCannedTextResponses); } if (videoCallChanged) { - fireVideoCallChanged(mVideoCall); + fireVideoCallChanged(mVideoCallImpl); } if (parentChanged) { fireParentChanged(getParent()); diff --git a/telecomm/java/android/telecom/ParcelableCall.java b/telecomm/java/android/telecom/ParcelableCall.java index 8cf4aebe840e..4a6fd7c16c1a 100644 --- a/telecomm/java/android/telecom/ParcelableCall.java +++ b/telecomm/java/android/telecom/ParcelableCall.java @@ -48,7 +48,7 @@ public final class ParcelableCall implements Parcelable { private final PhoneAccountHandle mAccountHandle; private final boolean mIsVideoCallProviderChanged; private final IVideoProvider mVideoCallProvider; - private InCallService.VideoCall mVideoCall; + private VideoCallImpl mVideoCall; private final String mParentCallId; private final List<String> mChildCallIds; private final StatusHints mStatusHints; @@ -179,12 +179,13 @@ public final class ParcelableCall implements Parcelable { /** * Returns an object for remotely communicating through the video call provider's binder. + * @return The video call. */ - public InCallService.VideoCall getVideoCall(Call call) { + public VideoCallImpl getVideoCallImpl() { if (mVideoCall == null && mVideoCallProvider != null) { try { - mVideoCall = new VideoCallImpl(mVideoCallProvider, call); + mVideoCall = new VideoCallImpl(mVideoCallProvider); } catch (RemoteException ignored) { // Ignore RemoteException. } diff --git a/telecomm/java/android/telecom/VideoCallImpl.java b/telecomm/java/android/telecom/VideoCallImpl.java index 93484cd291de..e54abeebb880 100644 --- a/telecomm/java/android/telecom/VideoCallImpl.java +++ b/telecomm/java/android/telecom/VideoCallImpl.java @@ -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; + } } |