IMS: Display wifi quality icons for VoWiFi calls

During an established VoWiFi call, depending on the
wifi quality indication, display corresponding in-call
icon.

Change-Id: I74d7127db4e9979ba05e31436e0033f7fd508d97
CRs-Fixed: 999867
diff --git a/InCallUI/res/drawable/vowifi_in_call_fair.xml b/InCallUI/res/drawable/vowifi_in_call_fair.xml
new file mode 100644
index 0000000..6cd5f30
--- /dev/null
+++ b/InCallUI/res/drawable/vowifi_in_call_fair.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2016, The Linux Foundation. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+        * Redistributions of source code must retain the above copyright
+        notice, this list of conditions and the following disclaimer.
+        * Redistributions in binary form must reproduce the above
+        copyright notice, this list of conditions and the following
+        disclaimer in the documentation and/or other materials provided
+        with the distribution.
+        * Neither the name of The Linux Foundation nor the names of its
+        contributors may be used to endorse or promote products derived
+        from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+-->
+<vector android:autoMirrored="true" android:height="24dp"
+    android:viewportHeight="588.0" android:viewportWidth="731.0"
+    android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
+    <path android:fillColor="#FFFFFF" android:pathData="M143.4,436.09998c-90.1,-91.2 -135,-209 -133.6,-322.6c0.2,-16.1 13.3,-29.2 29.4,-29.4l103.1,-1.3c8.5,-0.1 15.6,6.3 16.3,14.8l11.6,134L114.7,294c-2.9,3.2 -3.4,7.9 -1.3,11.7c18.4,33.4 41.4,64.2 68.9,92l0.7,0.6c27.5,27.8 58,51.3 91.2,70c3.7,2.1 8.4,1.7 11.7,-1.2l63.1,-54.7l133.9,13.3c8.4,0.8 14.8,8 14.6,16.5l-2.6,103c-0.4,16.1 -13.6,29.1 -29.7,29.1c-113.7,0 -230.8,-46.4 -320.9,-137.7L143.4,436.09998z"/>
+    <path android:fillAlpha="0.53" android:fillColor="#FFFFFF" android:pathData="M636.2,171.20001l22.3,-25l25.1,-28.1l34.1,-38.3c-71.4,-39.9 -163.3,-64 -263.6,-64s-192.2,24.1 -263.6,64l33.3,38.6l24.5,28.4L270,172c55.4,-18.6 117.9,-29.3 184.1,-29.3C519.6,142.6 581.3,153 636.2,171.20001z"/>
+    <path android:fillColor="#FFFFFF" android:pathData="M636.2,171.20001c-54.9,-18.2 -116.6,-28.6 -182.1,-28.6c-66.3,0 -128.7,10.7 -184.1,29.3l179.7,208.3L636.2,171.20001z"/>
+</vector>
diff --git a/InCallUI/res/drawable/vowifi_in_call_good.xml b/InCallUI/res/drawable/vowifi_in_call_good.xml
new file mode 100644
index 0000000..52d397c
--- /dev/null
+++ b/InCallUI/res/drawable/vowifi_in_call_good.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2016, The Linux Foundation. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+        * Redistributions of source code must retain the above copyright
+        notice, this list of conditions and the following disclaimer.
+        * Redistributions in binary form must reproduce the above
+        copyright notice, this list of conditions and the following
+        disclaimer in the documentation and/or other materials provided
+        with the distribution.
+        * Neither the name of The Linux Foundation nor the names of its
+        contributors may be used to endorse or promote products derived
+        from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+-->
+<vector android:autoMirrored="true" android:height="24dp"
+    android:viewportHeight="588.0" android:viewportWidth="731.0"
+    android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
+    <path android:fillColor="#FFFFFF" android:pathData="M144.4,436.09998c-90.1,-91.2 -135,-209 -133.6,-322.6c0.2,-16.1 13.3,-29.2 29.4,-29.4l103.1,-1.3c8.5,-0.1 15.6,6.3 16.3,14.8l11.6,134L115.7,294c-2.9,3.2 -3.4,7.9 -1.3,11.7c18.4,33.4 41.4,64.2 68.9,92l0.7,0.6c27.5,27.8 58,51.3 91.2,70c3.7,2.1 8.4,1.7 11.7,-1.2l63.1,-54.7l133.9,13.3c8.4,0.8 14.8,8 14.6,16.5l-2.6,103c-0.4,16.1 -13.6,29.1 -29.7,29.1c-113.7,0 -230.8,-46.4 -320.9,-137.7L144.4,436.09998z"/>
+    <path android:fillColor="#FFFFFF" android:pathData="M454.90002,15.5c-100.3,0 -192.2,24.1 -263.6,64l33.3,38.6l24.5,28.4L450.5,380l208.8,-234.1l25.1,-28.1l34.1,-38.3C647.1,39.600006 555.2,15.5 454.90002,15.5z"/>
+</vector>
diff --git a/InCallUI/res/drawable/vowifi_in_call_poor.xml b/InCallUI/res/drawable/vowifi_in_call_poor.xml
new file mode 100644
index 0000000..663ce90
--- /dev/null
+++ b/InCallUI/res/drawable/vowifi_in_call_poor.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2016, The Linux Foundation. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+        * Redistributions of source code must retain the above copyright
+        notice, this list of conditions and the following disclaimer.
+        * Redistributions in binary form must reproduce the above
+        copyright notice, this list of conditions and the following
+        disclaimer in the documentation and/or other materials provided
+        with the distribution.
+        * Neither the name of The Linux Foundation nor the names of its
+        contributors may be used to endorse or promote products derived
+        from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+-->
+<vector android:autoMirrored="true" android:height="24dp"
+    android:viewportHeight="588.0" android:viewportWidth="731.0"
+    android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
+    <path android:fillColor="#FFFFFF" android:pathData="M143.4,435.09998c-90.1,-91.2 -135,-209 -133.6,-322.6c0.2,-16.1 13.3,-29.2 29.4,-29.4l103.1,-1.3c8.5,-0.1 15.6,6.3 16.3,14.8l11.6,134L114.7,293c-2.9,3.2 -3.4,7.9 -1.3,11.7c18.4,33.4 41.4,64.2 68.9,92l0.7,0.6c27.5,27.8 58,51.3 91.2,70c3.7,2.1 8.4,1.7 11.7,-1.2l63.1,-54.7l133.9,13.3c8.4,0.8 14.8,8 14.6,16.5l-2.6,103c-0.4,16.1 -13.6,29.1 -29.7,29.1c-113.7,0 -230.8,-46.4 -320.9,-137.7L143.4,435.09998z"/>
+    <path android:fillAlpha="0.53" android:fillColor="#FFFFFF" android:pathData="M537.3,281.4l121.5,-136.2l25.1,-28.1l34.1,-38.3c-71.4,-39.9 -163.3,-64 -263.6,-64s-192.2,24.1 -263.6,64l33.3,38.6l24.5,28.4l117.6,136.3c28.4,-4.2 57.8,-6.6 88.2,-6.6C482.90002,275.6 510.5,277.7 537.3,281.4z"/>
+    <path android:fillColor="#FFFFFF" android:pathData="M537.3,281.4c-26.8,-3.7 -54.4,-5.8 -82.9,-5.8c-30.3,0 -59.7,2.4 -88.2,6.6l83.7,97.1L537.3,281.4z"/>
+</vector>
diff --git a/InCallUI/res/values/qtistrings.xml b/InCallUI/res/values/qtistrings.xml
index 6b8aef5..1ccb312 100644
--- a/InCallUI/res/values/qtistrings.xml
+++ b/InCallUI/res/values/qtistrings.xml
@@ -150,6 +150,12 @@
 
     <!-- Message indicating call failed due to low battery -->
     <string name="call_failed_due_to_low_battery">Call is failed due to low battery</string>
