Tyler Gunn | 4d128b6 | 2016-04-13 15:44:38 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package com.android.ims; |
| 18 | |
| 19 | import com.android.ims.internal.IImsMultiEndpoint; |
| 20 | import com.android.ims.internal.IImsExternalCallStateListener; |
| 21 | |
| 22 | import android.os.RemoteException; |
| 23 | import android.telephony.Rlog; |
Brad Ebinger | 190ed93 | 2018-01-23 13:41:32 -0800 | [diff] [blame] | 24 | import android.telephony.ims.ImsExternalCallState; |
| 25 | import android.telephony.ims.ImsReasonInfo; |
Tyler Gunn | 4d128b6 | 2016-04-13 15:44:38 -0700 | [diff] [blame] | 26 | |
| 27 | import 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 | */ |
| 35 | public 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 Ebinger | f68247f | 2017-06-20 16:29:50 -0700 | [diff] [blame] | 83 | |
| 84 | public boolean isBinderAlive() { |
| 85 | return mImsMultiendpoint.asBinder().isBinderAlive(); |
| 86 | } |
Tyler Gunn | 4d128b6 | 2016-04-13 15:44:38 -0700 | [diff] [blame] | 87 | } |