TTY over IMS: Notify the user that TTY mode changed in the far device
Pavel Zhamaitsiak [Sun, 16 Nov 2014 23:29:09 +0000 (15:29 -0800)]
Bug: 18247323
Change-Id: I9847d947c9d1ee97da0151a7ccfac35aa6a7b9c4

src/java/com/android/ims/ImsCall.java
src/java/com/android/ims/internal/ImsCallSession.java

index 342f527..c65516b 100644 (file)
@@ -28,8 +28,11 @@ import android.content.Context;
 import android.net.Uri;
 import android.os.Bundle;
 import android.os.Message;
+import android.provider.Settings;
 import android.telecom.ConferenceParticipant;
+import android.telecom.TelecomManager;
 import android.telephony.Rlog;
+import android.widget.Toast;
 
 import com.android.ims.internal.CallGroup;
 import com.android.ims.internal.CallGroupManager;
@@ -2609,6 +2612,40 @@ public class ImsCall implements ICall {
                 }
             }
         }
+
+        @Override
+        public void callSessionTtyModeReceived(ImsCallSession session, int mode) {
+            if (DBG) {
+                log("callSessionTtyModeReceived :: session=" + session
+                        + ", mode=" + mode);
+            }
+
+            int settingsTtyMode = Settings.Secure.getInt(
+                    mContext.getContentResolver(),
+                    Settings.Secure.PREFERRED_TTY_MODE,
+                    TelecomManager.TTY_MODE_OFF);
+            if (settingsTtyMode == TelecomManager.TTY_MODE_OFF) {
+                // Notify the user that TTY mode changed in the far device
+                int resId = 0;
+                switch (mode) {
+                    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;
+                }
+                if (resId != 0) {
+                    Toast.makeText(mContext, resId, Toast.LENGTH_SHORT).show();
+                }
+            }
+        }
     }
 
     /**
index eeca7a8..2acc433 100644 (file)
@@ -365,6 +365,17 @@ public class ImsCallSession {
                                        ImsReasonInfo reasonInfo) {
             // no-op
         }
+
+        /**
+         * Called when TTY mode of remote party changed
+         *
+         * @param session IMS session object
+         * @param mode TTY mode of remote party
+         */
+        public void callSessionTtyModeReceived(ImsCallSession session,
+                                       int mode) {
+            // no-op
+        }
     }
 
     private final IImsCallSession miSession;
@@ -1125,8 +1136,7 @@ public class ImsCallSession {
         public void callSessionTtyModeReceived(IImsCallSession session,
                 int mode) {
             if (mListener != null) {
-                //TODO: UI specific implementation.
-                //Vendor UI can listen to this callback to take action on received TTY mode.
+                mListener.callSessionTtyModeReceived(ImsCallSession.this, mode);
             }
         }
     }