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