Merge "IMS: RTT interface changes" am: 814fdf9312 am: bc56b97770
am: 7d1712e5b9

Change-Id: Ia5c6a16a69c71cfd96479e8df403669d5aaff6f9
diff --git a/telephony/java/android/telephony/ims/stub/ImsCallSessionImplBase.java b/telephony/java/android/telephony/ims/stub/ImsCallSessionImplBase.java
index 69b8acc..80b2f78 100644
--- a/telephony/java/android/telephony/ims/stub/ImsCallSessionImplBase.java
+++ b/telephony/java/android/telephony/ims/stub/ImsCallSessionImplBase.java
@@ -345,4 +345,29 @@
     public boolean isMultiparty() throws RemoteException {
         return false;
     }
+
+    /**
+     * Device issues RTT modify request
+     * @param toProfile The profile with requested changes made
+     */
+    @Override
+    public void sendRttModifyRequest(ImsCallProfile toProfile) {
+    }
+
+    /**
+     * Device responds to Remote RTT modify request
+     * @param status true  Accepted the request
+     *                false  Declined the request
+     */
+    @Override
+    public void sendRttModifyResponse(boolean status) {
+    }
+
+    /**
+     * Device sends RTT message
+     * @param rttMessage RTT message to be sent
+     */
+    @Override
+    public void sendRttMessage(String rttMessage) {
+    }
 }
diff --git a/telephony/java/android/telephony/ims/stub/ImsCallSessionListenerImplBase.java b/telephony/java/android/telephony/ims/stub/ImsCallSessionListenerImplBase.java
index 46f8f80..12228a1 100644
--- a/telephony/java/android/telephony/ims/stub/ImsCallSessionListenerImplBase.java
+++ b/telephony/java/android/telephony/ims/stub/ImsCallSessionListenerImplBase.java
@@ -247,5 +247,35 @@
             ImsSuppServiceNotification suppSrvNotification) {
         // no-op
     }
+
+    /**
+     * Received RTT modify request from Remote Party
+     * @param session The call session.
+     * @param callProfile ImsCallProfile with updated attribute
+     */
+    @Override
+    public void callSessionRttModifyRequestReceived(IImsCallSession session,
+            ImsCallProfile callProfile) {
+        // no-op
+    }
+
+    /**
+     * Received response for RTT modify request
+     * @param status true : Accepted the request
+     *               false : Declined the request
+     */
+    @Override
+    public void callSessionRttModifyResponseReceived(int status) {
+        // no -op
+    }
+
+    /**
+     * Device received RTT message from Remote UE
+     * @param rttMessage RTT message received
+     */
+    @Override
+    public void callSessionRttMessageReceived(String rttMessage) {
+        // no-op
+    }
 }
 
diff --git a/telephony/java/com/android/ims/ImsConfig.java b/telephony/java/com/android/ims/ImsConfig.java
index cd076b1..c301029 100644
--- a/telephony/java/com/android/ims/ImsConfig.java
+++ b/telephony/java/com/android/ims/ImsConfig.java
@@ -475,9 +475,15 @@
          */
         public static final int VICE_SETTING_ENABLED = 65;
 
+        /**
+         * RTT status: Enabled (1), or Disabled (0).
+         * Value is in Integer format.
+         */
+        public static final int RTT_SETTING_ENABLED = 66;
+
         // Expand the operator config items as needed here, need to change
         // PROVISIONED_CONFIG_END after that.
-        public static final int PROVISIONED_CONFIG_END = VICE_SETTING_ENABLED;
+        public static final int PROVISIONED_CONFIG_END = RTT_SETTING_ENABLED;
 
         // Expand the operator config items as needed here.
     }
diff --git a/telephony/java/com/android/ims/ImsStreamMediaProfile.java b/telephony/java/com/android/ims/ImsStreamMediaProfile.java
index 216cef5..cfe37b5 100644
--- a/telephony/java/com/android/ims/ImsStreamMediaProfile.java
+++ b/telephony/java/com/android/ims/ImsStreamMediaProfile.java
@@ -72,14 +72,20 @@
     public static final int VIDEO_QUALITY_VGA_LANDSCAPE = (1 << 3);
     public static final int VIDEO_QUALITY_VGA_PORTRAIT = (1 << 4);
 