+
+    <!-- VoWifi call quality indicators -->
+    <string name="vowifi_call_quality_good">Good Voice quality</string>
+    <string name="vowifi_call_quality_fair">Fair Voice quality</string>
+    <string name="vowifi_call_quality_poor">Poor Voice quality</string>
+
     <!-- Title for low battery alert dialogue -->
     <string name="low_battery">Low Battery Warning</string>
     <!-- Yes option of the low battery alert dialog -->
diff --git a/InCallUI/src/com/android/incallui/Call.java b/InCallUI/src/com/android/incallui/Call.java
index 5717fe4..d20f977 100644
--- a/InCallUI/src/com/android/incallui/Call.java
+++ b/InCallUI/src/com/android/incallui/Call.java
@@ -46,6 +46,7 @@
 import java.util.Objects;
 
 import org.codeaurora.ims.internal.IQtiImsExt;
+import org.codeaurora.ims.QtiCallConstants;
 import org.codeaurora.ims.QtiImsException;
 import org.codeaurora.ims.QtiImsExtListenerBaseImpl;
 import org.codeaurora.ims.QtiImsExtManager;
@@ -1000,4 +1001,11 @@
         }
         return false;
     }
+
+    public int getWifiQuality() {
+        Bundle extras = getExtras();
+        return (extras == null)? QtiCallConstants.VOWIFI_QUALITY_NONE :
+                extras.getInt(QtiCallConstants.VOWIFI_CALL_QUALITY_EXTRA_KEY,
+                QtiCallConstants.VOWIFI_QUALITY_NONE);
+    }
 }
