IMS-VT: Fix race-condition causing preview freeze.

The VideoCall object is made of two binders -
one for sending requests to telecomm and another one for
receiving notifications from telecom. The initialization of
the latter is delayed since a message is posted on a handler
and initialization is done in the handler. getVideoCall()
of InCallUi's Call class deligates the call to telecom's
getVideoCall() function. Since UI events are asynchronous
request to open the camera is sent, however, if the response
is received before the initialization is complete in the handler
the response will be dropped and camera initialization will fail.

Modify the getVideoCall() function of the InCallUI's call to
return valid VideoCall object only when the object is fully
constructed.

BUG=27810744
Change-Id: Id864892bf8452161f2c6f526edd6e4ecc39bf5cd
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() {