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