+    /**
+     * RTT Modes
+     */
+    public static final int RTT_MODE_DISABLED = 0;
+    public static final int RTT_MODE_FULL = 1;
+
     // Audio related information
     public int mAudioQuality;
     public int mAudioDirection;
     // Video related information
     public int mVideoQuality;
     public int mVideoDirection;
-
-
+    // Rtt related information
+    public int mRttMode;
 
     public ImsStreamMediaProfile(Parcel in) {
         readFromParcel(in);
@@ -90,6 +96,7 @@
         mAudioDirection = DIRECTION_SEND_RECEIVE;
         mVideoQuality = VIDEO_QUALITY_NONE;
         mVideoDirection = DIRECTION_INVALID;
+        mRttMode = RTT_MODE_DISABLED;
     }
 
     public ImsStreamMediaProfile(int audioQuality, int audioDirection,
@@ -100,11 +107,16 @@
         mVideoDirection = videoDirection;
     }
 
+    public ImsStreamMediaProfile(int rttMode) {
+        mRttMode = rttMode;
+    }
+
     public void copyFrom(ImsStreamMediaProfile profile) {
         mAudioQuality = profile.mAudioQuality;
         mAudioDirection = profile.mAudioDirection;
         mVideoQuality = profile.mVideoQuality;
         mVideoDirection = profile.mVideoDirection;
+        mRttMode = profile.mRttMode;
     }
 
     @Override
@@ -112,7 +124,8 @@
         return "{ audioQuality=" + mAudioQuality +
                 ", audioDirection=" + mAudioDirection +
                 ", videoQuality=" + mVideoQuality +
-                ", videoDirection=" + mVideoDirection + " }";
+                ", videoDirection=" + mVideoDirection +
+                ", rttMode=" + mRttMode + " }";
     }
 
     @Override
@@ -126,6 +139,7 @@
         out.writeInt(mAudioDirection);
         out.writeInt(mVideoQuality);
         out.writeInt(mVideoDirection);
+        out.writeInt(mRttMode);
     }
 
     private void readFromParcel(Parcel in) {
@@ -133,6 +147,7 @@
         mAudioDirection = in.readInt();
         mVideoQuality = in.readInt();
         mVideoDirection = in.readInt();
+        mRttMode = in.readInt();
     }
 
     public static final Creator<ImsStreamMediaProfile> CREATOR =
@@ -147,4 +162,20 @@
             return new ImsStreamMediaProfile[size];
         }
     };
+
+    /**
+     * Determines if it's RTT call
+     * @return true if RTT call, false otherwise.
+     */
+    public boolean isRttCall() {
+        return (mRttMode == RTT_MODE_FULL);
+    }
+
+    /**
+     * Updates the RttCall attribute
+     */
+    public void setRttMode(int rttMode) {
+        mRttMode = rttMode;
+    }
+
 }
diff --git a/telephony/java/com/android/ims/internal/IImsCallSession.aidl b/telephony/java/com/android/ims/internal/IImsCallSession.aidl
index b1f2d32..c6fc5e5 100644
--- a/telephony/java/com/android/ims/internal/IImsCallSession.aidl
+++ b/telephony/java/com/android/ims/internal/IImsCallSession.aidl
@@ -255,4 +255,23 @@
      * @return {@code True} if the session is multiparty.
      */
     boolean isMultiparty();
+
+    /**
+     * Device issues RTT modify request
+     * @param toProfile The profile with requested changes made
+     */
+    void sendRttModifyRequest(in ImsCallProfile toProfile);
+
+    /*
+     * Device responds to Remote RTT modify request
+     * @param status true : Accepted the request
+     *                false : Declined the request
+     */
+    void sendRttModifyResponse(in boolean status);
+
+    /*
+     * Device sends RTT message
+     * @param rttMessage RTT message to be sent
+     */
+    void sendRttMessage(in String rttMessage);
 }
diff --git a/telephony/java/com/android/ims/internal/IImsCallSessionListener.aidl b/telephony/java/com/android/ims/internal/IImsCallSessionListener.aidl
index d562ecc..ad59c1d8 100644
--- a/telephony/java/com/android/ims/internal/IImsCallSessionListener.aidl
+++ b/telephony/java/com/android/ims/internal/IImsCallSessionListener.aidl
@@ -130,4 +130,24 @@
      */
     void callSessionSuppServiceReceived(in IImsCallSession session,
          in ImsSuppServiceNotification suppSrvNotification);
