blob: 8ac473a54bb05152d5e017128027a60c4948bf95 [file] [log] [blame]
Wink Savilleef36ef62014-06-11 08:39:38 -07001/*
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
17package com.android.ims;
18
Pavel Zhamaitsiak4de9cbb2016-02-11 17:21:05 -080019import android.net.Uri;
Brad Ebinger190ed932018-01-23 13:41:32 -080020import android.telephony.ims.ImsReasonInfo;
Brad Ebinger172977a2018-01-16 09:36:56 -080021import android.telephony.ims.feature.ImsFeature;
22import android.telephony.ims.feature.MmTelFeature;
Brad Ebinger44fd8af2017-12-14 14:24:02 -080023import android.telephony.ims.stub.ImsRegistrationImplBase;
Pavel Zhamaitsiak4de9cbb2016-02-11 17:21:05 -080024
Brad Ebinger172977a2018-01-16 09:36:56 -080025import java.util.Arrays;
26
Wink Savilleef36ef62014-06-11 08:39:38 -070027/**
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 Ebinger44fd8af2017-12-14 14:24:02 -080031 * @Deprecated Use {@link ImsRegistrationImplBase.Callback} instead.
Wink Savilleef36ef62014-06-11 08:39:38 -070032 * @hide
33 */
Brad Ebinger44fd8af2017-12-14 14:24:02 -080034public 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 Ebinger172977a2018-01-16 09:36:56 -080061
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 Ebinger01720f22018-04-24 14:04:38 -0700105 ImsConfig.FeatureConstants.FEATURE_TYPE_VIDEO_OVER_WIFI;
Brad Ebinger172977a2018-01-16 09:36:56 -0800106 }
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 Savilleef36ef62014-06-11 08:39:38 -0700124 /**
Meng Wangbb98b9b2016-12-07 16:27:15 -0800125 * Called when the device is connected to the IMS network with {@param imsRadioTech}.
Wink Savilleef36ef62014-06-11 08:39:38 -0700126 */
Meng Wangbb98b9b2016-12-07 16:27:15 -0800127 public void onImsConnected(int imsRadioTech) {
Wink Savilleef36ef62014-06-11 08:39:38 -0700128 // no-op
129 }
130
131 /**
Meng Wangbb98b9b2016-12-07 16:27:15 -0800132 * Called when the device is trying to connect to the IMS network with {@param imsRadioTech}.
Rekha Kumar7b72dc22015-02-04 10:47:00 -0800133 */
Meng Wangbb98b9b2016-12-07 16:27:15 -0800134 public void onImsProgressing(int imsRadioTech) {
Rekha Kumar7b72dc22015-02-04 10:47:00 -0800135 // no-op
136 }
137
138 /**
Wink Savilleef36ef62014-06-11 08:39:38 -0700139 * Called when the device is disconnected from the IMS network.
140 */
Rekha Kumar7b72dc22015-02-04 10:47:00 -0800141 public void onImsDisconnected(ImsReasonInfo imsReasonInfo) {
Wink Savilleef36ef62014-06-11 08:39:38 -0700142 // no-op
143 }
144
145 /**
146 * Called when its suspended IMS connection is resumed, meaning the connection
147 * now allows throughput.
Brad Ebinger44fd8af2017-12-14 14:24:02 -0800148 * @deprecated not used in newer IMS provider implementations.
Wink Savilleef36ef62014-06-11 08:39:38 -0700149 */
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 Ebinger44fd8af2017-12-14 14:24:02 -0800156 * @deprecated not used in newer IMS provider implementations.
Wink Savilleef36ef62014-06-11 08:39:38 -0700157 */
158 public void onImsSuspended() {
159 // no-op
160 }
Libin.Tang@motorola.come2296782014-08-19 14:20:01 -0500161
162 /**
163 * Called when its current IMS connection feature capability changes.
Brad Ebinger44fd8af2017-12-14 14:24:02 -0800164 * @deprecated Not used in newer IMS provider implementations.
Libin.Tang@motorola.come2296782014-08-19 14:20:01 -0500165 */
166 public void onFeatureCapabilityChanged(int serviceClass,
167 int[] enabledFeatures, int[] disabledFeatures) {
168 // no-op
169 }
Shriram Ganeshd3adfad2015-05-31 10:06:15 -0700170
171 /**
172 * Called when waiting voice message count changes.
Brad Ebinger44fd8af2017-12-14 14:24:02 -0800173 * @deprecated not used in newer IMS provider implementations.
Shriram Ganeshd3adfad2015-05-31 10:06:15 -0700174 */
175 public void onVoiceMessageCountChanged(int count) {
176 // no-op
177 }
Pavel Zhamaitsiak4de9cbb2016-02-11 17:21:05 -0800178
179 /**
180 * Called after IMS registration.
181 */
182 public void registrationAssociatedUriChanged(Uri[] uris) {
183 // no-op
184 }
Meng Wangbb98b9b2016-12-07 16:27:15 -0800185
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 Savilleef36ef62014-06-11 08:39:38 -0700192}