1 /*
2  * Copyright (C) 2017 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.stub;
18 
19 import android.annotation.SystemApi;
20 import android.os.RemoteException;
21 import android.util.Log;
22 
23 import android.telephony.ims.ImsExternalCallState;
24 import com.android.ims.internal.IImsExternalCallStateListener;
25 import com.android.ims.internal.IImsMultiEndpoint;
26 
27 import java.util.List;
28 
29 /**
30  * Base implementation of ImsMultiEndpoint, which implements stub versions of the methods
31  * in the IImsMultiEndpoint AIDL. Override the methods that your implementation of
32  * ImsMultiEndpoint supports.
33  *
34  * DO NOT remove or change the existing APIs, only add new ones to this Base implementation or you
35  * will break other implementations of ImsMultiEndpoint maintained by other ImsServices.
36  *
37  * @hide
38  */
39 @SystemApi
40 public class ImsMultiEndpointImplBase {
41     private static final String TAG = "MultiEndpointImplBase";
42 
43     private IImsExternalCallStateListener mListener;
44     private IImsMultiEndpoint mImsMultiEndpoint = new IImsMultiEndpoint.Stub() {
45         @Override
46         public void setListener(IImsExternalCallStateListener listener) throws RemoteException {
47             mListener = listener;
48         }
49 
50         @Override
51         public void requestImsExternalCallStateInfo() throws RemoteException {
52             ImsMultiEndpointImplBase.this.requestImsExternalCallStateInfo();
53         }
54     };
55 
56     /** @hide */
getIImsMultiEndpoint()57     public IImsMultiEndpoint getIImsMultiEndpoint() {
58         return mImsMultiEndpoint;
59     }
60 
61     /**
62      * Notifies framework when Dialog Event Package update is received
63      *
64      * @throws RuntimeException if the connection to the framework is not available.
65      */
onImsExternalCallStateUpdate(List<ImsExternalCallState> externalCallDialogs)66     public final void onImsExternalCallStateUpdate(List<ImsExternalCallState> externalCallDialogs) {
67         Log.d(TAG, "ims external call state update triggered.");
68         if (mListener != null) {
69             try {
70                 mListener.onImsExternalCallStateUpdate(externalCallDialogs);
71             } catch (RemoteException e) {
72                 throw new RuntimeException(e);
73             }
74         }
75     }
76 
77     /**
78      * This method should be implemented by the IMS provider. Framework will trigger this to get the
79      * latest Dialog Event Package information. Should
80      */
requestImsExternalCallStateInfo()81     public void requestImsExternalCallStateInfo() {
82         Log.d(TAG, "requestImsExternalCallStateInfo() not implemented");
83     }
84 }
85