Indicate wifi for incoming calls.

This is done in the call card by showing the wifi icon.

This is done in the notification, by change the subtext.

For international calls in particular, this helps users understand
how accepting a phone call will affect the cost of their call.

Change-Id: Ifebd9f9cc8598b7fe5b693673b27a485f7ecdf0f
diff --git a/res/values/strings.xml b/res/values/strings.xml
index e8cc64c..45851f9 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -141,13 +141,18 @@
     <!-- Missed call notification message used for a single missed call, including
          the caller-id info from the missed call -->
     <string name="notification_missedCallTicker">Missed call from <xliff:g id="missed_call_from">%s</xliff:g></string>
-    <!-- The "label" of the in-call Notification for an ongoing call, used
-         as the format string for a Chronometer widget. [CHAR LIMIT=60] -->
+    <!-- The "label" of the in-call Notification for an ongoing call. [CHAR LIMIT=60] -->
     <string name="notification_ongoing_call">Ongoing call</string>
+    <!-- The "label" of the in-call Notification for an ongoing call, which is being made over
+         wi-fi. [CHAR LIMIT=60] -->
+    <string name="notification_ongoing_call_wifi">Ongoing wi-fi call</string>
     <!-- The "label" of the in-call Notification for a call that's on hold -->
     <string name="notification_on_hold">On hold</string>
-    <!-- The "label" of the in-call Notification for an incoming ringing call -->
+    <!-- The "label" of the in-call Notification for an incoming ringing call. [CHAR LIMIT=60] -->
     <string name="notification_incoming_call">Incoming call</string>
+    <!-- The "label" of the in-call Notification for an incoming ringing call,
+         which is being made over wi-fi. [CHAR LIMIT=60] -->
+    <string name="notification_incoming_call_wifi">Incoming wi-fi call</string>
     <!-- The "label" of the in-call Notification for an incoming ringing video call. -->
     <string name="notification_incoming_video_call">Incoming video call</string>
     <!-- The "label" of the in-call Notification for upgrading an existing call to a video call. -->
diff --git a/src/com/android/incallui/CallCardPresenter.java b/src/com/android/incallui/CallCardPresenter.java
index 47e4328..3944bf6 100644
--- a/src/com/android/incallui/CallCardPresenter.java
+++ b/src/com/android/incallui/CallCardPresenter.java
@@ -632,7 +632,8 @@
             }
         }
 
-        if (isPrimaryCallActive() && primaryCallCan(Details.CAPABILITY_WIFI)) {
+        if (primaryCallCan(Details.CAPABILITY_WIFI) && (isPrimaryCallActive()
+                || (mPrimary != null && mPrimary.getState() == Call.State.INCOMING))) {
             return mContext.getResources().getDrawable(R.drawable.ic_signal_wifi_4_bar_18dp);
         }
 
diff --git a/src/com/android/incallui/StatusBarNotifier.java b/src/com/android/incallui/StatusBarNotifier.java
index 99392d9..4a02160 100644
--- a/src/com/android/incallui/StatusBarNotifier.java
+++ b/src/com/android/incallui/StatusBarNotifier.java
@@ -30,6 +30,7 @@
 import android.graphics.drawable.BitmapDrawable;
 import android.os.Handler;
 import android.os.Message;
+import android.telecom.Call.Details;
 import android.telecom.PhoneAccount;
 import android.text.BidiFormatter;
 import android.text.TextDirectionHeuristics;
@@ -388,8 +389,7 @@
      * Returns the main string to use in the notification.
      */
     private String getContentTitle(ContactCacheEntry contactInfo, Call call) {
-        if (call.isConferenceCall()
-                && !call.can(android.telecom.Call.Details.CAPABILITY_GENERIC_CONFERENCE)) {
+        if (call.isConferenceCall() && !call.can(Details.CAPABILITY_GENERIC_CONFERENCE)) {
             return mContext.getResources().getString(R.string.card_title_conf_call);
         }
         if (TextUtils.isEmpty(contactInfo.name)) {
@@ -416,8 +416,7 @@
      */
     private Bitmap getLargeIconToDisplay(ContactCacheEntry contactInfo, Call call) {
         Bitmap largeIcon = null;
-        if (call.isConferenceCall()
-                && !call.can(android.telecom.Call.Details.CAPABILITY_GENERIC_CONFERENCE)) {
+        if (call.isConferenceCall() && !call.can(Details.CAPABILITY_GENERIC_CONFERENCE)) {
             largeIcon = BitmapFactory.decodeResource(mContext.getResources(),
                     R.drawable.img_conference);
         }
@@ -461,9 +460,16 @@
      */
     private int getContentString(Call call) {
         int resId = R.string.notification_ongoing_call;
+        if (call.can(Details.CAPABILITY_WIFI)) {
+            resId = R.string.notification_ongoing_call_wifi;
+        }
 
         if (call.getState() == Call.State.INCOMING || call.getState() == Call.State.CALL_WAITING) {
-            resId = R.string.notification_incoming_call;
+            if (call.can(Details.CAPABILITY_WIFI)) {
+                resId = R.string.notification_incoming_call_wifi;
+            } else {
+                resId = R.string.notification_incoming_call;
+            }
         } else if (call.getState() == Call.State.ONHOLD) {
             resId = R.string.notification_on_hold;
         } else if (Call.State.isDialing(call.getState())) {