IMS: Notify about change of TTY mode of other call participants

Display message when TTY mode of other party changed
during VoLTE phone call

Bug: 18247323
Change-Id: Ia8ea3a277b06582a7d11a3c7a21b477350804ca9
diff --git a/src/com/android/phone/CallNotifier.java b/src/com/android/phone/CallNotifier.java
index 5b60f8a..3669544 100644
--- a/src/com/android/phone/CallNotifier.java
+++ b/src/com/android/phone/CallNotifier.java
@@ -46,6 +46,7 @@
 import android.os.Vibrator;
 import android.provider.CallLog.Calls;
 import android.provider.Settings;
+import android.telecom.TelecomManager;
 import android.telephony.DisconnectCause;
 import android.telephony.PhoneNumberUtils;
 import android.telephony.PhoneStateListener;
@@ -255,6 +256,11 @@
                 onSuppServiceFailed((AsyncResult) msg.obj);
                 break;
 
+            case CallStateMonitor.PHONE_TTY_MODE_RECEIVED:
+                if (DBG) log("Received PHONE_TTY_MODE_RECEIVED event");
+                onTtyModeReceived((AsyncResult) msg.obj);
+                break;
+
             default:
                 // super.handleMessage(msg);
         }
@@ -979,6 +985,42 @@
     }
 
     /**
+     * Displays a notification when the phone receives a notice that TTY mode
+     * has changed on remote end.
+     */
+    private void onTtyModeReceived(AsyncResult r) {
+        if (DBG) log("TtyModeReceived: displaying notification message");
+
+        int resId = 0;
+        switch (((Integer)r.result).intValue()) {
+            case TelecomManager.TTY_MODE_FULL:
+                resId = com.android.internal.R.string.peerTtyModeFull;
+                break;
+            case TelecomManager.TTY_MODE_HCO:
+                resId = com.android.internal.R.string.peerTtyModeHco;
+                break;
+            case TelecomManager.TTY_MODE_VCO:
+                resId = com.android.internal.R.string.peerTtyModeVco;
+                break;
+            case TelecomManager.TTY_MODE_OFF:
+                resId = com.android.internal.R.string.peerTtyModeOff;
+                break;
+            default:
+                Log.e(LOG_TAG, "Unsupported TTY mode: " + r.result);
+                break;
+        }
+        if (resId != 0) {
+            PhoneDisplayMessage.displayNetworkMessage(mApplication,
+                    mApplication.getResources().getString(resId));
+
+            // start a timer that kills the dialog
+            sendEmptyMessageDelayed(
+                    CallStateMonitor.INTERNAL_SHOW_MESSAGE_NOTIFICATION_DONE,
+                    SHOW_MESSAGE_NOTIFICATION_TIME);
+        }
+    }
+
+    /**
      * Helper class to play SignalInfo tones using the ToneGenerator.
      *
      * To use, just instantiate a new SignalInfoTonePlayer