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