Home | History | Annotate | Download | only in feature
      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.compat.feature;
     18 
     19 import android.app.PendingIntent;
     20 import android.os.Message;
     21 import android.os.RemoteException;
     22 
     23 import android.telephony.ims.ImsCallProfile;
     24 import com.android.ims.internal.IImsCallSession;
     25 import com.android.ims.internal.IImsCallSessionListener;
     26 import com.android.ims.internal.IImsConfig;
     27 import com.android.ims.internal.IImsEcbm;
     28 import com.android.ims.internal.IImsMMTelFeature;
     29 import com.android.ims.internal.IImsMultiEndpoint;
     30 import com.android.ims.internal.IImsRegistrationListener;
     31 import com.android.ims.internal.IImsUt;
     32 import android.telephony.ims.ImsCallSession;
     33 import android.telephony.ims.compat.stub.ImsCallSessionImplBase;
     34 import android.telephony.ims.stub.ImsEcbmImplBase;
     35 import android.telephony.ims.stub.ImsMultiEndpointImplBase;
     36 import android.telephony.ims.stub.ImsUtImplBase;
     37 
     38 /**
     39  * Base implementation for MMTel.
     40  * Any class wishing to use MMTelFeature should extend this class and implement all methods that the
     41  * service supports.
     42  *
     43  * @hide
     44  */
     45 
     46 public class MMTelFeature extends ImsFeature {
     47 
     48     // Lock for feature synchronization
     49     private final Object mLock = new Object();
     50 
     51     private final IImsMMTelFeature mImsMMTelBinder = new IImsMMTelFeature.Stub() {
     52 
     53         @Override
     54         public int startSession(PendingIntent incomingCallIntent,
     55                 IImsRegistrationListener listener) throws RemoteException {
     56             synchronized (mLock) {
     57                 return MMTelFeature.this.startSession(incomingCallIntent, listener);
     58             }
     59         }
     60 
     61         @Override
     62         public void endSession(int sessionId) throws RemoteException {
     63             synchronized (mLock) {
     64                 MMTelFeature.this.endSession(sessionId);
     65             }
     66         }
     67 
     68         @Override
     69         public boolean isConnected(int callSessionType, int callType)
     70                 throws RemoteException {
     71             synchronized (mLock) {
     72                 return MMTelFeature.this.isConnected(callSessionType, callType);
     73             }
     74         }
     75 
     76         @Override
     77         public boolean isOpened() throws RemoteException {
     78             synchronized (mLock) {
     79                 return MMTelFeature.this.isOpened();
     80             }
     81         }
     82 
     83         @Override
     84         public int getFeatureStatus() throws RemoteException {
     85             synchronized (mLock) {
     86                 return MMTelFeature.this.getFeatureState();
     87             }
     88         }
     89 
     90         @Override
     91         public void addRegistrationListener(IImsRegistrationListener listener)
     92                 throws RemoteException {
     93             synchronized (mLock) {
     94                 MMTelFeature.this.addRegistrationListener(listener);
     95             }
     96         }
     97 
     98         @Override
     99         public void removeRegistrationListener(IImsRegistrationListener listener)
    100                 throws RemoteException {
    101             synchronized (mLock) {
    102                 MMTelFeature.this.removeRegistrationListener(listener);
    103             }
    104         }
    105 
    106         @Override
    107         public ImsCallProfile createCallProfile(int sessionId, int callSessionType, int callType)
    108                 throws RemoteException {
    109             synchronized (mLock) {
    110                 return MMTelFeature.this.createCallProfile(sessionId, callSessionType,  callType);
    111             }
    112         }
    113 
    114         @Override
    115         public IImsCallSession createCallSession(int sessionId, ImsCallProfile profile)
    116                 throws RemoteException {
    117             synchronized (mLock) {
    118                 return MMTelFeature.this.createCallSession(sessionId, profile, null);
    119             }
    120         }
    121 
    122         @Override
    123         public IImsCallSession getPendingCallSession(int sessionId, String callId)
    124                 throws RemoteException {
    125             synchronized (mLock) {
    126                 return MMTelFeature.this.getPendingCallSession(sessionId, callId);
    127             }
    128         }
    129 
    130         @Override
    131         public IImsUt getUtInterface() throws RemoteException {
    132             synchronized (mLock) {
    133                 ImsUtImplBase implBase = MMTelFeature.this.getUtInterface();
    134                 return implBase != null ? implBase.getInterface() : null;
    135             }
    136         }
    137 
    138         @Override
    139         public IImsConfig getConfigInterface() throws RemoteException {
    140             synchronized (mLock) {
    141                 return MMTelFeature.this.getConfigInterface();
    142             }
    143         }
    144 
    145         @Override
    146         public void turnOnIms() throws RemoteException {
    147             synchronized (mLock) {
    148                 MMTelFeature.this.turnOnIms();
    149             }
    150         }
    151 
    152         @Override
    153         public void turnOffIms() throws RemoteException {
    154             synchronized (mLock) {
    155                 MMTelFeature.this.turnOffIms();
    156             }
    157         }
    158 
    159         @Override
    160         public IImsEcbm getEcbmInterface() throws RemoteException {
    161             synchronized (mLock) {
    162                 ImsEcbmImplBase implBase = MMTelFeature.this.getEcbmInterface();
    163                 return implBase != null ? implBase.getImsEcbm() : null;
    164             }
    165         }
    166 
    167         @Override
    168         public void setUiTTYMode(int uiTtyMode, Message onComplete) throws RemoteException {
    169             synchronized (mLock) {
    170                 MMTelFeature.this.setUiTTYMode(uiTtyMode, onComplete);
    171             }
    172         }
    173 
    174         @Override
    175         public IImsMultiEndpoint getMultiEndpointInterface() throws RemoteException {
    176             synchronized (mLock) {
    177                 ImsMultiEndpointImplBase implBase = MMTelFeature.this.getMultiEndpointInterface();
    178                 return implBase != null ? implBase.getIImsMultiEndpoint() : null;
    179             }
    180         }
    181     };
    182 
    183     /**
    184      * @hide
    185      */
    186     @Override
    187     public final IImsMMTelFeature getBinder() {
    188         return mImsMMTelBinder;
    189     }
    190 
    191     /**
    192      * Notifies the MMTel feature that you would like to start a session. This should always be
    193      * done before making/receiving IMS calls. The IMS service will register the device to the
    194      * operator's network with the credentials (from ISIM) periodically in order to receive calls
    195      * from the operator's network. When the IMS service receives a new call, it will send out an
    196      * intent with the provided action string. The intent contains a call ID extra
    197      * {@link IImsCallSession#getCallId} and it can be used to take a call.
    198      *
    199      * @param incomingCallIntent When an incoming call is received, the IMS service will call
    200      * {@link PendingIntent#send} to send back the intent to the caller with
    201      * ImsManager#INCOMING_CALL_RESULT_CODE as the result code and the intent to fill in the call
    202      * ID; It cannot be null.
    203      * @param listener To listen to IMS registration events; It cannot be null
    204      * @return an integer (greater than 0) representing the session id associated with the session
    205      * that has been started.
    206      */
    207     public int startSession(PendingIntent incomingCallIntent, IImsRegistrationListener listener) {
    208         return 0;
    209     }
    210 
    211     /**
    212      * End a previously started session using the associated sessionId.
    213      * @param sessionId an integer (greater than 0) representing the ongoing session. See
    214      * {@link #startSession}.
    215      */
    216     public void endSession(int sessionId) {
    217     }
    218 
    219     /**
    220      * Checks if the IMS service has successfully registered to the IMS network with the specified
    221      * service & call type.
    222      *
    223      * @param callSessionType a service type that is specified in {@link ImsCallProfile}
    224      *        {@link ImsCallProfile#SERVICE_TYPE_NORMAL}
    225      *        {@link ImsCallProfile#SERVICE_TYPE_EMERGENCY}
    226      * @param callType a call type that is specified in {@link ImsCallProfile}
    227      *        {@link ImsCallProfile#CALL_TYPE_VOICE_N_VIDEO}
    228      *        {@link ImsCallProfile#CALL_TYPE_VOICE}
    229      *        {@link ImsCallProfile#CALL_TYPE_VT}
    230      *        {@link ImsCallProfile#CALL_TYPE_VS}
    231      * @return true if the specified service id is connected to the IMS network; false otherwise
    232      */
    233     public boolean isConnected(int callSessionType, int callType) {
    234         return false;
    235     }
    236 
    237     /**
    238      * Checks if the specified IMS service is opened.
    239      *
    240      * @return true if the specified service id is opened; false otherwise
    241      */
    242     public boolean isOpened() {
    243         return false;
    244     }
    245 
    246     /**
    247      * Add a new registration listener for the client associated with the session Id.
    248      * @param listener An implementation of IImsRegistrationListener.
    249      */
    250     public void addRegistrationListener(IImsRegistrationListener listener) {
    251     }
    252 
    253     /**
    254      * Remove a previously registered listener using {@link #addRegistrationListener} for the client
    255      * associated with the session Id.
    256      * @param listener A previously registered IImsRegistrationListener
    257      */
    258     public void removeRegistrationListener(IImsRegistrationListener listener) {
    259     }
    260 
    261     /**
    262      * Creates a {@link ImsCallProfile} from the service capabilities & IMS registration state.
    263      *
    264      * @param sessionId a session id which is obtained from {@link #startSession}
    265      * @param callSessionType a service type that is specified in {@link ImsCallProfile}
    266      *        {@link ImsCallProfile#SERVICE_TYPE_NONE}
    267      *        {@link ImsCallProfile#SERVICE_TYPE_NORMAL}
    268      *        {@link ImsCallProfile#SERVICE_TYPE_EMERGENCY}
    269      * @param callType a call type that is specified in {@link ImsCallProfile}
    270      *        {@link ImsCallProfile#CALL_TYPE_VOICE}
    271      *        {@link ImsCallProfile#CALL_TYPE_VT}
    272      *        {@link ImsCallProfile#CALL_TYPE_VT_TX}
    273      *        {@link ImsCallProfile#CALL_TYPE_VT_RX}
    274      *        {@link ImsCallProfile#CALL_TYPE_VT_NODIR}
    275      *        {@link ImsCallProfile#CALL_TYPE_VS}
    276      *        {@link ImsCallProfile#CALL_TYPE_VS_TX}
    277      *        {@link ImsCallProfile#CALL_TYPE_VS_RX}
    278      * @return a {@link ImsCallProfile} object
    279      */
    280     public ImsCallProfile createCallProfile(int sessionId, int callSessionType, int callType) {
    281         return null;
    282     }
    283 
    284     /**
    285      * Creates an {@link ImsCallSession} with the specified call profile.
    286      * Use other methods, if applicable, instead of interacting with
    287      * {@link ImsCallSession} directly.
    288      *
    289      * @param sessionId a session id which is obtained from {@link #startSession}
    290      * @param profile a call profile to make the call
    291      */
    292     public IImsCallSession createCallSession(int sessionId, ImsCallProfile profile,
    293             IImsCallSessionListener listener) {
    294         return null;
    295     }
    296 
    297     /**
    298      * Retrieves the call session associated with a pending call.
    299      *
    300      * @param sessionId a session id which is obtained from {@link #startSession}
    301      * @param callId a call id to make the call
    302      */
    303     public IImsCallSession getPendingCallSession(int sessionId, String callId) {
    304         return null;
    305     }
    306 
    307     /**
    308      * @return The Ut interface for the supplementary service configuration.
    309      */
    310     public ImsUtImplBase getUtInterface() {
    311         return null;
    312     }
    313 
    314     /**
    315      * @return The config interface for IMS Configuration
    316      */
    317     public IImsConfig getConfigInterface() {
    318         return null;
    319     }
    320 
    321     /**
    322      * Signal the MMTelFeature to turn on IMS when it has been turned off using {@link #turnOffIms}
    323      */
    324     public void turnOnIms() {
    325     }
    326 
    327     /**
    328      * Signal the MMTelFeature to turn off IMS when it has been turned on using {@link #turnOnIms}
    329      */
    330     public void turnOffIms() {
    331     }
    332 
    333     /**
    334      * @return The Emergency call-back mode interface for emergency VoLTE calls that support it.
    335      */
    336     public ImsEcbmImplBase getEcbmInterface() {
    337         return null;
    338     }
    339 
    340     /**
    341      * Sets the current UI TTY mode for the MMTelFeature.
    342      * @param uiTtyMode An integer containing the new UI TTY Mode.
    343      * @param onComplete A {@link Message} to be used when the mode has been set.
    344      */
    345     public void setUiTTYMode(int uiTtyMode, Message onComplete) {
    346     }
    347 
    348     /**
    349      * @return MultiEndpoint interface for DEP notifications
    350      */
    351     public ImsMultiEndpointImplBase getMultiEndpointInterface() {
    352         return null;
    353     }
    354 
    355     @Override
    356     public void onFeatureReady() {
    357 
    358     }
    359 
    360     /**
    361      * {@inheritDoc}
    362      */
    363     public void onFeatureRemoved() {
    364 
    365     }
    366 }
    367