Clear video pause tracker when video un-pause reported by the modem.
Tyler Gunn [Tue, 20 Jun 2017 22:15:44 +0000 (15:15 -0700)]
When video calls are swapped, the video stream automatically unpauses
without the UI requesting the pause/resume. Thus, the video pause tracker,
which tracks pause requests from the UI, can get into a state where it
thinks the video is paused, do it will ignore further pause requests.

Test: Manual
Bug: 62779713
Bug: 62784036
Change-Id: Ia8add452dbe9a79957e8a49e20ce58317136403b

src/java/com/android/ims/internal/ImsVideoCallProviderWrapper.java
src/java/com/android/ims/internal/VideoPauseTracker.java

index 1aae533..d6da824 100644 (file)
@@ -535,4 +535,19 @@ public class ImsVideoCallProviderWrapper extends Connection.VideoProvider {
     public void setUseVideoPauseWorkaround(boolean useVideoPauseWorkaround) {
         mUseVideoPauseWorkaround = useVideoPauseWorkaround;
     }
+
+    /**
+     * Called by {@code ImsPhoneConnection} when there is a change to the video state of the call.
+     * Informs the video pause tracker that the video is no longer paused.  This ensures that
+     * subsequent pause requests are not filtered out.
+     *
+     * @param newVideoState The new video state.
+     */
+    public void onVideoStateChanged(int newVideoState) {
+        if (mVideoPauseTracker.isPaused() && !VideoProfile.isPaused(newVideoState)) {
+            Log.i(this, "onVideoStateChanged: newVideoState=%s, clearing pending pause requests.",
+                    VideoProfile.videoStateToString(newVideoState));
+            mVideoPauseTracker.clearPauseRequests();
+        }
+    }
 }
index d37f7fa..a23c590 100644 (file)
@@ -150,6 +150,15 @@ public class VideoPauseTracker {
     }
 
     /**
+     * Clears pending pause requests for the tracker.
+     */
+    public void clearPauseRequests() {
+        synchronized (mPauseRequestsLock) {
+            mPauseRequests.clear();
+        }
+    }
+
+    /**
      * Returns a string equivalent of a {@code SOURCE_*} constant.
      *
      * @param source A {@code SOURCE_*} constant.