1 /* 2 * Copyright (C) 2018 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.internal.telephony.ims; 18 19 import static android.telephony.ServiceState.RIL_RADIO_TECHNOLOGY_IWLAN; 20 import static android.telephony.ServiceState.RIL_RADIO_TECHNOLOGY_LTE; 21 import static android.telephony.ServiceState.RIL_RADIO_TECHNOLOGY_NR; 22 23 import android.net.Uri; 24 import android.os.RemoteException; 25 import android.telephony.ims.ImsReasonInfo; 26 import android.telephony.ims.stub.ImsRegistrationImplBase; 27 import android.util.ArrayMap; 28 29 import com.android.ims.internal.IImsRegistrationListener; 30 31 import java.util.Map; 32 33 public class ImsRegistrationCompatAdapter extends ImsRegistrationImplBase { 34 35 // Maps "RAT" based radio technologies to ImsRegistrationImplBase definitions. 36 private static final Map<Integer, Integer> RADIO_TECH_MAPPER = new ArrayMap<>(2); 37 static { RADIO_TECH_MAPPER.put(RIL_RADIO_TECHNOLOGY_NR, REGISTRATION_TECH_NR)38 RADIO_TECH_MAPPER.put(RIL_RADIO_TECHNOLOGY_NR, REGISTRATION_TECH_NR); RADIO_TECH_MAPPER.put(RIL_RADIO_TECHNOLOGY_LTE, REGISTRATION_TECH_LTE)39 RADIO_TECH_MAPPER.put(RIL_RADIO_TECHNOLOGY_LTE, REGISTRATION_TECH_LTE); RADIO_TECH_MAPPER.put(RIL_RADIO_TECHNOLOGY_IWLAN, REGISTRATION_TECH_IWLAN)40 RADIO_TECH_MAPPER.put(RIL_RADIO_TECHNOLOGY_IWLAN, REGISTRATION_TECH_IWLAN); 41 } 42 43 // Trampolines "old" listener events to the new interface. 44 private final IImsRegistrationListener mListener = new IImsRegistrationListener.Stub() { 45 @Override 46 public void registrationConnected() throws RemoteException { 47 onRegistered(REGISTRATION_TECH_NONE); 48 } 49 50 @Override 51 public void registrationProgressing() throws RemoteException { 52 onRegistering(REGISTRATION_TECH_NONE); 53 } 54 55 @Override 56 public void registrationConnectedWithRadioTech(int imsRadioTech) throws RemoteException { 57 onRegistered(RADIO_TECH_MAPPER.getOrDefault(imsRadioTech, REGISTRATION_TECH_NONE)); 58 } 59 60 @Override 61 public void registrationProgressingWithRadioTech(int imsRadioTech) throws RemoteException { 62 onRegistering(RADIO_TECH_MAPPER.getOrDefault(imsRadioTech, REGISTRATION_TECH_NONE)); 63 } 64 65 @Override 66 public void registrationDisconnected(ImsReasonInfo imsReasonInfo) throws RemoteException { 67 onDeregistered(imsReasonInfo); 68 } 69 70 @Override 71 public void registrationResumed() throws RemoteException { 72 // Don't care 73 } 74 75 @Override 76 public void registrationSuspended() throws RemoteException { 77 // Don't care 78 } 79 80 @Override 81 public void registrationServiceCapabilityChanged(int serviceClass, int event) 82 throws RemoteException { 83 // Don't care 84 } 85 86 @Override 87 public void registrationFeatureCapabilityChanged(int serviceClass, int[] enabledFeatures, 88 int[] disabledFeatures) throws RemoteException { 89 // Implemented in the MMTel Adapter 90 } 91 92 @Override 93 public void voiceMessageCountUpdate(int count) throws RemoteException { 94 // Implemented in the MMTel Adapter 95 } 96 97 @Override 98 public void registrationAssociatedUriChanged(Uri[] uris) throws RemoteException { 99 onSubscriberAssociatedUriChanged(uris); 100 } 101 102 @Override 103 public void registrationChangeFailed(int targetAccessTech, ImsReasonInfo imsReasonInfo) 104 throws RemoteException { 105 onTechnologyChangeFailed(RADIO_TECH_MAPPER.getOrDefault(targetAccessTech, 106 REGISTRATION_TECH_NONE), imsReasonInfo); 107 } 108 }; 109 110 /** 111 * Need access to the listener in order to register for events in MMTelFeature adapter 112 */ getRegistrationListener()113 public IImsRegistrationListener getRegistrationListener() { 114 return mListener; 115 } 116 } 117