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 com.android.ims.internal.IImsEcbm; 24 import com.android.ims.internal.IImsEcbmListener; 25 26 /** 27 * Base implementation of ImsEcbm, which implements stub versions of the methods 28 * in the IImsEcbm AIDL. Override the methods that your implementation of ImsEcbm supports. 29 * 30 * DO NOT remove or change the existing APIs, only add new ones to this Base implementation or you 31 * will break other implementations of ImsEcbm maintained by other ImsServices. 32 * 33 * @hide 34 */ 35 @SystemApi 36 public class ImsEcbmImplBase { 37 private static final String TAG = "ImsEcbmImplBase"; 38 39 private IImsEcbmListener mListener; 40 private IImsEcbm mImsEcbm = new IImsEcbm.Stub() { 41 @Override 42 public void setListener(IImsEcbmListener listener) { 43 mListener = listener; 44 } 45 46 @Override 47 public void exitEmergencyCallbackMode() { 48 ImsEcbmImplBase.this.exitEmergencyCallbackMode(); 49 } 50 }; 51 52 /** @hide */ getImsEcbm()53 public IImsEcbm getImsEcbm() { 54 return mImsEcbm; 55 } 56 57 /** 58 * This method should be implemented by the IMS provider. Framework will trigger this method to 59 * request to come out of ECBM mode 60 */ exitEmergencyCallbackMode()61 public void exitEmergencyCallbackMode() { 62 Log.d(TAG, "exitEmergencyCallbackMode() not implemented"); 63 } 64 65 /** 66 * Notifies the framework when the device enters Emergency Callback Mode. 67 * 68 * @throws RuntimeException if the connection to the framework is not available. 69 */ enteredEcbm()70 public final void enteredEcbm() { 71 Log.d(TAG, "Entered ECBM."); 72 if (mListener != null) { 73 try { 74 mListener.enteredECBM(); 75 } catch (RemoteException e) { 76 throw new RuntimeException(e); 77 } 78 } 79 } 80 81 /** 82 * Notifies the framework when the device exits Emergency Callback Mode. 83 * 84 * @throws RuntimeException if the connection to the framework is not available. 85 */ exitedEcbm()86 public final void exitedEcbm() { 87 Log.d(TAG, "Exited ECBM."); 88 if (mListener != null) { 89 try { 90 mListener.exitedECBM(); 91 } catch (RemoteException e) { 92 throw new RuntimeException(e); 93 } 94 } 95 } 96 } 97