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 android.os.RemoteException; 20 import android.telephony.ims.ImsExternalCallState; 21 import android.telephony.ims.ImsReasonInfo; 22 23 import com.android.ims.internal.IImsExternalCallStateListener; 24 import com.android.ims.internal.IImsMultiEndpoint; 25 import com.android.telephony.Rlog; 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 ImsExternalCallStateListenerProxy(ImsExternalCallStateListener listener)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 onImsExternalCallStateUpdate(List<ImsExternalCallState> externalCallState)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 ImsMultiEndpoint(IImsMultiEndpoint iImsMultiEndpoint)67 public ImsMultiEndpoint(IImsMultiEndpoint iImsMultiEndpoint) { 68 if (DBG) Rlog.d(TAG, "ImsMultiEndpoint created"); 69 mImsMultiendpoint = iImsMultiEndpoint; 70 } 71 setExternalCallStateListener(ImsExternalCallStateListener externalCallStateListener)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 } 83 isBinderAlive()84 public boolean isBinderAlive() { 85 return mImsMultiendpoint.asBinder().isBinderAlive(); 86 } 87 } 88