IMS-VT: Pop up request "video" message when request voice call

Do not display requesting for all downgrade use-cases
such as VT to VT-TX or VT-RX or Voice only.
VT-TX or VT-RX to Voice only.

Change-Id: I3714f82acb1eccb3d99aea3c2fbc18ab04af1714
CRs-Fixed: 2018550
diff --git a/InCallUI/src/com/android/incallui/CallCardFragment.java b/InCallUI/src/com/android/incallui/CallCardFragment.java
index 1c4890b..4bf94fd 100644
--- a/InCallUI/src/com/android/incallui/CallCardFragment.java
+++ b/InCallUI/src/com/android/incallui/CallCardFragment.java
@@ -44,6 +44,7 @@
 import android.media.AudioManager;
 import android.provider.Settings;
 import android.telecom.DisconnectCause;
+import android.telecom.VideoProfile;
 import android.telephony.PhoneNumberUtils;
 import android.telephony.SubscriptionManager;
 import android.text.TextUtils;
@@ -1140,6 +1141,20 @@
         return bitmap;
     }
 
+    private boolean isDowngrading(int videoState) {
+        boolean isDowngrade = false;
+        if ((videoState == VideoProfile.STATE_BIDIRECTIONAL
+                    && QtiCallUtils.getRequestedVideoState()
+                    != VideoProfile.STATE_BIDIRECTIONAL)
+                || ((videoState == VideoProfile.STATE_TX_ENABLED
+                        || videoState == VideoProfile.STATE_RX_ENABLED)
+                    && QtiCallUtils.getRequestedVideoState()
+                    == VideoProfile.STATE_AUDIO_ONLY)) {
+            isDowngrade = true;
+        }
+        return isDowngrade;
+    }
+
     /**
      * Gets the call state label based on the state of the call or cause of disconnect.
      *
@@ -1179,7 +1194,12 @@
                     isAutoDismissing = true;
                 } else if (sessionModificationState
                         == Call.SessionModificationState.WAITING_FOR_RESPONSE) {
-                    callStateLabel = context.getString(R.string.card_title_video_call_requesting);
+                    if (isDowngrading(videoState)) {
+                        callStateLabel = context.getString(R.string.card_title_video_call);
+                    } else {
+                        callStateLabel = context.getString(
+                                R.string.card_title_video_call_requesting);
+                    }
                 } else if (sessionModificationState
                         == Call.SessionModificationState.RECEIVED_UPGRADE_TO_VIDEO_REQUEST) {
                     callStateLabel = context.getString(R.string.card_title_video_call_requesting);
diff --git a/InCallUI/src/com/android/incallui/QtiCallUtils.java b/InCallUI/src/com/android/incallui/QtiCallUtils.java
index faf518c..4e5b203 100644
--- a/InCallUI/src/com/android/incallui/QtiCallUtils.java
+++ b/InCallUI/src/com/android/incallui/QtiCallUtils.java
@@ -73,6 +73,7 @@
     public static final String INTENT_ACTION_DIALOG_DISMISS =
             "com.qti.editnumber.INTENT_ACTION_DIALOG_DISMISS";
     private static String mEditNumberCallId;
+    private static int mRequestedVideoState = -1;
 
     static {
         VIDEO_QUALITY_TABLE.put(new Size(320,240), VideoProfile.QUALITY_LOW);
@@ -229,6 +230,7 @@
                 final int selCallType = itemToCallType.get(item);
                 Log.v(this, "Videocall: ModifyCall: upgrade/downgrade to "
                         + callTypeToString(selCallType));
+                mRequestedVideoState = selCallType;
                 VideoProfile videoProfile = new VideoProfile(selCallType);
                 changeToVideoClicked(call, videoProfile, context);
                 dialog.dismiss();
@@ -241,6 +243,10 @@
         alert.show();
     }
 
+    public static int getRequestedVideoState() {
+        return mRequestedVideoState;
+    }
+
     public static void changeToVideoCall(Call call, VideoProfile videoProfile, Context context) {
             changeToVideoClicked(call, videoProfile, context);
     }