From be6b69a2ec388bbcff2f129dcf0c7c1476315664 Mon Sep 17 00:00:00 2001 From: roldenburg Date: Tue, 20 Jun 2017 15:27:45 -0700 Subject: Update our paused flag based on call session events This fixes a bug where we would remember being paused after receiving a second call incorrectly after we swap back to it. @tgunn, adding you here to double-check I am interpreting those call session events correctly. PiperOrigin-RevId: 159623587 Change-Id: Ic52e3e9046f767321a48e22274b8a1c27b4dfa86 --- .../videotech/ims/ImsVideoCallCallback.java | 9 +++++++++ .../incallui/videotech/ims/ImsVideoTech.java | 22 +++++++++++++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) (limited to 'java/com/android') diff --git a/java/com/android/incallui/videotech/ims/ImsVideoCallCallback.java b/java/com/android/incallui/videotech/ims/ImsVideoCallCallback.java index 17c2e6518..f4e0a01ea 100644 --- a/java/com/android/incallui/videotech/ims/ImsVideoCallCallback.java +++ b/java/com/android/incallui/videotech/ims/ImsVideoCallCallback.java @@ -161,14 +161,23 @@ public class ImsVideoCallCallback extends VideoCall.Callback { } } + // In the vendor code rx_pause and rx_resume get triggered when the video player starts or stops + // playing the incoming video stream. For the case where you're resuming a held call, its + // definitely a good signal to use to know that the video is resuming (though the video state + // should change to indicate its not paused in this case as well). However, keep in mind you'll + // get these signals as well on carriers that don't support the video pause signalling (like TMO) + // so you want to ensure you don't send sessionModifyRequests with pause/resume based on these + // signals. Also, its technically possible to have a pause/resume if the video signal degrades. @Override public void onCallSessionEvent(int event) { switch (event) { case Connection.VideoProvider.SESSION_EVENT_RX_PAUSE: LogUtil.i("ImsVideoCallCallback.onCallSessionEvent", "rx_pause"); + videoTech.onPausedEvent(); break; case Connection.VideoProvider.SESSION_EVENT_RX_RESUME: LogUtil.i("ImsVideoCallCallback.onCallSessionEvent", "rx_resume"); + videoTech.onResumedEvent(); break; case Connection.VideoProvider.SESSION_EVENT_CAMERA_FAILURE: LogUtil.i("ImsVideoCallCallback.onCallSessionEvent", "camera_failure"); diff --git a/java/com/android/incallui/videotech/ims/ImsVideoTech.java b/java/com/android/incallui/videotech/ims/ImsVideoTech.java index a6cef7b81..3d73e4e7d 100644 --- a/java/com/android/incallui/videotech/ims/ImsVideoTech.java +++ b/java/com/android/incallui/videotech/ims/ImsVideoTech.java @@ -19,6 +19,7 @@ package com.android.incallui.videotech.ims; import android.content.Context; import android.os.Build; import android.support.annotation.Nullable; +import android.support.annotation.VisibleForTesting; import android.telecom.Call; import android.telecom.Call.Details; import android.telecom.VideoProfile; @@ -40,7 +41,8 @@ public class ImsVideoTech implements VideoTech { private @SessionModificationState int sessionModificationState = SessionModificationState.NO_REQUEST; private int previousVideoState = VideoProfile.STATE_AUDIO_ONLY; - private boolean paused = false; + + @VisibleForTesting boolean paused = false; public ImsVideoTech(LoggingBindings logger, VideoTechListener listener, Call call) { this.logger = logger; @@ -247,6 +249,24 @@ public class ImsVideoTech implements VideoTech { call.getVideoCall().setDeviceOrientation(rotation); } + /** + * Called when we receive an rx_pause from the IMS stack. Update our state so we know we are + * currently paused. This is important in the cases where we swap calls since pause() and + * unpause() are not called. + */ + void onPausedEvent() { + paused = true; + } + + /** + * Called when we receive an rx_resume from the IMS stack. Update our state so we know we are + * currently not paused. This is important in the cases where we swap calls since pause() and + * unpause() are not called. + */ + void onResumedEvent() { + paused = false; + } + private boolean canPause() { return call.getDetails().can(Details.CAPABILITY_CAN_PAUSE_VIDEO) && call.getState() == Call.STATE_ACTIVE -- cgit v1.2.3