1 /*
2  * Copyright (c) 2013 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 com.android.ims.internal;
18 
19 import android.os.Message;
20 import com.android.ims.ImsCallProfile;
21 import com.android.ims.ImsStreamMediaProfile;
22 import com.android.ims.internal.IImsCallSessionListener;
23 import com.android.ims.internal.IImsVideoCallProvider;
24 
25 /**
26  * An IMS session that is associated with a SIP dialog which is established from/to
27  * INVITE request or a mid-call transaction to control the session.
28  * {@hide}
29  */
30 interface IImsCallSession {
31     /**
32      * Closes the object. This object is not usable after being closed.
33      */
close()34     void close();
35 
36     /**
37      * Gets the call ID of the session.
38      *
39      * @return the call ID
40      */
getCallId()41     String getCallId();
42 
43     /**
44      * Gets the call profile that this session is associated with
45      *
46      * @return the call profile that this session is associated with
47      */
getCallProfile()48     ImsCallProfile getCallProfile();
49 
50     /**
51      * Gets the local call profile that this session is associated with
52      *
53      * @return the local call profile that this session is associated with
54      */
getLocalCallProfile()55     ImsCallProfile getLocalCallProfile();
56 
57     /**
58      * Gets the remote call profile that this session is associated with
59      *
60      * @return the remote call profile that this session is associated with
61      */
getRemoteCallProfile()62     ImsCallProfile getRemoteCallProfile();
63 
64     /**
65      * Gets the value associated with the specified property of this session.
66      *
67      * @return the string value associated with the specified property
68      */
getProperty(String name)69     String getProperty(String name);
70 
71     /**
72      * Gets the session state. The value returned must be one of the states in
73      * {@link ImsCallSession#State}.
74      *
75      * @return the session state
76      */
getState()77     int getState();
78 
79     /**
80      * Checks if the session is in a call.
81      *
82      * @return true if the session is in a call
83      */
isInCall()84     boolean isInCall();
85 
86     /**
87      * Sets the listener to listen to the session events. A {@link IImsCallSession}
88      * can only hold one listener at a time. Subsequent calls to this method
89      * override the previous listener.
90      *
91      * @param listener to listen to the session events of this object
92      */
setListener(in IImsCallSessionListener listener)93     void setListener(in IImsCallSessionListener listener);
94 
95     /**
96      * Mutes or unmutes the mic for the active call.
97      *
98      * @param muted true if the call is muted, false otherwise
99      */
setMute(boolean muted)100     void setMute(boolean muted);
101 
102     /**
103      * Initiates an IMS call with the specified target and call profile.
104      * The session listener is called back upon defined session events.
105      * The method is only valid to call when the session state is in
106      * {@link ImsCallSession#State#IDLE}.
107      *
108      * @param callee dialed string to make the call to
109      * @param profile call profile to make the call with the specified service type,
110      *      call type and media information
111      * @see Listener#callSessionStarted, Listener#callSessionStartFailed
112      */
start(String callee, in ImsCallProfile profile)113     void start(String callee, in ImsCallProfile profile);
114 
115     /**
116      * Initiates an IMS call with the specified participants and call profile.
117      * The session listener is called back upon defined session events.
118      * The method is only valid to call when the session state is in
119      * {@link ImsCallSession#State#IDLE}.
120      *
121      * @param participants participant list to initiate an IMS conference call
122      * @param profile call profile to make the call with the specified service type,
123      *      call type and media information
124      * @see Listener#callSessionStarted, Listener#callSessionStartFailed
125      */
startConference(in String[] participants, in ImsCallProfile profile)126     void startConference(in String[] participants, in ImsCallProfile profile);
127 
128     /**
129      * Accepts an incoming call or session update.
130      *
131      * @param callType call type specified in {@link ImsCallProfile} to be answered
132      * @param profile stream media profile {@link ImsStreamMediaProfile} to be answered
133      * @see Listener#callSessionStarted
134      */
accept(int callType, in ImsStreamMediaProfile profile)135     void accept(int callType, in ImsStreamMediaProfile profile);
136 
137     /**
138      * Rejects an incoming call or session update.
139      *
140      * @param reason reason code to reject an incoming call
141      * @see Listener#callSessionStartFailed
142      */
reject(int reason)143     void reject(int reason);
144 
145     /**
146      * Terminates a call.
147      *
148      * @see Listener#callSessionTerminated
149      */
terminate(int reason)150     void terminate(int reason);
151 
152     /**
153      * Puts a call on hold. When it succeeds, {@link Listener#callSessionHeld} is called.
154      *
155      * @param profile stream media profile {@link ImsStreamMediaProfile} to hold the call
156      * @see Listener#callSessionHeld, Listener#callSessionHoldFailed
157      */
hold(in ImsStreamMediaProfile profile)158     void hold(in ImsStreamMediaProfile profile);
159 
160     /**
161      * Continues a call that's on hold. When it succeeds, {@link Listener#callSessionResumed}
162      * is called.
163      *
164      * @param profile stream media profile {@link ImsStreamMediaProfile} to resume the call
165      * @see Listener#callSessionResumed, Listener#callSessionResumeFailed
166      */
resume(in ImsStreamMediaProfile profile)167     void resume(in ImsStreamMediaProfile profile);
168 
169     /**
170      * Merges the active & hold call. When the merge starts,
171      * {@link Listener#callSessionMergeStarted} is called.
172      * {@link Listener#callSessionMergeComplete} is called if the merge is successful, and
173      * {@link Listener#callSessionMergeFailed} is called if the merge fails.
174      *
175      * @see Listener#callSessionMergeStarted, Listener#callSessionMergeComplete,
176      *      Listener#callSessionMergeFailed
177      */
merge()178     void merge();
179 
180     /**
181      * Updates the current call's properties (ex. call mode change: video upgrade / downgrade).
182      *
183      * @param callType call type specified in {@link ImsCallProfile} to be updated
184      * @param profile stream media profile {@link ImsStreamMediaProfile} to be updated
185      * @see Listener#callSessionUpdated, Listener#callSessionUpdateFailed
186      */
update(int callType, in ImsStreamMediaProfile profile)187     void update(int callType, in ImsStreamMediaProfile profile);
188 
189     /**
190      * Extends this call to the conference call with the specified recipients.
191      *
192      * @param participants participant list to be invited to the conference call after extending the call
193      * @see Listener#sessionConferenceExtened, Listener#sessionConferenceExtendFailed
194      */
extendToConference(in String[] participants)195     void extendToConference(in String[] participants);
196 
197     /**
198      * Requests the conference server to invite an additional participants to the conference.
199      *
200      * @param participants participant list to be invited to the conference call
201      * @see Listener#sessionInviteParticipantsRequestDelivered,
202      *      Listener#sessionInviteParticipantsRequestFailed
203      */
inviteParticipants(in String[] participants)204     void inviteParticipants(in String[] participants);
205 
206     /**
207      * Requests the conference server to remove the specified participants from the conference.
208      *
209      * @param participants participant list to be removed from the conference call
210      * @see Listener#sessionRemoveParticipantsRequestDelivered,
211      *      Listener#sessionRemoveParticipantsRequestFailed
212      */
removeParticipants(in String[] participants)213     void removeParticipants(in String[] participants);
214 
215     /**
216      * Sends a DTMF code. According to <a href="http://tools.ietf.org/html/rfc2833">RFC 2833</a>,
217      * event 0 ~ 9 maps to decimal value 0 ~ 9, '*' to 10, '#' to 11, event 'A' ~ 'D' to 12 ~ 15,
218      * and event flash to 16. Currently, event flash is not supported.
219      *
220      * @param c the DTMF to send. '0' ~ '9', 'A' ~ 'D', '*', '#' are valid inputs.
221      * @param result.
222      */
sendDtmf(char c, in Message result)223     void sendDtmf(char c, in Message result);
224 
225     /**
226      * Start a DTMF code. According to <a href="http://tools.ietf.org/html/rfc2833">RFC 2833</a>,
227      * event 0 ~ 9 maps to decimal value 0 ~ 9, '*' to 10, '#' to 11, event 'A' ~ 'D' to 12 ~ 15,
228      * and event flash to 16. Currently, event flash is not supported.
229      *
230      * @param c the DTMF to send. '0' ~ '9', 'A' ~ 'D', '*', '#' are valid inputs.
231      */
startDtmf(char c)232     void startDtmf(char c);
233 
234     /**
235      * Stop a DTMF code.
236      */
stopDtmf()237     void stopDtmf();
238 
239     /**
240      * Sends an USSD message.
241      *
242      * @param ussdMessage USSD message to send
243      */
sendUssd(String ussdMessage)244     void sendUssd(String ussdMessage);
245 
246     /**
247      * Returns a binder for the video call provider implementation contained within the IMS service
248      * process. This binder is used by the VideoCallProvider subclass in Telephony which
249      * intermediates between the propriety implementation and Telecomm/InCall.
250      */
getVideoCallProvider()251     IImsVideoCallProvider getVideoCallProvider();
252 
253     /**
254      * Determines if the current session is multiparty.
255      * @return {@code True} if the session is multiparty.
256      */
isMultiparty()257     boolean isMultiparty();
258 }
259