1/*
2 * Copyright (C) 2018 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 android.telephony.ims.compat.stub;
18
19import android.os.Message;
20import android.os.RemoteException;
21
22import android.telephony.ims.ImsCallProfile;
23import android.telephony.ims.ImsConferenceState;
24import android.telephony.ims.ImsReasonInfo;
25import android.telephony.ims.ImsStreamMediaProfile;
26import android.telephony.ims.ImsSuppServiceNotification;
27import android.telephony.ims.aidl.IImsCallSessionListener;
28import com.android.ims.internal.IImsCallSession;
29import com.android.ims.internal.IImsVideoCallProvider;
30
31import android.telephony.ims.ImsCallSession;
32
33/**
34 * Compat implementation of ImsCallSessionImplBase for older implementations.
35 *
36 * DO NOT remove or change the existing APIs, only add new ones to this Base implementation or you
37 * will break other implementations of ImsCallSession maintained by other ImsServices.
38 *
39 * @hide
40 */
41
42public class ImsCallSessionImplBase extends IImsCallSession.Stub {
43
44    @Override
45    // convert to old implementation of listener
46    public final void setListener(IImsCallSessionListener listener)
47            throws RemoteException {
48        setListener(new ImsCallSessionListenerConverter(listener));
49    }
50
51    /**
52     * Sets the listener to listen to the session events. An {@link ImsCallSession}
53     * can only hold one listener at a time. Subsequent calls to this method
54     * override the previous listener.
55     *
56     * @param listener to listen to the session events of this object
57     */
58    public void setListener(com.android.ims.internal.IImsCallSessionListener listener) {
59
60    }
61
62    /**
63     * Closes the object. This {@link ImsCallSessionImplBase} is not usable after being closed.
64     */
65    @Override
66    public void close() {
67
68    }
69
70    /**
71     * @return A String containing the unique call ID of this {@link ImsCallSessionImplBase}.
72     */
73    @Override
74    public String getCallId() {
75        return null;
76    }
77
78    /**
79     * @return The {@link ImsCallProfile} that this {@link ImsCallSessionImplBase} is associated
80     * with.
81     */
82    @Override
83    public ImsCallProfile getCallProfile() {
84        return null;
85    }
86
87    /**
88     * @return The local {@link ImsCallProfile} that this {@link ImsCallSessionImplBase} is
89     * associated with.
90     */
91    @Override
92    public ImsCallProfile getLocalCallProfile() {
93        return null;
94    }
95
96    /**
97     * @return The remote {@link ImsCallProfile} that this {@link ImsCallSessionImplBase} is
98     * associated with.
99     */
100    @Override
101    public ImsCallProfile getRemoteCallProfile() {
102        return null;
103    }
104
105    /**
106     * @param name The String extra key.
107     * @return The string extra value associated with the specified property.
108     */
109    @Override
110    public String getProperty(String name) {
111        return null;
112    }
113
114    /**
115     * @return The {@link ImsCallSessionImplBase} state.
116     */
117    @Override
118    public int getState() {
119        return -1;
120    }
121
122    /**
123     * @return true if the {@link ImsCallSessionImplBase} is in a call, false otherwise.
124     */
125    @Override
126    public boolean isInCall() {
127        return false;
128    }
129
130    /**
131     * Mutes or unmutes the mic for the active call.
132     *
133     * @param muted true if the call should be muted, false otherwise.
134     */
135    @Override
136    public void setMute(boolean muted) {
137    }
138
139    /**
140     * Initiates an IMS call with the specified number and call profile.
141     * The session listener set in {@link #setListener(IImsCallSessionListener)} is called back upon
142     * defined session events.
143     * Only valid to call when the session state is in
144     * {@link ImsCallSession.State#IDLE}.
145     *
146     * @param callee dialed string to make the call to
147     * @param profile call profile to make the call with the specified service type,
148     *      call type and media information
149     * @see {@link ImsCallSession.Listener#callSessionStarted},
150     * {@link ImsCallSession.Listener#callSessionStartFailed}
151     */
152    @Override
153    public void start(String callee, ImsCallProfile profile) {
154    }
155
156    /**
157     * Initiates an IMS call with the specified participants and call profile.
158     * The session listener set in {@link #setListener(IImsCallSessionListener)} is called back upon
159     * defined session events.
160     * The method is only valid to call when the session state is in
161     * {@link ImsCallSession.State#IDLE}.
162     *
163     * @param participants participant list to initiate an IMS conference call
164     * @param profile call profile to make the call with the specified service type,
165     *      call type and media information
166     * @see {@link ImsCallSession.Listener#callSessionStarted},
167     * {@link ImsCallSession.Listener#callSessionStartFailed}
168     */
169    @Override
170    public void startConference(String[] participants, ImsCallProfile profile) {
171    }
172
173    /**
174     * Accepts an incoming call or session update.
175     *
176     * @param callType call type specified in {@link ImsCallProfile} to be answered
177     * @param profile stream media profile {@link ImsStreamMediaProfile} to be answered
178     * @see {@link ImsCallSession.Listener#callSessionStarted}
179     */
180    @Override
181    public void accept(int callType, ImsStreamMediaProfile profile) {
182    }
183
184    /**
185     * Deflects an incoming call.
186     *
187     * @param deflectNumber number to deflect the call
188     */
189    @Override
190    public void deflect(String deflectNumber) {
191    }
192
193    /**
194     * Rejects an incoming call or session update.
195     *
196     * @param reason reason code to reject an incoming call, defined in {@link ImsReasonInfo}.
197     * {@link ImsCallSession.Listener#callSessionStartFailed}
198     */
199    @Override
200    public void reject(int reason) {
201    }
202
203    /**
204     * Terminates a call.
205     *
206     * @param reason reason code to terminate a call, defined in {@link ImsReasonInfo}.
207     *
208     * @see {@link ImsCallSession.Listener#callSessionTerminated}
209     */
210    @Override
211    public void terminate(int reason) {
212    }
213
214    /**
215     * Puts a call on hold. When it succeeds, {@link ImsCallSession.Listener#callSessionHeld} is
216     * called.
217     *
218     * @param profile stream media profile {@link ImsStreamMediaProfile} to hold the call
219     * @see {@link ImsCallSession.Listener#callSessionHeld},
220     * {@link ImsCallSession.Listener#callSessionHoldFailed}
221     */
222    @Override
223    public void hold(ImsStreamMediaProfile profile) {
224    }
225
226    /**
227     * Continues a call that's on hold. When it succeeds,
228     * {@link ImsCallSession.Listener#callSessionResumed} is called.
229     *
230     * @param profile stream media profile with {@link ImsStreamMediaProfile} to resume the call
231     * @see {@link ImsCallSession.Listener#callSessionResumed},
232     * {@link ImsCallSession.Listener#callSessionResumeFailed}
233     */
234    @Override
235    public void resume(ImsStreamMediaProfile profile) {
236    }
237
238    /**
239     * Merges the active and held call. When the merge starts,
240     * {@link ImsCallSession.Listener#callSessionMergeStarted} is called.
241     * {@link ImsCallSession.Listener#callSessionMergeComplete} is called if the merge is
242     * successful, and {@link ImsCallSession.Listener#callSessionMergeFailed} is called if the merge
243     * fails.
244     *
245     * @see {@link ImsCallSession.Listener#callSessionMergeStarted},
246     * {@link ImsCallSession.Listener#callSessionMergeComplete},
247     *      {@link ImsCallSession.Listener#callSessionMergeFailed}
248     */
249    @Override
250    public void merge() {
251    }
252
253    /**
254     * Updates the current call's properties (ex. call mode change: video upgrade / downgrade).
255     *
256     * @param callType call type specified in {@link ImsCallProfile} to be updated
257     * @param profile stream media profile {@link ImsStreamMediaProfile} to be updated
258     * @see {@link ImsCallSession.Listener#callSessionUpdated},
259     * {@link ImsCallSession.Listener#callSessionUpdateFailed}
260     */
261    @Override
262    public void update(int callType, ImsStreamMediaProfile profile) {
263    }
264
265    /**
266     * Extends this call to the conference call with the specified recipients.
267     *
268     * @param participants participant list to be invited to the conference call after extending the
269     * call
270     * @see {@link ImsCallSession.Listener#callSessionConferenceExtended},
271     * {@link ImsCallSession.Listener#callSessionConferenceExtendFailed}
272     */
273    @Override
274    public void extendToConference(String[] participants) {
275    }
276
277    /**
278     * Requests the conference server to invite an additional participants to the conference.
279     *
280     * @param participants participant list to be invited to the conference call
281     * @see {@link ImsCallSession.Listener#callSessionInviteParticipantsRequestDelivered},
282     *      {@link ImsCallSession.Listener#callSessionInviteParticipantsRequestFailed}
283     */
284    @Override
285    public void inviteParticipants(String[] participants) {
286    }
287
288    /**
289     * Requests the conference server to remove the specified participants from the conference.
290     *
291     * @param participants participant list to be removed from the conference call
292     * @see {@link ImsCallSession.Listener#callSessionRemoveParticipantsRequestDelivered},
293     *      {@link ImsCallSession.Listener#callSessionRemoveParticipantsRequestFailed}
294     */
295    @Override
296    public void removeParticipants(String[] participants) {
297    }
298
299    /**
300     * Sends a DTMF code. According to <a href="http://tools.ietf.org/html/rfc2833">RFC 2833</a>,
301     * event 0 ~ 9 maps to decimal value 0 ~ 9, '*' to 10, '#' to 11, event 'A' ~ 'D' to 12 ~ 15,
302     * and event flash to 16. Currently, event flash is not supported.
303     *
304     * @param c the DTMF to send. '0' ~ '9', 'A' ~ 'D', '*', '#' are valid inputs.
305     */
306    @Override
307    public void sendDtmf(char c, Message result) {
308    }
309
310    /**
311     * Start a DTMF code. According to <a href="http://tools.ietf.org/html/rfc2833">RFC 2833</a>,
312     * event 0 ~ 9 maps to decimal value 0 ~ 9, '*' to 10, '#' to 11, event 'A' ~ 'D' to 12 ~ 15,
313     * and event flash to 16. Currently, event flash is not supported.
314     *
315     * @param c the DTMF to send. '0' ~ '9', 'A' ~ 'D', '*', '#' are valid inputs.
316     */
317    @Override
318    public void startDtmf(char c) {
319    }
320
321    /**
322     * Stop a DTMF code.
323     */
324    @Override
325    public void stopDtmf() {
326    }
327
328    /**
329     * Sends an USSD message.
330     *
331     * @param ussdMessage USSD message to send
332     */
333    @Override
334    public void sendUssd(String ussdMessage) {
335    }
336
337    @Override
338    public IImsVideoCallProvider getVideoCallProvider() {
339        return null;
340    }
341
342    /**
343     * Determines if the current session is multiparty.
344     * @return {@code True} if the session is multiparty.
345     */
346    @Override
347    public boolean isMultiparty() {
348        return false;
349    }
350
351    /**
352     * Device issues RTT modify request
353     * @param toProfile The profile with requested changes made
354     */
355    @Override
356    public void sendRttModifyRequest(ImsCallProfile toProfile) {
357    }
358
359    /**
360     * Device responds to Remote RTT modify request
361     * @param status true if the the request was accepted or false of the request is defined.
362     */
363    @Override
364    public void sendRttModifyResponse(boolean status) {
365    }
366
367    /**
368     * Device sends RTT message
369     * @param rttMessage RTT message to be sent
370     */
371    @Override
372    public void sendRttMessage(String rttMessage) {
373    }
374
375    /**
376     * There are two different ImsCallSessionListeners that need to reconciled here, we need to
377     * convert the "old" version of the com.android.ims.internal.IImsCallSessionListener to the
378     * "new" version of the Listener android.telephony.ims.ImsCallSessionListener when calling
379     * back to the framework.
380     */
381    private class ImsCallSessionListenerConverter
382            extends com.android.ims.internal.IImsCallSessionListener.Stub {
383
384        private final IImsCallSessionListener mNewListener;
385
386        public ImsCallSessionListenerConverter(IImsCallSessionListener listener) {
387            mNewListener = listener;
388        }
389
390        @Override
391        public void callSessionProgressing(IImsCallSession i,
392                ImsStreamMediaProfile imsStreamMediaProfile) throws RemoteException {
393            mNewListener.callSessionProgressing(imsStreamMediaProfile);
394        }
395
396        @Override
397        public void callSessionStarted(IImsCallSession i, ImsCallProfile imsCallProfile)
398                throws RemoteException {
399            mNewListener.callSessionInitiated(imsCallProfile);
400        }
401
402        @Override
403        public void callSessionStartFailed(IImsCallSession i, ImsReasonInfo imsReasonInfo)
404                throws RemoteException {
405            mNewListener.callSessionInitiatedFailed(imsReasonInfo);
406        }
407
408        @Override
409        public void callSessionTerminated(IImsCallSession i, ImsReasonInfo imsReasonInfo)
410                throws RemoteException {
411            mNewListener.callSessionTerminated(imsReasonInfo);
412        }
413
414        @Override
415        public void callSessionHeld(IImsCallSession i, ImsCallProfile imsCallProfile)
416                throws RemoteException {
417            mNewListener.callSessionHeld(imsCallProfile);
418        }
419
420        @Override
421        public void callSessionHoldFailed(IImsCallSession i, ImsReasonInfo imsReasonInfo)
422                throws RemoteException {
423            mNewListener.callSessionHoldFailed(imsReasonInfo);
424        }
425
426        @Override
427        public void callSessionHoldReceived(IImsCallSession i, ImsCallProfile imsCallProfile)
428                throws RemoteException {
429            mNewListener.callSessionHoldReceived(imsCallProfile);
430        }
431
432        @Override
433        public void callSessionResumed(IImsCallSession i, ImsCallProfile imsCallProfile)
434                throws RemoteException {
435            mNewListener.callSessionResumed(imsCallProfile);
436        }
437
438        @Override
439        public void callSessionResumeFailed(IImsCallSession i, ImsReasonInfo imsReasonInfo)
440                throws RemoteException {
441            mNewListener.callSessionResumeFailed(imsReasonInfo);
442        }
443
444        @Override
445        public void callSessionResumeReceived(IImsCallSession i, ImsCallProfile imsCallProfile)
446                throws RemoteException {
447            mNewListener.callSessionResumeReceived(imsCallProfile);
448        }
449
450        @Override
451        public void callSessionMergeStarted(IImsCallSession i, IImsCallSession newSession,
452                ImsCallProfile profile)
453                throws RemoteException {
454            mNewListener.callSessionMergeStarted(newSession, profile);
455        }
456
457        @Override
458        public void callSessionMergeComplete(IImsCallSession iImsCallSession)
459                throws RemoteException {
460            mNewListener.callSessionMergeComplete(iImsCallSession);
461        }
462
463        @Override
464        public void callSessionMergeFailed(IImsCallSession i, ImsReasonInfo imsReasonInfo)
465                throws RemoteException {
466            mNewListener.callSessionMergeFailed(imsReasonInfo);
467        }
468
469        @Override
470        public void callSessionUpdated(IImsCallSession i, ImsCallProfile imsCallProfile)
471                throws RemoteException {
472            mNewListener.callSessionUpdated(imsCallProfile);
473        }
474
475        @Override
476        public void callSessionUpdateFailed(IImsCallSession i, ImsReasonInfo imsReasonInfo)
477                throws RemoteException {
478            mNewListener.callSessionUpdateFailed(imsReasonInfo);
479        }
480
481        @Override
482        public void callSessionUpdateReceived(IImsCallSession i, ImsCallProfile imsCallProfile)
483                throws RemoteException {
484            mNewListener.callSessionUpdateReceived(imsCallProfile);
485        }
486
487        @Override
488        public void callSessionConferenceExtended(IImsCallSession i, IImsCallSession newSession,
489                ImsCallProfile imsCallProfile) throws RemoteException {
490            mNewListener.callSessionConferenceExtended(newSession, imsCallProfile);
491        }
492
493        @Override
494        public void callSessionConferenceExtendFailed(IImsCallSession i,
495                ImsReasonInfo imsReasonInfo) throws RemoteException {
496            mNewListener.callSessionConferenceExtendFailed(imsReasonInfo);
497        }
498
499        @Override
500        public void callSessionConferenceExtendReceived(IImsCallSession i,
501                IImsCallSession newSession, ImsCallProfile imsCallProfile)
502                throws RemoteException {
503            mNewListener.callSessionConferenceExtendReceived(newSession, imsCallProfile);
504        }
505
506        @Override
507        public void callSessionInviteParticipantsRequestDelivered(IImsCallSession i)
508                throws RemoteException {
509            mNewListener.callSessionInviteParticipantsRequestDelivered();
510        }
511
512        @Override
513        public void callSessionInviteParticipantsRequestFailed(IImsCallSession i,
514                ImsReasonInfo imsReasonInfo) throws RemoteException {
515            mNewListener.callSessionInviteParticipantsRequestFailed(imsReasonInfo);
516        }
517
518        @Override
519        public void callSessionRemoveParticipantsRequestDelivered(IImsCallSession i)
520                throws RemoteException {
521            mNewListener.callSessionRemoveParticipantsRequestDelivered();
522        }
523
524        @Override
525        public void callSessionRemoveParticipantsRequestFailed(IImsCallSession i,
526                ImsReasonInfo imsReasonInfo) throws RemoteException {
527            mNewListener.callSessionRemoveParticipantsRequestFailed(imsReasonInfo);
528        }
529
530        @Override
531        public void callSessionConferenceStateUpdated(IImsCallSession i,
532                ImsConferenceState imsConferenceState) throws RemoteException {
533            mNewListener.callSessionConferenceStateUpdated(imsConferenceState);
534        }
535
536        @Override
537        public void callSessionUssdMessageReceived(IImsCallSession i, int mode, String message)
538                throws RemoteException {
539            mNewListener.callSessionUssdMessageReceived(mode, message);
540        }
541
542        @Override
543        public void callSessionHandover(IImsCallSession i, int srcAccessTech, int targetAccessTech,
544                ImsReasonInfo reasonInfo) throws RemoteException {
545            mNewListener.callSessionHandover(srcAccessTech, targetAccessTech, reasonInfo);
546        }
547
548        @Override
549        public void callSessionHandoverFailed(IImsCallSession i, int srcAccessTech,
550                int targetAccessTech, ImsReasonInfo reasonInfo) throws RemoteException {
551            mNewListener.callSessionHandoverFailed(srcAccessTech, targetAccessTech, reasonInfo);
552        }
553
554        @Override
555        public void callSessionMayHandover(IImsCallSession i, int srcAccessTech, int targetAccessTech)
556                throws RemoteException {
557            mNewListener.callSessionMayHandover(srcAccessTech, targetAccessTech);
558        }
559
560        @Override
561        public void callSessionTtyModeReceived(IImsCallSession iImsCallSession, int mode)
562                throws RemoteException {
563            mNewListener.callSessionTtyModeReceived(mode);
564        }
565
566        @Override
567        public void callSessionMultipartyStateChanged(IImsCallSession i, boolean isMultiparty)
568                throws RemoteException {
569            mNewListener.callSessionMultipartyStateChanged(isMultiparty);
570        }
571
572        @Override
573        public void callSessionSuppServiceReceived(IImsCallSession i,
574                ImsSuppServiceNotification imsSuppServiceNotification) throws RemoteException {
575            mNewListener.callSessionSuppServiceReceived(imsSuppServiceNotification);
576        }
577
578        @Override
579        public void callSessionRttModifyRequestReceived(IImsCallSession i,
580                ImsCallProfile imsCallProfile) throws RemoteException {
581            mNewListener.callSessionRttModifyRequestReceived(imsCallProfile);
582        }
583
584        @Override
585        public void callSessionRttModifyResponseReceived(int status) throws RemoteException {
586            mNewListener.callSessionRttModifyResponseReceived(status);
587        }
588
589        @Override
590        public void callSessionRttMessageReceived(String rttMessage) throws RemoteException {
591            mNewListener.callSessionRttMessageReceived(rttMessage);
592        }
593    }
594}
595