Don't show SSID for Wi-Fi calls.

- Delete wifi icon and method to get SSID.
+ Use labels provided by StatusHints instead.

I'm not very happy with the additional "isWifi" cases I ended up
adding in call card fragment.

I felt this was necessary because of assumptions in some cases
that if a label is provided, it should be formatted as a phone
account source. While this was true before, it's becoming less so.
I feel like the fragment shouldn't have to worry about formatting
or choosing the label based on the call and  conditions. It should
just display the label if it thinks it is appropriate to show a
label given the call state.

To fix that, it seems like logic should be moved to the presenter
instead, and possibly to Telephony. But, I'm hesitant to do that
until these WFC changes back merge to master because of potential
merge conflicts and its slightly more risky for this branch,
because it starts dealing with logic/flows outside of WFC..

Bug: 19866988
Change-Id: Iacd5a09259c84ea7be28b0170ae603eb9561f7ca
diff --git a/res/drawable-hdpi/ic_signal_wifi_4_bar_18dp.png b/res/drawable-hdpi/ic_signal_wifi_4_bar_18dp.png
deleted file mode 100644
index d7b9805..0000000
--- a/res/drawable-hdpi/ic_signal_wifi_4_bar_18dp.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/ic_signal_wifi_4_bar_18dp.png b/res/drawable-mdpi/ic_signal_wifi_4_bar_18dp.png
deleted file mode 100644
index d537ab4..0000000
--- a/res/drawable-mdpi/ic_signal_wifi_4_bar_18dp.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/ic_signal_wifi_4_bar_18dp.png b/res/drawable-xhdpi/ic_signal_wifi_4_bar_18dp.png
deleted file mode 100644
index 5a53192..0000000
--- a/res/drawable-xhdpi/ic_signal_wifi_4_bar_18dp.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_signal_wifi_4_bar_18dp.png b/res/drawable-xxhdpi/ic_signal_wifi_4_bar_18dp.png
deleted file mode 100644
index b627198..0000000
--- a/res/drawable-xxhdpi/ic_signal_wifi_4_bar_18dp.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxxhdpi/ic_signal_wifi_4_bar_18dp.png b/res/drawable-xxxhdpi/ic_signal_wifi_4_bar_18dp.png
deleted file mode 100644
index f4105ec..0000000
--- a/res/drawable-xxxhdpi/ic_signal_wifi_4_bar_18dp.png
+++ /dev/null
Binary files differ
diff --git a/src/com/android/incallui/CallCardFragment.java b/src/com/android/incallui/CallCardFragment.java
index 8148761..28f449b 100644
--- a/src/com/android/incallui/CallCardFragment.java
+++ b/src/com/android/incallui/CallCardFragment.java
@@ -488,10 +488,11 @@
             DisconnectCause disconnectCause,
             String connectionLabel,
             Drawable callStateIcon,
-            String gatewayNumber) {
+            String gatewayNumber,
+            boolean isWifi) {
         boolean isGatewayCall = !TextUtils.isEmpty(gatewayNumber);
         CharSequence callStateLabel = getCallStateLabelFromState(state, videoState,
-                sessionModificationState, disconnectCause, connectionLabel, isGatewayCall);
+                sessionModificationState, disconnectCause, connectionLabel, isGatewayCall, isWifi);
 
         Log.v(this, "setCallState " + callStateLabel);
         Log.v(this, "DisconnectCause " + disconnectCause.toString());
@@ -499,6 +500,10 @@
 
         if (TextUtils.equals(callStateLabel, mCallStateLabel.getText())) {
             // Nothing to do if the labels are the same
+            if (state == Call.State.ACTIVE || state == Call.State.CONFERENCED) {
+                mCallStateLabel.clearAnimation();
+                mCallStateIcon.clearAnimation();
+            }
             return;
         }
 
@@ -652,10 +657,11 @@
      *         2. Ongoing calls will display the name of the provider.
      *         3. Incoming calls will only display "Incoming via..." for accounts.
      *         4. Video calls, and session modification states (eg. requesting video).
