1 /**
2  * Copyright (C) 2022 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package android.telephony.imsmedia;
18 
19 import android.os.IBinder;
20 import android.os.RemoteException;
21 import android.util.Log;
22 
23 /**
24  * API to manage the text session
25  *
26  * @hide
27  */
28 public class ImsTextSession implements ImsMediaSession {
29     private static final String TAG = "ImsTextSession";
30     private final IImsTextSession mSession;
31 
32     /** @hide */
ImsTextSession(final IImsTextSession session)33     public ImsTextSession(final IImsTextSession session) {
34         mSession = session;
35     }
36 
37     /** @hide */
38     @Override
getBinder()39     public IBinder getBinder() {
40         return mSession.asBinder();
41     }
42 
43     /** {@inheritDoc} */
getSessionId()44     public int getSessionId() {
45         try {
46             return mSession.getSessionId();
47         } catch (RemoteException e) {
48             Log.e(TAG, "Failed to get session ID: " + e);
49         }
50 
51         return -1;
52     }
53 
54     /**
55      * {@inheritDoc}
56      */
modifySession(final RtpConfig config)57     public void modifySession(final RtpConfig config) {
58         try {
59             mSession.modifySession((TextConfig) config);
60         } catch (RemoteException e) {
61             Log.e(TAG, "Failed to modify session: " + e);
62         }
63     }
64 
65     /**
66      * {@inheritDoc}
67      */
setMediaQualityThreshold(final MediaQualityThreshold threshold)68     public void setMediaQualityThreshold(final MediaQualityThreshold threshold) {
69         try {
70             mSession.setMediaQualityThreshold(threshold);
71         } catch (RemoteException e) {
72             Log.e(TAG, "Failed to set media quality threshold: " + e);
73         }
74     }
75 
76     /**
77      * Send Rtt text stream
78      *
79      * @param text The text string
80      */
sendRtt(final String text)81     public void sendRtt(final String text) {
82         try {
83             mSession.sendRtt(text);
84         } catch (RemoteException e) {
85             Log.e(TAG, "Failed to request video data usage: " + e);
86         }
87     }
88 }
89