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 com.android.internal.telephony.ims;
18 
19 import android.app.PendingIntent;
20 import android.os.IBinder;
21 import android.os.Message;
22 import android.os.RemoteException;
23 import android.telephony.ims.ImsCallProfile;
24 
25 import com.android.ims.internal.IImsCallSession;
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 
33 /**
34  * Defines "generic" MmTel commands and provides a concrete implementation for compatibility
35  * purposes.
36  */
37 
38 public class MmTelInterfaceAdapter {
39 
40     protected IBinder mBinder;
41     protected int mSlotId;
42 
MmTelInterfaceAdapter(int slotId, IBinder binder)43     public MmTelInterfaceAdapter(int slotId, IBinder binder) {
44         mBinder = binder;
45         mSlotId = slotId;
46     }
47 
startSession(PendingIntent incomingCallIntent, IImsRegistrationListener listener)48     public int startSession(PendingIntent incomingCallIntent, IImsRegistrationListener listener)
49             throws RemoteException {
50         return getInterface().startSession(incomingCallIntent, listener);
51     }
52 
endSession(int sessionId)53     public void endSession(int sessionId) throws RemoteException {
54         getInterface().endSession(sessionId);
55     }
56 
isConnected(int callSessionType, int callType)57     public boolean isConnected(int callSessionType, int callType) throws RemoteException {
58         return getInterface().isConnected(callSessionType, callType);
59     }
60 
isOpened()61     public boolean isOpened() throws RemoteException {
62         return getInterface().isOpened();
63     }
64 
getFeatureState()65     public int getFeatureState() throws RemoteException {
66         return getInterface().getFeatureStatus();
67     }
68 
addRegistrationListener(IImsRegistrationListener listener)69     public void addRegistrationListener(IImsRegistrationListener listener) throws RemoteException {
70         getInterface().addRegistrationListener(listener);
71     }
72 
removeRegistrationListener(IImsRegistrationListener listener)73     public void removeRegistrationListener(IImsRegistrationListener listener)
74             throws RemoteException {
75         getInterface().removeRegistrationListener(listener);
76     }
77 
createCallProfile(int sessionId, int callSessionType, int callType)78     public ImsCallProfile createCallProfile(int sessionId, int callSessionType, int callType)
79             throws RemoteException {
80         return getInterface().createCallProfile(sessionId, callSessionType, callType);
81     }
82 
createCallSession(int sessionId, ImsCallProfile profile)83     public IImsCallSession createCallSession(int sessionId, ImsCallProfile profile)
84             throws RemoteException {
85         return getInterface().createCallSession(sessionId, profile);
86     }
87 
getPendingCallSession(int sessionId, String callId)88     public IImsCallSession getPendingCallSession(int sessionId, String callId)
89             throws RemoteException {
90         return getInterface().getPendingCallSession(sessionId, callId);
91     }
92 
getUtInterface()93     public IImsUt getUtInterface() throws RemoteException {
94         return getInterface().getUtInterface();
95     }
96 
getConfigInterface()97     public IImsConfig getConfigInterface() throws RemoteException {
98         return getInterface().getConfigInterface();
99     }
100 
turnOnIms()101     public void turnOnIms() throws RemoteException {
102         getInterface().turnOnIms();
103     }
104 
turnOffIms()105     public void turnOffIms() throws RemoteException {
106         getInterface().turnOffIms();
107     }
108 
getEcbmInterface()109     public IImsEcbm getEcbmInterface() throws RemoteException {
110         return getInterface().getEcbmInterface();
111     }
112 
setUiTTYMode(int uiTtyMode, Message onComplete)113     public void setUiTTYMode(int uiTtyMode, Message onComplete) throws RemoteException {
114         getInterface().setUiTTYMode(uiTtyMode, onComplete);
115     }
116 
getMultiEndpointInterface()117     public IImsMultiEndpoint getMultiEndpointInterface() throws RemoteException {
118         return getInterface().getMultiEndpointInterface();
119     }
120 
getInterface()121     private IImsMMTelFeature getInterface() throws RemoteException {
122         IImsMMTelFeature feature = IImsMMTelFeature.Stub.asInterface(mBinder);
123         if (feature == null) {
124             throw new RemoteException("Binder not Available");
125         }
126         return feature;
127     }
128 }
129