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