blob: 1315dbd33e3fba1451365dd7eaa24a00ba3c467e [file] [log] [blame]
Tyler Gunn4d128b62016-04-13 15:44:38 -07001/*
2 * Copyright (C) 2016 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
17package com.android.ims;
18
19import com.android.ims.internal.IImsMultiEndpoint;
20import com.android.ims.internal.IImsExternalCallStateListener;
21
22import android.os.RemoteException;
23import android.telephony.Rlog;
Brad Ebinger190ed932018-01-23 13:41:32 -080024import android.telephony.ims.ImsExternalCallState;
25import android.telephony.ims.ImsReasonInfo;
Tyler Gunn4d128b62016-04-13 15:44:38 -070026
27import java.util.List;
28
29/**
30 * Provides APIs for the IMS multi-endpoint functionality. Specifically, provides a means for IMS
31 * to subscribe to dialog event packages issued by the network.
32 *
33 * @hide
34 */
35public class ImsMultiEndpoint {
36 /**
37 * Adapter class for {@link IImsExternalCallStateListener}.
38 */
39 private class ImsExternalCallStateListenerProxy extends IImsExternalCallStateListener.Stub {
40 private ImsExternalCallStateListener mListener;
41
42 public ImsExternalCallStateListenerProxy(ImsExternalCallStateListener listener) {
43 mListener = listener;
44 }
45
46
47 /**
48 * Notifies client when Dialog Event Package update is received
49 *
50 * @param externalCallState the external call state.
51 */
52 @Override
53 public void onImsExternalCallStateUpdate(List<ImsExternalCallState> externalCallState) {
54 if (DBG) Rlog.d(TAG, "onImsExternalCallStateUpdate");
55
56 if (mListener != null) {
57 mListener.onImsExternalCallStateUpdate(externalCallState);
58 }
59 }
60 }
61
62 private static final String TAG = "ImsMultiEndpoint";
63 private static final boolean DBG = true;
64
65 private final IImsMultiEndpoint mImsMultiendpoint;
66
67 public ImsMultiEndpoint(IImsMultiEndpoint iImsMultiEndpoint) {
68 if (DBG) Rlog.d(TAG, "ImsMultiEndpoint created");
69 mImsMultiendpoint = iImsMultiEndpoint;
70 }
71
72 public void setExternalCallStateListener(ImsExternalCallStateListener externalCallStateListener)
73 throws ImsException {
74 try {
75 if (DBG) Rlog.d(TAG, "setExternalCallStateListener");
76 mImsMultiendpoint.setListener(new ImsExternalCallStateListenerProxy(
77 externalCallStateListener));
78 } catch (RemoteException e) {
79 throw new ImsException("setExternalCallStateListener could not be set.", e,
80 ImsReasonInfo.CODE_LOCAL_IMS_SERVICE_DOWN);
81 }
82 }
Brad Ebingerf68247f2017-06-20 16:29:50 -070083
84 public boolean isBinderAlive() {
85 return mImsMultiendpoint.asBinder().isBinderAlive();
86 }
Tyler Gunn4d128b62016-04-13 15:44:38 -070087}