1 /* 2 * Copyright (c) 2013 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.net.Uri; 20 import android.telephony.ims.ImsMmTelManager; 21 import android.telephony.ims.ImsReasonInfo; 22 import android.telephony.ims.feature.ImsFeature; 23 import android.telephony.ims.feature.MmTelFeature; 24 import android.telephony.ims.stub.ImsRegistrationImplBase; 25 26 import java.util.Arrays; 27 28 /** 29 * Listener for receiving notifications about changes to the IMS connection. 30 * It provides a state of IMS registration between UE and IMS network, the service 31 * availability of the local device during IMS registered. 32 * @Deprecated Use {@link ImsMmTelManager.RegistrationCallback} instead. 33 * @hide 34 */ 35 public class ImsConnectionStateListener extends ImsMmTelManager.RegistrationCallback { 36 37 @Override onRegistered(@msRegistrationImplBase.ImsRegistrationTech int imsRadioTech)38 public final void onRegistered(@ImsRegistrationImplBase.ImsRegistrationTech int imsRadioTech) { 39 onImsConnected(imsRadioTech); 40 } 41 42 @Override onRegistering(@msRegistrationImplBase.ImsRegistrationTech int imsRadioTech)43 public final void onRegistering(@ImsRegistrationImplBase.ImsRegistrationTech int imsRadioTech) { 44 onImsProgressing(imsRadioTech); 45 } 46 47 @Override onUnregistered(ImsReasonInfo info)48 public final void onUnregistered(ImsReasonInfo info) { 49 onImsDisconnected(info); 50 } 51 52 @Override onTechnologyChangeFailed( @msRegistrationImplBase.ImsRegistrationTech int imsRadioTech, ImsReasonInfo info)53 public final void onTechnologyChangeFailed( 54 @ImsRegistrationImplBase.ImsRegistrationTech int imsRadioTech, ImsReasonInfo info) { 55 onRegistrationChangeFailed(imsRadioTech, info); 56 } 57 58 @Override onSubscriberAssociatedUriChanged(Uri[] uris)59 public void onSubscriberAssociatedUriChanged(Uri[] uris) { 60 registrationAssociatedUriChanged(uris); 61 } 62 63 /** 64 * Used to convert from the new capabilities structure to the old features structure for 65 * backwards compatibility. 66 * @param imsRadioTech The registration that will be used to convert to the old feature 67 * structure. Can be either {@link ImsRegistrationImplBase#REGISTRATION_TECH_LTE} or 68 * {@link ImsRegistrationImplBase#REGISTRATION_TECH_IWLAN} 69 * @param c Capabilities that will be turned into old feature array. 70 */ onFeatureCapabilityChangedAdapter( @msRegistrationImplBase.ImsRegistrationTech int imsRadioTech, MmTelFeature.MmTelCapabilities c)71 public void onFeatureCapabilityChangedAdapter( 72 @ImsRegistrationImplBase.ImsRegistrationTech int imsRadioTech, 73 MmTelFeature.MmTelCapabilities c) { 74 // Size of ImsConfig.FeatureConstants 75 int[] enabledCapabilities = new int[6]; 76 // UNKNOWN means disabled. 77 Arrays.fill(enabledCapabilities, ImsConfig.FeatureConstants.FEATURE_TYPE_UNKNOWN); 78 // Size of ImsConfig.FeatureConstants 79 int[] disabledCapabilities = new int[6]; 80 Arrays.fill(disabledCapabilities, ImsConfig.FeatureConstants.FEATURE_TYPE_UNKNOWN); 81 // populate enabledCapabilities 82 switch (imsRadioTech) { 83 case ImsRegistrationImplBase.REGISTRATION_TECH_LTE: { 84 if (c.isCapable(MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VOICE)) { 85 // enabled means equal to its own integer value. 86 enabledCapabilities[ImsConfig.FeatureConstants.FEATURE_TYPE_VOICE_OVER_LTE] = 87 ImsConfig.FeatureConstants.FEATURE_TYPE_VOICE_OVER_LTE; 88 } 89 if (c.isCapable(MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VIDEO)) { 90 enabledCapabilities[ImsConfig.FeatureConstants.FEATURE_TYPE_VIDEO_OVER_LTE] = 91 ImsConfig.FeatureConstants.FEATURE_TYPE_VIDEO_OVER_LTE; 92 } 93 if (c.isCapable(MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_UT)) { 94 enabledCapabilities[ImsConfig.FeatureConstants.FEATURE_TYPE_UT_OVER_LTE] = 95 ImsConfig.FeatureConstants.FEATURE_TYPE_UT_OVER_LTE; 96 } 97 break; 98 } 99 case ImsRegistrationImplBase.REGISTRATION_TECH_IWLAN: { 100 if (c.isCapable(MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VOICE)) { 101 enabledCapabilities[ImsConfig.FeatureConstants.FEATURE_TYPE_VOICE_OVER_WIFI] = 102 ImsConfig.FeatureConstants.FEATURE_TYPE_VOICE_OVER_WIFI; 103 } 104 if (c.isCapable(MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VIDEO)) { 105 enabledCapabilities[ImsConfig.FeatureConstants.FEATURE_TYPE_VIDEO_OVER_WIFI] = 106 ImsConfig.FeatureConstants.FEATURE_TYPE_VIDEO_OVER_WIFI; 107 } 108 if (c.isCapable(MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_UT)) { 109 enabledCapabilities[ImsConfig.FeatureConstants.FEATURE_TYPE_UT_OVER_WIFI] = 110 ImsConfig.FeatureConstants.FEATURE_TYPE_UT_OVER_WIFI; 111 } 112 break; 113 } 114 } 115 // make disabledCapabilities the opposite of enabledCapabilities. Since the disabled 116 // capabilities array was defaulted to -1 it is UNKNOWN if not disabled. 117 for (int i = 0; i < enabledCapabilities.length; i++) { 118 if (enabledCapabilities[i] != i) { 119 disabledCapabilities[i] = i; 120 } 121 } 122 onFeatureCapabilityChanged(ImsServiceClass.MMTEL, enabledCapabilities, 123 disabledCapabilities); 124 } 125 /** 126 * Called when the device is connected to the IMS network with {@param imsRadioTech}. 127 */ onImsConnected(int imsRadioTech)128 public void onImsConnected(int imsRadioTech) { 129 // no-op 130 } 131 132 /** 133 * Called when the device is trying to connect to the IMS network with {@param imsRadioTech}. 134 */ onImsProgressing(int imsRadioTech)135 public void onImsProgressing(int imsRadioTech) { 136 // no-op 137 } 138 139 /** 140 * Called when the device is disconnected from the IMS network. 141 */ onImsDisconnected(ImsReasonInfo imsReasonInfo)142 public void onImsDisconnected(ImsReasonInfo imsReasonInfo) { 143 // no-op 144 } 145 146 /** 147 * Called when its suspended IMS connection is resumed, meaning the connection 148 * now allows throughput. 149 * @deprecated not used in newer IMS provider implementations. 150 */ onImsResumed()151 public void onImsResumed() { 152 // no-op 153 } 154 155 /** 156 * Called when its current IMS connection is suspended, meaning there is no data throughput. 157 * @deprecated not used in newer IMS provider implementations. 158 */ onImsSuspended()159 public void onImsSuspended() { 160 // no-op 161 } 162 163 /** 164 * Called when its current IMS connection feature capability changes. 165 * @deprecated Not used in newer IMS provider implementations. 166 */ onFeatureCapabilityChanged(int serviceClass, int[] enabledFeatures, int[] disabledFeatures)167 public void onFeatureCapabilityChanged(int serviceClass, 168 int[] enabledFeatures, int[] disabledFeatures) { 169 // no-op 170 } 171 172 /** 173 * Called when waiting voice message count changes. 174 * @deprecated not used in newer IMS provider implementations. 175 */ onVoiceMessageCountChanged(int count)176 public void onVoiceMessageCountChanged(int count) { 177 // no-op 178 } 179 180 /** 181 * Called after IMS registration. 182 */ registrationAssociatedUriChanged(Uri[] uris)183 public void registrationAssociatedUriChanged(Uri[] uris) { 184 // no-op 185 } 186 187 /** 188 * Called when IMS registration attempt on {@param imsRadioTech} failed 189 */ onRegistrationChangeFailed(int imsRadioTech, ImsReasonInfo imsReasonInfo)190 public void onRegistrationChangeFailed(int imsRadioTech, ImsReasonInfo imsReasonInfo) { 191 // no-op 192 } 193 } 194