IMS-VT: Transmit static image when multitasking

1. Send static image when user puts the active video call
   in background
2. Unset the static image when UE come back to foreground
   i.e. when multitasking ends.
3. Unset the static image when Tx is disabled for the video call
   for eg. when background video call that is transmitting static
   image is downgraded to Rx or to voice
4. If respective static image UI config is disabled:
       i. Do not show static image in preview window
       ii. Do not show hide me button in active call screen

Change-Id: Ic117370044dd043dad528219d8a780dfdb5415ee
CRs-Fixed: 1107225
diff --git a/InCallUI/src/com/android/incallui/CallButtonPresenter.java b/InCallUI/src/com/android/incallui/CallButtonPresenter.java
index f4451c3..f94f81a 100644
--- a/InCallUI/src/com/android/incallui/CallButtonPresenter.java
+++ b/InCallUI/src/com/android/incallui/CallButtonPresenter.java
@@ -565,7 +565,7 @@
         ui.showButton(BUTTON_SWITCH_CAMERA, isVideo && !sIsHideMe);
         // show hide me button only for active video calls
         ui.showButton(BUTTON_HIDE_ME, isCallActive && isVideo &&
-                QtiCallUtils.shallTransmitStaticImage(getUi().getContext()));
+                QtiCallUtils.shallShowStaticImageUi(getUi().getContext()));
         ui.showButton(BUTTON_PAUSE_VIDEO, isVideo && !useExt && !useCustomVideoUi &&
                 !mEnhanceEnable);
         if (isVideo) {
diff --git a/InCallUI/src/com/android/incallui/QtiCallUtils.java b/InCallUI/src/com/android/incallui/QtiCallUtils.java
index 7543c6e..21c9fc2 100644
--- a/InCallUI/src/com/android/incallui/QtiCallUtils.java
+++ b/InCallUI/src/com/android/incallui/QtiCallUtils.java
@@ -287,6 +287,13 @@
         return context != null && QtiImsExtUtils.useCustomVideoUi(context);
     }
 
+    public static boolean shallShowStaticImageUi(Context context) {
+        if (context == null) {
+            Log.w(context, "Context is null...");
+        }
+        return context != null && QtiImsExtUtils.shallShowStaticImageUi(context);
+    }
+
     /**
      * Checks the boolean flag in config file to figure out if transmitting static image
      * in a video call is enabled or not
diff --git a/InCallUI/src/com/android/incallui/VideoCallPresenter.java b/InCallUI/src/com/android/incallui/VideoCallPresenter.java
index 8ff4c05..1defb66 100644
--- a/InCallUI/src/com/android/incallui/VideoCallPresenter.java
+++ b/InCallUI/src/com/android/incallui/VideoCallPresenter.java
@@ -614,6 +614,17 @@
             return;
         }
 
+        if (!QtiCallUtils.shallShowStaticImageUi(mContext) &&
+             QtiCallUtils.shallTransmitStaticImage(mContext) &&
+             mIsInBackground &&
+             shallTransmitStaticImage() &&
+             !VideoUtils.isTransmissionEnabled(call) &&
+             mVideoCall != null) {
+            /* Unset the pause image when Tx is disabled for eg. when background video call
+               that is transmitting static image is downgraded to Rx or to voice */
+            mVideoCall.setPauseImage(null);
+        }
+
         updateCameraSelection(call);
 
         if (isVideoCall) {
@@ -1073,7 +1084,12 @@
         Log.v(this, "showVideoUi : showIncoming = " + showIncomingVideo + " showOutgoing = "
                 + showOutgoingVideo + " shallTransmitStaticImage = " + shallTransmitStaticImage());
         if (showIncomingVideo || showOutgoingVideo) {
-            ui.showVideoViews(showOutgoingVideo && !shallTransmitStaticImage(), showIncomingVideo);
+            if (QtiCallUtils.shallShowStaticImageUi(mContext)) {
+                ui.showVideoViews(showOutgoingVideo && !shallTransmitStaticImage(),
+                        showIncomingVideo);
+            } else {
+                ui.showVideoViews(showOutgoingVideo, showIncomingVideo);
+            }
 
             boolean hidePreview = shallHidePreview(isConf, videoState);
             Log.v(this, "showVideoUi, hidePreview = " + hidePreview);
@@ -1083,7 +1099,9 @@
 
             if (showOutgoingVideo) {
                 setPreviewSize(mDeviceOrientation, mPreviewAspectRatio);
-                maybeLoadPreConfiguredImageAsync();
+                if (QtiCallUtils.shallShowStaticImageUi(mContext)) {
+                    maybeLoadPreConfiguredImageAsync();
+                }
             }
 
             if (isVideoReceptionEnabled && !shallTransmitStaticImage()) {
@@ -1157,11 +1175,20 @@
 
         mIsInBackground = !showing;
 
+        if (!QtiCallUtils.shallShowStaticImageUi(mContext)) {
+            sShallTransmitStaticImage = sUseDefaultImage = mIsInBackground;
+        }
+
         if (mPrimaryCall == null || !VideoUtils.isActiveVideoCall(mPrimaryCall)) {
             Log.w(this, "onUiShowing, received for non-active video call");
             return;
         }
 
+        if (!QtiCallUtils.shallShowStaticImageUi(mContext) &&
+            VideoUtils.isTransmissionEnabled(mPrimaryCall)) {
+            setPauseImage();
+        }
+
         if (showing) {
             maybeEnableCamera();
         } else if (mPreviewSurfaceState != PreviewSurfaceState.NONE) {