Promotion of atel.lnx.2.0-00076.

CRs      Change ID                                   Subject
--------------------------------------------------------------------------------------------------------------
2036068   I1ce18dbc5c1d5f6f5abaa8db7eb14012a59499a1   IMS-VT: Fix race condition issue of no preview during VT

Change-Id: I0bf6ceb9c414a1db79105b4908c9b0424fc66194
CRs-Fixed: 2036068
diff --git a/InCallUI/src/com/android/incallui/VideoCallPresenter.java b/InCallUI/src/com/android/incallui/VideoCallPresenter.java
index 0b61102..b715e2d 100644
--- a/InCallUI/src/com/android/incallui/VideoCallPresenter.java
+++ b/InCallUI/src/com/android/incallui/VideoCallPresenter.java
@@ -303,6 +303,7 @@
 
         // Register for surface and video events from {@link InCallVideoCallListener}s.
         InCallVideoCallCallbackNotifier.getInstance().addSurfaceChangeListener(this);
+        InCallUiStateNotifier.getInstance().addListener(this, true );
         mCurrentVideoState = VideoProfile.STATE_AUDIO_ONLY;
         mCurrentCallState = Call.State.INVALID;
 
@@ -311,7 +312,6 @@
         onStateChange(inCallState, inCallState, CallList.getInstance());
         InCallVideoCallCallbackNotifier.getInstance().addVideoEventListener(this,
                 VideoUtils.isVideoCall(mCurrentVideoState));
-        InCallUiStateNotifier.getInstance().addListener(this, true );
     }
 
     /**
@@ -1279,6 +1279,15 @@
             return;
         }
 
+        if (shallTransmitStaticImage()) {
+            setPauseImage();
+        }
+
+        if (mPreviewSurfaceState == PreviewSurfaceState.NONE) {
+            Log.w(this, "onCameraDimensionsChange: capabilities received when camera is OFF.");
+            return;
+        }
+
         mPreviewSurfaceState = PreviewSurfaceState.CAPABILITIES_RECEIVED;
         Point previewDimensions = ui.getPreviewSize();
 
@@ -1295,10 +1304,6 @@
         changePreviewDimensions(width, height);
         ui.setPreviewRotation(mDeviceOrientation);
 
-        if (shallTransmitStaticImage()) {
-            setPauseImage();
-        }
-
         // Check if the preview surface is ready yet; if it is, set it on the {@code VideoCall}.
         // If it not yet ready, it will be set when when creation completes.
         if (ui.isPreviewVideoSurfaceCreated()) {