diff --git a/InCallUI/src/com/android/incallui/StatusBarNotifier.java b/InCallUI/src/com/android/incallui/StatusBarNotifier.java
index 301b819..601f8f3 100644
--- a/InCallUI/src/com/android/incallui/StatusBarNotifier.java
+++ b/InCallUI/src/com/android/incallui/StatusBarNotifier.java
@@ -63,6 +63,7 @@
 import com.android.incallui.ringtone.ToneGeneratorFactory;
 
 import java.util.Objects;
+import org.codeaurora.ims.QtiCallConstants;
 
 /**
  * This class adds Notifications to the status bar for the in-call experience.
@@ -125,6 +126,34 @@
         updateNotification(newState, callList);
     }
 
+    private int getVoWiFiQualityIcon(int voWifiCallQuality) {
+        switch (voWifiCallQuality) {
+            case QtiCallConstants.VOWIFI_QUALITY_EXCELLENT:
+                return R.drawable.vowifi_in_call_good;
+
+            case QtiCallConstants.VOWIFI_QUALITY_FAIR:
+                return R.drawable.vowifi_in_call_fair;
+
+            case QtiCallConstants.VOWIFI_QUALITY_POOR:
+                return R.drawable.vowifi_in_call_poor;
+        }
+       return QtiCallConstants.VOWIFI_QUALITY_NONE;
+    }
+
+    private String getVoWiFiQualityText(int voWifiCallQuality) {
+        switch (voWifiCallQuality) {
+            case QtiCallConstants.VOWIFI_QUALITY_EXCELLENT:
+                return mContext.getResources().getString(R.string.vowifi_call_quality_good);
+
+            case QtiCallConstants.VOWIFI_QUALITY_FAIR:
+                return mContext.getResources().getString(R.string.vowifi_call_quality_fair);
+
+            case QtiCallConstants.VOWIFI_QUALITY_POOR:
+                return mContext.getResources().getString(R.string.vowifi_call_quality_poor);
+        }
+      return null;
+    }
+
     /**
      * Updates the phone app's status bar notification *and* launches the
      * incoming call UI in response to a new incoming call.
@@ -287,10 +316,17 @@
         final int callState = call.getState();
 
         // Check if data has changed; if nothing is different, don't issue another notification.
-        final int iconResId = getIconToDisplay(call);
+        final int iconResId;
         Bitmap largeIcon = getLargeIconToDisplay(contactInfo, call);
         final String content =
                 getContentString(call, contactInfo.userType);
+        int wifiQualityValue = call.getWifiQuality();
+        if (wifiQualityValue != QtiCallConstants.VOWIFI_QUALITY_NONE) {
+            iconResId = getVoWiFiQualityIcon(wifiQualityValue);
+            content += " " + getVoWiFiQualityText(wifiQualityValue);
+        } else {
+            iconResId = getIconToDisplay(call);
+        }
         final String contentTitle = getContentTitle(contactInfo, call);
 
         final boolean isVideoUpgradeRequest = call.getSessionModificationState()