Home | History | Annotate | Download | only in ims
      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 
     17 package android.telephony.ims;
     18 
     19 import android.annotation.SystemApi;
     20 import android.os.RemoteException;
     21 import android.telephony.ims.aidl.IImsCallSessionListener;
     22 import android.telephony.ims.stub.ImsCallSessionImplBase;
     23 
     24 import com.android.ims.internal.IImsCallSession;
     25 
     26 /**
     27  * Listener interface for notifying the Framework's {@link ImsCallSession} for updates to an ongoing
     28  * IMS call.
     29  *
     30  * @hide
     31  */
     32 // DO NOT remove or change the existing APIs, only add new ones to this implementation or you
     33 // will break other implementations of ImsCallSessionListener maintained by other ImsServices.
     34 // TODO: APIs in here do not conform to API guidelines yet. This can be changed if
     35 // ImsCallSessionListenerConverter is also changed.
     36 @SystemApi
     37 public class ImsCallSessionListener {
     38 
     39     private final IImsCallSessionListener mListener;
     40 
     41     /** @hide */
     42     public ImsCallSessionListener(IImsCallSessionListener l) {
     43         mListener = l;
     44     }
     45 
     46     /**
     47      * A request has been sent out to initiate a new IMS call session and a 1xx response has been
     48      * received from the network.
     49      */
     50     public void callSessionProgressing(ImsStreamMediaProfile profile) {
     51         try {
     52             mListener.callSessionProgressing(profile);
     53         } catch (RemoteException e) {
     54             throw new RuntimeException(e);
     55         }
     56     }
     57 
     58     /**
     59      * The IMS call session has been initiated.
     60      *
     61      * @param profile the associated {@link ImsCallProfile}.
     62      */
     63     public void callSessionInitiated(ImsCallProfile profile) {
     64         try {
     65             mListener.callSessionInitiated(profile);
     66         } catch (RemoteException e) {
     67             throw new RuntimeException(e);
     68         }
     69     }
     70 
     71     /**
     72      * The IMS call session establishment has failed.
     73      *
     74      * @param reasonInfo {@link ImsReasonInfo} detailing the reason of the IMS call session
     75      * establishment failure.
     76      */
     77     public void callSessionInitiatedFailed(ImsReasonInfo reasonInfo) {
     78         try {
     79             mListener.callSessionInitiatedFailed(reasonInfo);
     80         } catch (RemoteException e) {
     81             throw new RuntimeException(e);
     82         }
     83     }
     84 
     85     /**
     86      * The IMS call session has been terminated.
     87      *
     88      * @param reasonInfo {@link ImsReasonInfo} detailing the reason of the session termination.
     89      */
     90     public void callSessionTerminated(ImsReasonInfo reasonInfo) {
     91         try {
     92             mListener.callSessionTerminated(reasonInfo);
     93         } catch (RemoteException e) {
     94             throw new RuntimeException(e);
     95         }
     96     }
     97 
     98     /**
     99      * The IMS call session has started the process of holding the call. If it fails,
    100      * {@link #callSessionHoldFailed(ImsReasonInfo)} should be called.
    101      *
    102      * If the IMS call session is resumed, call {@link #callSessionResumed(ImsCallProfile)}.
    103      *
    104      * @param profile The associated {@link ImsCallProfile} of the call session that has been put
    105      * on hold.
    106      */
    107     public void callSessionHeld(ImsCallProfile profile) {
    108         try {
    109             mListener.callSessionHeld(profile);
    110         } catch (RemoteException e) {
    111             throw new RuntimeException(e);
    112         }
    113     }
    114 
    115     /**
    116      * The IMS call session has failed to be held.
    117      *
    118      * @param reasonInfo {@link ImsReasonInfo} detailing the reason of the session hold failure.
    119      */
    120     public void callSessionHoldFailed(ImsReasonInfo reasonInfo) {
    121         try {
    122             mListener.callSessionHoldFailed(reasonInfo);
    123         } catch (RemoteException e) {
    124             throw new RuntimeException(e);
    125         }
    126     }
    127 
    128     /**
    129      * This IMS Call session has been put on hold by the remote party.
    130      *
    131      * @param profile The {@link ImsCallProfile} associated with this IMS call session.
    132      */
    133     public void callSessionHoldReceived(ImsCallProfile profile) {
    134         try {
    135             mListener.callSessionHoldReceived(profile);
    136         } catch (RemoteException e) {
    137             throw new RuntimeException(e);
    138         }
    139     }
    140 
    141     /**
    142      * The IMS call session has started the process of resuming the call. If the process of resuming
    143      * the call fails, call {@link #callSessionResumeFailed(ImsReasonInfo)}.
    144      *
    145      * @param profile The {@link ImsCallProfile} associated with this IMS call session.
    146      */
    147     public void callSessionResumed(ImsCallProfile profile) {
    148         try {
    149             mListener.callSessionResumed(profile);
    150         } catch (RemoteException e) {
    151             throw new RuntimeException(e);
    152         }
    153     }
    154 
    155     /**
    156      * The IMS call session resume has failed.
    157      *
    158      * @param reasonInfo {@link ImsReasonInfo} containing the detailed reason of the session resume
    159      * failure.
    160      */
    161     public void callSessionResumeFailed(ImsReasonInfo reasonInfo) {
    162         try {
    163             mListener.callSessionResumeFailed(reasonInfo);
    164         } catch (RemoteException e) {
    165             throw new RuntimeException(e);
    166         }
    167     }
    168 
    169     /**
    170      * The remote party has resumed this IMS call session.
    171      *
    172      * @param profile {@link ImsCallProfile} associated with the IMS call session.
    173      */
    174     public void callSessionResumeReceived(ImsCallProfile profile) {
    175         try {
    176             mListener.callSessionResumeReceived(profile);
    177         } catch (RemoteException e) {
    178             throw new RuntimeException(e);
    179         }
    180     }
    181 
    182     /**
    183      * The IMS call session merge has been started.  At this point, the {@code newSession}
    184      * represents the IMS call session which represents the new merged conference and has been
    185      * initiated to the IMS conference server.
    186      *
    187      * @param newSession the {@link ImsCallSessionImplBase} that represents the merged active & held
    188      * sessions.
    189      * @param profile The {@link ImsCallProfile} associated with this IMS call session.
    190      */
    191     public void callSessionMergeStarted(ImsCallSessionImplBase newSession, ImsCallProfile profile)
    192     {
    193         try {
    194             mListener.callSessionMergeStarted(newSession != null ?
    195                             newSession.getServiceImpl() : null, profile);
    196         } catch (RemoteException e) {
    197             throw new RuntimeException(e);
    198         }
    199     }
    200 
    201     /**
    202      * Compatibility method for older implementations.
    203      * See {@link #callSessionMergeStarted(ImsCallSessionImplBase, ImsCallProfile)}.
    204      *
    205      * @hide
    206      */
    207     public void callSessionMergeStarted(IImsCallSession newSession, ImsCallProfile profile)
    208     {
    209         try {
    210             mListener.callSessionMergeStarted(newSession, profile);
    211         } catch (RemoteException e) {
    212             throw new RuntimeException(e);
    213         }
    214     }
    215 
    216     /**
    217      * The session merge is successful and the merged {@link ImsCallSession} is active.
    218      *
    219      * @param newSession the new {@link ImsCallSessionImplBase}
    220      *                  that represents the conference IMS call
    221      * session.
    222      */
    223     public void callSessionMergeComplete(ImsCallSessionImplBase newSession) {
    224         try {
    225             mListener.callSessionMergeComplete(newSession != null ?
    226                     newSession.getServiceImpl() : null);
    227         } catch (RemoteException e) {
    228             throw new RuntimeException(e);
    229         }
    230     }
    231 
    232     /**
    233      * Compatibility method for older implementations of ImsService.
    234      *
    235      * See {@link #callSessionMergeComplete(ImsCallSessionImplBase)}}.
    236      *
    237      * @hide
    238      */
    239     public void callSessionMergeComplete(IImsCallSession newSession) {
    240         try {
    241             mListener.callSessionMergeComplete(newSession);
    242         } catch (RemoteException e) {
    243             throw new RuntimeException(e);
    244         }
    245     }
    246 
    247     /**
    248      * The IMS call session merge has failed.
    249      *
    250      * @param reasonInfo {@link ImsReasonInfo} contining the reason for the call merge failure.
    251      */
    252     public void callSessionMergeFailed(ImsReasonInfo reasonInfo) {
    253         try {
    254             mListener.callSessionMergeFailed(reasonInfo);
    255         } catch (RemoteException e) {
    256             throw new RuntimeException(e);
    257         }
    258     }
    259 
    260     /**
    261      * The IMS call session profile has been updated. Does not include holding or resuming a call.
    262      *
    263      * @param profile The {@link ImsCallProfile} associated with the updated IMS call session.
    264      */
    265     public void callSessionUpdated(ImsCallProfile profile) {
    266         try {
    267             mListener.callSessionUpdated(profile);
    268         } catch (RemoteException e) {
    269             throw new RuntimeException(e);
    270         }
    271     }
    272 
    273     /**
    274      * The IMS call session profile update has failed.
    275      *
    276      * @param reasonInfo {@link ImsReasonInfo} containing a reason for the session update failure.
    277      */
    278     public void callSessionUpdateFailed(ImsReasonInfo reasonInfo) {
    279         try {
    280             mListener.callSessionUpdateFailed(reasonInfo);
    281         } catch (RemoteException e) {
    282             throw new RuntimeException(e);
    283         }
    284     }
    285 
    286     /**
    287      * The IMS call session profile has received an update from the remote user.
    288      *
    289      * @param profile The new {@link ImsCallProfile} associated with the update.
    290      */
    291     public void callSessionUpdateReceived(ImsCallProfile profile) {
    292         try {
    293             mListener.callSessionUpdateReceived(profile);
    294         } catch (RemoteException e) {
    295             throw new RuntimeException(e);
    296         }
    297     }
    298 
    299     /**
    300      * Called when the session has been extended to a conference session.
    301      *
    302      * If the conference extension fails, call
    303      * {@link #callSessionConferenceExtendFailed(ImsReasonInfo)}.
    304      *
    305      * @param newSession the session object that is extended to the conference from the active
    306      * IMS Call session.
    307      * @param profile The {@link ImsCallProfile} associated with the IMS call session.
    308      */
    309     public void callSessionConferenceExtended(ImsCallSessionImplBase newSession,
    310             ImsCallProfile profile) {
    311         try {
    312             mListener.callSessionConferenceExtended(
    313                     newSession != null ? newSession.getServiceImpl() : null, profile);
    314         } catch (RemoteException e) {
    315             throw new RuntimeException(e);
    316         }
    317     }
    318 
    319     /**
    320      * Compatibility method to interface with older versions of ImsService.
    321      * See {@link #callSessionConferenceExtended(ImsCallSessionImplBase, ImsCallProfile)}.
    322      *
    323      * @hide
    324      */
    325     public void callSessionConferenceExtended(IImsCallSession newSession, ImsCallProfile profile) {
    326         try {
    327             mListener.callSessionConferenceExtended(newSession, profile);
    328         } catch (RemoteException e) {
    329             throw new RuntimeException(e);
    330         }
    331     }
    332 
    333     /**
    334      * The previous conference extension has failed.
    335      *
    336      * @param reasonInfo {@link ImsReasonInfo} containing the detailed reason of the conference
    337      * extension failure.
    338      */
    339     public void callSessionConferenceExtendFailed(ImsReasonInfo reasonInfo) {
    340         try {
    341             mListener.callSessionConferenceExtendFailed(reasonInfo);
    342         } catch (RemoteException e) {
    343             throw new RuntimeException(e);
    344         }
    345     }
    346 
    347     /**
    348      * A conference extension has been received received from the remote party.
    349      *
    350      * @param newSession An {@link ImsCallSessionImplBase}
    351      *                   representing the extended IMS call session.
    352      * @param profile The {@link ImsCallProfile} associated with the new IMS call session.
    353      */
    354     public void callSessionConferenceExtendReceived(ImsCallSessionImplBase newSession,
    355             ImsCallProfile profile) {
    356         try {
    357             mListener.callSessionConferenceExtendReceived(newSession != null
    358                     ? newSession.getServiceImpl() : null, profile);
    359         } catch (RemoteException e) {
    360             throw new RuntimeException(e);
    361         }
    362     }
    363 
    364     /**
    365      * Compatibility method to interface with older versions of ImsService.
    366      * See {@link #callSessionConferenceExtendReceived(ImsCallSessionImplBase, ImsCallProfile)}.
    367      *
    368      * @hide
    369      */
    370     public void callSessionConferenceExtendReceived(IImsCallSession newSession,
    371             ImsCallProfile profile) {
    372         try {
    373             mListener.callSessionConferenceExtendReceived(newSession, profile);
    374         } catch (RemoteException e) {
    375             throw new RuntimeException(e);
    376         }
    377     }
    378 
    379     /**
    380      * The request to invite participants to the conference has been delivered to the conference
    381      * server.
    382      */
    383     public void callSessionInviteParticipantsRequestDelivered() {
    384         try {
    385             mListener.callSessionInviteParticipantsRequestDelivered();
    386         } catch (RemoteException e) {
    387             throw new RuntimeException(e);
    388         }
    389     }
    390 
    391     /**
    392      * The previous request to invite participants to the conference (see
    393      * {@link #callSessionInviteParticipantsRequestDelivered()}) has failed.
    394      *
    395      * @param reasonInfo {@link ImsReasonInfo} detailing the reason forthe conference invitation
    396      * failure.
    397      */
    398     public void callSessionInviteParticipantsRequestFailed(ImsReasonInfo reasonInfo)
    399     {
    400         try {
    401             mListener.callSessionInviteParticipantsRequestFailed(reasonInfo);
    402         } catch (RemoteException e) {
    403             throw new RuntimeException(e);
    404         }
    405     }
    406 
    407     /**
    408      * The request to remove participants from the conference has been delivered to the conference
    409      * server.
    410      */
    411     public void callSessionRemoveParticipantsRequestDelivered() {
    412         try {
    413             mListener.callSessionRemoveParticipantsRequestDelivered();
    414         } catch (RemoteException e) {
    415             throw new RuntimeException(e);
    416         }
    417     }
    418 
    419     /**
    420      * The previous request to remove participants from the conference (see
    421      * {@link #callSessionRemoveParticipantsRequestDelivered()}) has failed.
    422      *
    423      * @param reasonInfo {@link ImsReasonInfo} detailing the reason for the conference removal
    424      * failure.
    425      */
    426     public void callSessionRemoveParticipantsRequestFailed(ImsReasonInfo reasonInfo)
    427     {
    428         try {
    429             mListener.callSessionInviteParticipantsRequestFailed(reasonInfo);
    430         } catch (RemoteException e) {
    431             throw new RuntimeException(e);
    432         }
    433     }
    434 
    435     /**
    436      * The IMS call session's conference state has changed.
    437      *
    438      * @param state The new {@link ImsConferenceState} associated with the conference.
    439      */
    440     public void callSessionConferenceStateUpdated(ImsConferenceState state) {
    441         try {
    442             mListener.callSessionConferenceStateUpdated(state);
    443         } catch (RemoteException e) {
    444             throw new RuntimeException(e);
    445         }
    446     }
    447 
    448     /**
    449      * The IMS call session has received a Ussd message.
    450      *
    451      * @param mode The mode of the USSD message, either
    452      * {@link ImsCallSessionImplBase#USSD_MODE_NOTIFY} or
    453      * {@link ImsCallSessionImplBase#USSD_MODE_REQUEST}.
    454      * @param ussdMessage The USSD message.
    455      */
    456     public void callSessionUssdMessageReceived(int mode, String ussdMessage)
    457     {
    458         try {
    459             mListener.callSessionUssdMessageReceived(mode, ussdMessage);
    460         } catch (RemoteException e) {
    461             throw new RuntimeException(e);
    462         }
    463     }
    464 
    465     /**
    466      * An {@link ImsCallSession} may potentially handover from one radio
    467      * technology to another.
    468      *
    469      * @param srcAccessTech The source radio access technology; one of the access technology
    470      * constants defined in {@link android.telephony.ServiceState}. For example
    471      * {@link android.telephony.ServiceState#RIL_RADIO_TECHNOLOGY_LTE}.
    472      * @param targetAccessTech The target radio access technology; one of the access technology
    473      * constants defined in {@link android.telephony.ServiceState}. For example
    474      * {@link android.telephony.ServiceState#RIL_RADIO_TECHNOLOGY_LTE}.
    475      */
    476     public void callSessionMayHandover(int srcAccessTech, int targetAccessTech)
    477     {
    478         try {
    479             mListener.callSessionMayHandover(srcAccessTech, targetAccessTech);
    480         } catch (RemoteException e) {
    481             throw new RuntimeException(e);
    482         }
    483     }
    484 
    485     /**
    486      * The IMS call session's access technology has changed.
    487      *
    488      * @param srcAccessTech original access technology, defined in
    489      * {@link android.telephony.ServiceState}.
    490      * @param targetAccessTech new access technology, defined in
    491      * {@link android.telephony.ServiceState}.
    492      * @param reasonInfo The {@link ImsReasonInfo} associated with this handover.
    493      */
    494     public void callSessionHandover(int srcAccessTech, int targetAccessTech,
    495             ImsReasonInfo reasonInfo) {
    496         try {
    497             mListener.callSessionHandover(srcAccessTech, targetAccessTech, reasonInfo);
    498         } catch (RemoteException e) {
    499             throw new RuntimeException(e);
    500         }
    501     }
    502 
    503     /**
    504      * The IMS call session's access technology change has failed..
    505      *
    506      * @param srcAccessTech original access technology
    507      * @param targetAccessTech new access technology
    508      * @param reasonInfo An {@link ImsReasonInfo} detailing the reason for the failure.
    509      */
    510     public void callSessionHandoverFailed(int srcAccessTech, int targetAccessTech,
    511             ImsReasonInfo reasonInfo) {
    512         try {
    513             mListener.callSessionHandoverFailed(srcAccessTech, targetAccessTech, reasonInfo);
    514         } catch (RemoteException e) {
    515             throw new RuntimeException(e);
    516         }
    517     }
    518 
    519     /**
    520      * The TTY mode has been changed by the remote party.
    521      *
    522      * @param mode one of the following: -
    523      *             {@link com.android.internal.telephony.Phone#TTY_MODE_OFF} -
    524      *             {@link com.android.internal.telephony.Phone#TTY_MODE_FULL} -
    525      *             {@link com.android.internal.telephony.Phone#TTY_MODE_HCO} -
    526      *             {@link com.android.internal.telephony.Phone#TTY_MODE_VCO}
    527      */
    528     public void callSessionTtyModeReceived(int mode) {
    529         try {
    530             mListener.callSessionTtyModeReceived(mode);
    531         } catch (RemoteException e) {
    532             throw new RuntimeException(e);
    533         }
    534     }
    535 
    536     /**
    537      * The multiparty state has been changed for this {@code ImsCallSession}.
    538      *
    539      * @param isMultiParty {@code true} if the session became multiparty, {@code false} otherwise.
    540      */
    541     public void callSessionMultipartyStateChanged(boolean isMultiParty) {
    542         try {
    543             mListener.callSessionMultipartyStateChanged(isMultiParty);
    544         } catch (RemoteException e) {
    545             throw new RuntimeException(e);
    546         }
    547     }
    548 
    549     /**
    550      * Supplementary service information has been received for the current IMS call session.
    551      *
    552      * @param suppSrvNotification The {@link ImsSuppServiceNotification} containing the change.
    553      */
    554     public void callSessionSuppServiceReceived(ImsSuppServiceNotification suppSrvNotification)
    555     {
    556         try {
    557             mListener.callSessionSuppServiceReceived(suppSrvNotification);
    558         } catch (RemoteException e) {
    559             throw new RuntimeException(e);
    560         }
    561     }
    562 
    563     /**
    564      * An RTT modify request has been received from the remote party.
    565      *
    566      * @param callProfile An {@link ImsCallProfile} with the updated attributes
    567      */
    568     public void callSessionRttModifyRequestReceived(ImsCallProfile callProfile)
    569     {
    570         try {
    571             mListener.callSessionRttModifyRequestReceived(callProfile);
    572         } catch (RemoteException e) {
    573             throw new RuntimeException(e);
    574         }
    575     }
    576 
    577     /**
    578      * An RTT modify response has been received.
    579      *
    580      * @param status the received response for RTT modify request.
    581      */
    582     public void callSessionRttModifyResponseReceived(int status) {
    583         try {
    584             mListener.callSessionRttModifyResponseReceived(status);
    585         } catch (RemoteException e) {
    586             throw new RuntimeException(e);
    587         }
    588     }
    589 
    590     /**
    591      * An RTT message has been received from the remote party.
    592      *
    593      * @param rttMessage The RTT message that has been received.
    594      */
    595     public void callSessionRttMessageReceived(String rttMessage) {
    596         try {
    597             mListener.callSessionRttMessageReceived(rttMessage);
    598         } catch (RemoteException e) {
    599             throw new RuntimeException(e);
    600         }
    601     }
    602 }
    603 
    604