+
+    /**
+     * Device received RTT modify request from Remote UE
+     * @param session ImsCallProfile with updated attribute
+     */
+    void callSessionRttModifyRequestReceived(in IImsCallSession session,
+            in ImsCallProfile callProfile);
+
+    /* Device issued RTT modify request and inturn received response
+     * from Remote UE
+     * @param status Will be one of the following values from:
+     * - {@link Connection.RttModifyStatus}
+     */
+    void callSessionRttModifyResponseReceived(in int status);
+
+    /*
+     * While in call, device received RTT message from Remote UE
+     * @param rttMessage Received RTT message
+     */
+    void callSessionRttMessageReceived(in String rttMessage);
 }
diff --git a/telephony/java/com/android/ims/internal/ImsCallSession.java b/telephony/java/com/android/ims/internal/ImsCallSession.java
index 8196b23..f20f7c8 100644
--- a/telephony/java/com/android/ims/internal/ImsCallSession.java
+++ b/telephony/java/com/android/ims/internal/ImsCallSession.java
@@ -403,6 +403,28 @@
         public void callSessionSuppServiceReceived(ImsCallSession session,
                 ImsSuppServiceNotification suppServiceInfo) {
         }
+
+        /**
+         * Received RTT modify request from Remote Party
+         */
+        public void callSessionRttModifyRequestReceived(ImsCallSession session,
+            ImsCallProfile callProfile) {
+            // no-op
+        }
+
+        /**
+         * Received response for RTT modify request
+         */
+        public void callSessionRttModifyResponseReceived(int status) {
+            // no -op
+        }
+
+        /**
+         * Device received RTT message from Remote UE
+         */
+        public void callSessionRttMessageReceived(String rttMessage) {
+            // no-op
+        }
     }
 
     private final IImsCallSession miSession;
@@ -944,6 +966,57 @@
     }
 
     /**
+     * Sends Rtt Message
+     *
+     * @param rttMessage rtt text to be sent
+     * @throws ImsException if call is absent
+     */
+    public void sendRttMessage(String rttMessage) {
+        if (mClosed) {
+            return;
+        }
+
+        try {
+            miSession.sendRttMessage(rttMessage);
+        } catch (RemoteException e) {
+        }
+    }
+
+    /**
+     * Sends RTT Upgrade request
+     *
+     * @param to   : expected profile
+     * @throws CallStateException
+     */
+    public void sendRttModifyRequest(ImsCallProfile to) {
+        if (mClosed) {
+            return;
+        }
+
+        try {
+            miSession.sendRttModifyRequest(to);
+        } catch (RemoteException e) {
+        }
+    }
+
+    /**
+     * Sends RTT Upgrade response
+     *
+     * @param response : response for upgrade
+     * @throws CallStateException
+     */
+    public void sendRttModifyResponse(boolean response) {
+        if (mClosed) {
+            return;
+        }
+
+        try {
+            miSession.sendRttModifyResponse(response);
+        } catch (RemoteException e) {
+        }
+    }
+
+    /**
      * A listener type for receiving notification on IMS call session events.
      * When an event is generated for an {@link IImsCallSession},
      * the application is notified by having one of the methods called on
@@ -1267,6 +1340,36 @@
             }
         }
 
+        /**
+         * Received RTT modify request from remote party
+         */
+        @Override
+        public void callSessionRttModifyRequestReceived(IImsCallSession session,
+                ImsCallProfile callProfile) {
+            if (mListener != null) {
+                mListener.callSessionRttModifyRequestReceived(ImsCallSession.this, callProfile);
+            }
+        }
+
+        /**
+         * Received response for RTT modify request
+         */
+        @Override
+        public void callSessionRttModifyResponseReceived(int status) {
+            if (mListener != null) {
+                mListener.callSessionRttModifyResponseReceived(status);
+            }
+        }
+
+        /**
+         * RTT Message received
+         */
+        @Override
+        public void callSessionRttMessageReceived(String rttMessage) {
+            if (mListener != null) {
+                mListener.callSessionRttMessageReceived(rttMessage);
+            }
+        }
     }
 
     /**