+     *         5. Incoming and active Wi-Fi calls will show label provided by hint.
      */
     private CharSequence getCallStateLabelFromState(int state, int videoState,
             int sessionModificationState, DisconnectCause disconnectCause, String label,
-            boolean isGatewayCall) {
+            boolean isGatewayCall, boolean isWifi) {
         final Context context = getView().getContext();
         CharSequence callStateLabel = null;  // Label to display as part of the call banner
 
@@ -669,7 +675,7 @@
             case Call.State.ACTIVE:
                 // We normally don't show a "call state label" at all in this state
                 // (but we can use the call state label to display the provider name).
-                if (isAccount) {
+                if (isAccount || isWifi) {
                     callStateLabel = label;
                 } else if (sessionModificationState
                         == Call.SessionModificationState.REQUEST_FAILED) {
@@ -686,7 +692,7 @@
                 break;
             case Call.State.CONNECTING:
             case Call.State.DIALING:
-                if (isSpecialCall) {
+                if (isSpecialCall && !isWifi) {
                     callStateLabel = context.getString(R.string.calling_via_template, label);
                 } else {
                     callStateLabel = context.getString(R.string.card_title_dialing);
@@ -697,7 +703,9 @@
                 break;
             case Call.State.INCOMING:
             case Call.State.CALL_WAITING:
-                if (isAccount) {
+                if (isWifi) {
+                    callStateLabel = label;
+                } else if (isAccount) {
                     callStateLabel = context.getString(R.string.incoming_via_template, label);
                 } else if (VideoProfile.VideoState.isBidirectional(videoState)) {
                     callStateLabel = context.getString(R.string.notification_incoming_video_call);
diff --git a/src/com/android/incallui/CallCardPresenter.java b/src/com/android/incallui/CallCardPresenter.java
index 3944bf6..d7e39d8 100644
--- a/src/com/android/incallui/CallCardPresenter.java
+++ b/src/com/android/incallui/CallCardPresenter.java
@@ -23,7 +23,6 @@
 import android.content.pm.PackageManager;
 import android.graphics.drawable.Drawable;
 import android.net.Uri;
-import android.net.wifi.WifiManager;
 import android.os.Bundle;
 import android.telecom.Call.Details;
 import android.telecom.DisconnectCause;
@@ -68,7 +67,6 @@
     private CallTimer mCallTimer;
 
     private Context mContext;
-    private WifiManager mWifiManager;
 
     public static class ContactLookupCallback implements ContactInfoCacheCallback {
         private final WeakReference<CallCardPresenter> mCallCardPresenter;
@@ -109,7 +107,6 @@
 
     public void init(Context context, Call call) {
         mContext = Preconditions.checkNotNull(context);
-        mWifiManager = (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE);
 
         // Call may be null if disconnect happened already.
         if (call != null) {
@@ -246,7 +243,8 @@
                     new DisconnectCause(DisconnectCause.UNKNOWN),
                     null,
                     null,
-                    null);
+                    null,
+                    false /* isWifi */);
             getUi().showHdAudioIndicator(false);
         }
 
@@ -301,7 +299,8 @@
                     mPrimary.getDisconnectCause(),
                     getConnectionLabel(),
                     getCallStateIcon(),
-                    getGatewayNumber());
+                    getGatewayNumber(),
+                    primaryCallCan(Details.CAPABILITY_WIFI));
 
             boolean showHdAudioIndicator =
                     isPrimaryCallActive() && primaryCallCan(Details.CAPABILITY_HIGH_DEF_AUDIO);
@@ -600,13 +599,6 @@
             return statusHints.getLabel().toString();
         }
 
-        // Assume the SSID of the connection reported by the WifiManager is the name of the wifi
-        // network used for calling, since currently a phone only connects to a single wifi network.
-        if (isPrimaryCallActive() && primaryCallCan(Details.CAPABILITY_WIFI)
-                && mWifiManager.getConnectionInfo() != null) {
-            return formatWifiSSID(mWifiManager.getConnectionInfo().getSSID());
-        }
-
         if (hasOutgoingGatewayCall() && getUi() != null) {
             // Return the label for the gateway app on outgoing calls.
             final PackageManager pm = mContext.getPackageManager();
@@ -632,11 +624,6 @@
             }
         }
 
-        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);
-        }
-
         return null;
     }
 
@@ -742,34 +729,6 @@
         return photo;
     }
 
-    /**
-     * Strip quotations off the outside of a Wifi SSID identifier. For example, \"GoogleGuest\"
-     * becomes GoogleGuest.
-     *
-     * TODO: Move into utility class.
-     * TODO: Add unit tests.
-     *
-     * @param ssid The ssid of the wifi network.
-     */
-    private String formatWifiSSID(String ssid) {
-        if (TextUtils.isEmpty(ssid)) {
-            return "";
-        }
-
-        // Trim quotation if first character.
-        if (ssid.charAt(0) == '\"') {
-            ssid = ssid.substring(1);
-        }
-
-        // Trim quotation if last character.
-        int lastIndex = ssid.length() - 1;
-        if (lastIndex >= 0 && ssid.charAt(lastIndex) == '\"') {
-            ssid = ssid.substring(0, lastIndex);
-        }
-
-        return ssid;
-    }
-
     public interface CallCardUi extends Ui {
         void setVisible(boolean on);
         void setCallCardVisible(boolean visible);
@@ -779,7 +738,7 @@
                 String providerLabel, boolean isConference);
         void setCallState(int state, int videoState, int sessionModificationState,
                 DisconnectCause disconnectCause, String connectionLabel,
-                Drawable connectionIcon, String gatewayNumber);
+                Drawable connectionIcon, String gatewayNumber, boolean isWifi);
         void setPrimaryCallElapsedTime(boolean show, long duration);
         void setPrimaryName(String name, boolean nameIsNumber);
         void setPrimaryImage(Drawable image);