Merge "IMS-VT: Fix race-condition causing preview freeze." into nyc-dev
am: 1f77177

* commit '1f77177c64177d51fe6312532195d133a7c6186c':
  IMS-VT: Fix race-condition causing preview freeze.

Change-Id: I835103a509e11f4ccb2a6c9e2541e22481b2d37b
diff --git a/InCallUI/src/com/android/incallui/Call.java b/InCallUI/src/com/android/incallui/Call.java
index 54ec528..447c34c 100644
--- a/InCallUI/src/com/android/incallui/Call.java
+++ b/InCallUI/src/com/android/incallui/Call.java
@@ -374,6 +374,7 @@
     private int mRequestedVideoState = VideoProfile.STATE_AUDIO_ONLY;
 
     private InCallVideoCallCallback mVideoCallCallback;
+    private boolean mIsVideoCallCallbackRegistered;
     private String mChildNumber;
     private String mLastForwardedNumber;
     private String mCallSubject;
@@ -448,6 +449,7 @@
                 mVideoCallCallback = new InCallVideoCallCallback(this);
             }
             mTelecomCall.getVideoCall().registerCallback(mVideoCallCallback);
+            mIsVideoCallCallbackRegistered = true;
         }
 
         mChildCallIds.clear();
@@ -754,8 +756,14 @@
         return mTelecomCall == null ? null : mTelecomCall.getDetails().getAccountHandle();
     }
 
+    /**
+     * @return The {@link VideoCall} instance associated with the {@link android.telecom.Call}.
+     *      Will return {@code null} until {@link #updateFromTelecomCall()} has registered a valid
+     *      callback on the {@link VideoCall}.
+     */
     public VideoCall getVideoCall() {
-        return mTelecomCall == null ? null : mTelecomCall.getVideoCall();
+        return mTelecomCall == null || !mIsVideoCallCallbackRegistered ? null
+                : mTelecomCall.getVideoCall();
     }
 
     public List<String> getChildCallIds() {